Changeset 1934:d0e896ee439a in orangebioinformatics for orangecontrib/bio/obiProb.py
 Timestamp:
 12/12/13 14:09:36 (4 months ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

orangecontrib/bio/obiProb.py
r1890 r1934 50 50 51 51 class Binomial(LogBin): 52 """ `Binomial distribution 53 <http://en.wikipedia.org/wiki/Binomial_distribution>`_ is a discrete 54 probability distribution of the number of successes in a sequence 55 of n independent yes/no experiments, each of which yields success 56 with probability p. """ 52 57 53 58 def __call__(self, k, N, m, n): 59 """ If m out of N experiments are positive return the probability 60 that k out of n experiments are positive using the binomial 61 distribution: if p = m/N then return bin(n,k)*(p**k + (1p)**(nk)) 62 where bin is the binomial coefficient. """ 63 54 64 p = 1.0 * m / N 55 65 if p == 0.0: … … 71 81 72 82 def p_value(self, k, N, m, n): 83 """ The probability that k or more tests are positive. """ 73 84 if n  k + 1 <= k: 74 85 #starting from k gives the shorter list of values … … 86 97 87 98 class Hypergeometric(LogBin): 99 """ `Hypergeometric distribution 100 <http://en.wikipedia.org/wiki/Hypergeometric_distribution>`_ is 101 a discrete probability distribution that describes the number of 102 successes in a sequence of n draws from a finite population without 103 replacement. 104 105 """ 88 106 89 107 def __call__(self, k, N, m, n): 108 """If m out of N experiments are positive return the probability 109 that k out of n experiments are positive using the hypergeometric 110 distribution (i.e. return bin(m, k)*bin(Nm, nk)/bin(N,n) 111 where bin is the binomial coefficient). 112 """ 90 113 if k < max(0, n + m  N) or k > min(n, m): 91 114 return 0.0 … … 97 120 98 121 def p_value(self, k, N, m, n): 99 #From wolfram alpha:100 #1CDF[HypergeometricDistribution[80, 50, 2000], 201] = 1.75695e16101 #1CDF[HypergeometricDistribution[80, 50, 2000], 401] = 9.92008e52122 """ 123 The probability that k or more tests are positive. 124 """ 102 125 103 126 if min(n,m)  k + 1 <= k: … … 125 148 def FDR(p_values, dependent=False, m=None, ordered=False): 126 149 """ 127 If the user is sure that pvalues as already sorted nondescendingly 128 setting ordered=True will make the computation faster. 150 `False Discovery Rate <http://en.wikipedia.org/wiki/False_discovery_rate>`_ correction on a list of pvalues. 151 152 :param p_values: a list of pvalues. 153 :param dependent: use correction for dependent hypotheses (default False). 154 :param m: number of hypotheses tested (default ``len(p_values)``). 155 :param ordered: prevent sorting of pvalues if they are already sorted (default False). 129 156 """ 130 157 … … 164 191 165 192 def Bonferroni(p_values, m=None): 193 """ 194 `Bonferroni correction <http://en.wikipedia.org/wiki/Bonferroni_correction>`_ correction on a list of pvalues. 195 196 :param p_values: a list of pvalues. 197 :param m: number of hypotheses tested (default ``len(p_values)``). 198 """ 166 199 if not m: 167 200 m = len(p_values)
Note: See TracChangeset
for help on using the changeset viewer.