Changeset 1890:043f2b1864cd in orangebioinformatics for orangecontrib/bio/obiProb.py
 Timestamp:
 10/15/13 13:07:59 (6 months ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

orangecontrib/bio/obiProb.py
r1889 r1890 71 71 72 72 def p_value(self, k, N, m, n): 73 subtract = n  k + 1 > k 74 result = sum([self.__call__(i, N, m, n) for i in (range(k) if subtract else range(k, n+1))]) 75 return max(1.0  result if subtract else result, 0.0) 73 if n  k + 1 <= k: 74 #starting from k gives the shorter list of values 75 return sum(self.__call__(i, N, m, n) for i in range(k, n+1)) 76 else: 77 value = 1.0  sum(self.__call__(i, N, m, n) for i in range(k)) 78 #if the value is small it is probably inexact due to the limited 79 #precision of floats, as for example (1(11e20)) > 0 80 #if so, compute the result without substraction 81 if value < 1e3: #arbitary threshold 82 #print "INEXACT", value, sum(self.__call__(i, N, m, n) for i in range(k, n+1)) 83 return sum(self.__call__(i, N, m, n) for i in range(k, n+1)) 84 else: 85 return value 76 86 77 87 class Hypergeometric(LogBin): … … 97 107 value = 1.0  sum(self.__call__(i, N, m, n) for i in (range(k))) 98 108 #if the value is small it is probably inexact due to the limited 99 #precision of floats, as for example (1(11 0e20)) > 0109 #precision of floats, as for example (1(11e20)) > 0 100 110 #if so, compute the result without substraction 101 111 if value < 1e3: #arbitary threshold
Note: See TracChangeset
for help on using the changeset viewer.