Skip to content

Commit

Permalink
attempted fix to issue #3. Not resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
keflavich committed Jun 16, 2014
1 parent 37c831d commit 884aeb9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions plfit/plfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def alpha(xmin,x=x):
return a
return alpha

def kstest_(self,x):
def kstest_(self,x,unique=False,finite=False):
"""
Create a mappable function kstest to apply to each xmin in a list of xmins.
Expand All @@ -107,12 +107,16 @@ def kstest_(self,x):
The returned value is the "D" parameter in the ks test.
"""
def kstest(xmin,x=x):
if unique:
x = numpy.unique(x)
x = x[x>=xmin]
n = float(len(x))
n = len(x)
if n == 0: return numpy.inf
a = float(n) / sum(log(x/xmin))
a = 1+float(n) / sum(log(x/xmin))
if finite:
a = a*(n-1.)/n+1./n
cx = numpy.arange(n,dtype='float')/float(n)
cf = 1-(xmin/x)**a
cf = 1-(xmin/x)**(a-1)
ks = max(abs(cf-cx))
return ks
return kstest
Expand Down

0 comments on commit 884aeb9

Please sign in to comment.