Mercurial > repos > iuc > ngsutils_bam_filter
diff ngsutils/support/stats.py @ 2:7a68005de299 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ngsutils commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
author | iuc |
---|---|
date | Sun, 27 Nov 2016 15:01:21 -0500 |
parents | 4e4e4093d65d |
children |
line wrap: on
line diff
--- a/ngsutils/support/stats.py Sun Dec 06 05:03:12 2015 -0500 +++ b/ngsutils/support/stats.py Sun Nov 27 15:01:21 2016 -0500 @@ -2,8 +2,10 @@ various statistical tests and methods... ''' import math + from ngsutils.support import memoize + def median(vals): ''' >>> median([1,2,3]) @@ -106,6 +108,7 @@ return (mean, stdev) + @memoize def poisson_prob(x, mean): ''' @@ -120,15 +123,16 @@ 0.33277427882095645 ''' acc = 0.0 - for i in xrange(1, x+1): + for i in xrange(1, x + 1): acc += poisson_func(i, mean) return acc + @memoize def poisson_func(mu, lambd): ''' This is the Poisson distribution function - + p(mu) = (lambda^mu * e^(-lambda)) / (mu!) mu is a count @@ -156,6 +160,7 @@ ''' return math.factorial(x) + if __name__ == '__main__': import doctest doctest.testmod()