Changeset 1934:d0e896ee439a in orange-bioinformatics for orangecontrib/bio/obiProb.py


Ignore:
Timestamp:
12/12/13 14:09:36 (4 months ago)
Author:
markotoplak
Branch:
default
Message:

Converted obiProb documentation to rst.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/obiProb.py

    r1890 r1934  
    5050 
    5151class 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. """ 
    5257 
    5358    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 + (1-p)**(n-k)) 
     62        where bin is the binomial coefficient. """ 
     63 
    5464        p = 1.0 * m / N 
    5565        if p == 0.0: 
     
    7181 
    7282    def p_value(self, k, N, m, n): 
     83        """ The probability that k or more tests are positive. """ 
    7384        if n - k + 1 <= k: 
    7485            #starting from k gives the shorter list of values 
     
    8697 
    8798class 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    """ 
    88106 
    89107    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(N-m, n-k)/bin(N,n) 
     111        where bin is the binomial coefficient). 
     112        """ 
    90113        if k < max(0, n + m - N) or k > min(n, m): 
    91114            return 0.0 
     
    97120 
    98121    def p_value(self, k, N, m, n): 
    99         #From wolfram alpha: 
    100         #1-CDF[HypergeometricDistribution[80, 50, 2000], 20-1] = 1.75695e-16 
    101         #1-CDF[HypergeometricDistribution[80, 50, 2000], 40-1] = 9.92008e-52 
     122        """  
     123        The probability that k or more tests are positive. 
     124        """ 
    102125 
    103126        if min(n,m) - k + 1 <= k: 
     
    125148def FDR(p_values, dependent=False, m=None, ordered=False): 
    126149    """ 
    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 p-values. 
     151 
     152    :param p_values: a list of p-values. 
     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 p-values if they are already sorted (default False). 
    129156    """ 
    130157 
     
    164191 
    165192def Bonferroni(p_values, m=None): 
     193    """ 
     194    `Bonferroni correction <http://en.wikipedia.org/wiki/Bonferroni_correction>`_ correction on a list of p-values. 
     195 
     196    :param p_values: a list of p-values. 
     197    :param m: number of hypotheses tested (default ``len(p_values)``). 
     198    """ 
    166199    if not m: 
    167200        m = len(p_values) 
Note: See TracChangeset for help on using the changeset viewer.