def hypergeoP_byLog(n,i,m,N): """ Calculates the non-cumulative hypergeometric p-value for variables: n = # of positives in population i = # of positives in sample m = # of negatives in population N = sample size P(x=i) = (choose(n,i)choose(m,N-i))/choose(n+m,N) For more details -> http://mathworld.wolfram.com/HypergeometricDistribution.html """ return 10**(log10(bestChoose(n,i))+log10(bestChoose(m,N-i))-log10(bestChoose(n+m,N)))
def hypergeoP(n,i,m,N): """ | Calculates the non-cumulative hypergeometric *p-value* for variables: | | ``n`` = number of positives in population | ``i`` = number of positives in sample | ``m`` = number of negatives in population | ``N`` = sample size | | *P(x=i) = (choose(n,i)choose(m,N-i))/choose(n+m,N)* | | For more details -> http://mathworld.wolfram.com/HypergeometricDistribution.html """ return (bestChoose(n,i)*bestChoose(m,N-i))/float(bestChoose(n+m,N))
def binomialPval(n,k,p): """Returns exact binomial P-value. n = number of trials k = number of successes p = probability of a success P(k succeses in n trials) = choose(n,k) * p^k * (1-p)^(n-k) """ return bestChoose(n,k) * p**k * (1-p)**(n-k)
def binomialPval(n,k,p): """ *RETURNS:* * exact binomial P-value. | ``n`` = number of trials | ``k`` = number of successes | ``p`` = probability of a success | | *P(k succeses in n trials) = choose(n,k) (p^k) ((1-p)^(n-k))* """ return bestChoose(n,k) * p**k * (1-p)**(n-k)