Skip to content

Commit

Permalink
fixed pearson correlation function, added case r<-1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alnf committed Aug 3, 2017
1 parent 2a05f7a commit 904c1bd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BNfinder/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ def lpearsonr(x,y):
df = n-2
if r>1.0: # sometimes due to rounding errors we get r>1.0 ...
r=1.0-TINY
if r<-1.0: # or r<-1.0
r=-1.0+TINY
t = r*math.sqrt(df/((1.0-r+TINY)*(1.0+r+TINY)))
prob = betai(0.5*df,0.5,df/float(df+t*t))
return r, prob
Expand Down

0 comments on commit 904c1bd

Please sign in to comment.