New implementation of binomial probability that accurately computes values down to around 1e-237.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@520 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
305584b69e
commit
3cda85f2e3
|
|
@ -1,5 +1,7 @@
|
||||||
package org.broadinstitute.sting.utils;
|
package org.broadinstitute.sting.utils;
|
||||||
|
|
||||||
|
import cern.jet.math.Arithmetic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MathUtils is a static class (no instantiation allowed!) with some useful math methods.
|
* MathUtils is a static class (no instantiation allowed!) with some useful math methods.
|
||||||
*
|
*
|
||||||
|
|
@ -56,4 +58,17 @@ public class MathUtils {
|
||||||
if (a > b) { return -1; }
|
if (a > b) { return -1; }
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes a binomial probability
|
||||||
|
*
|
||||||
|
* @param k number of successes
|
||||||
|
* @param n number of Bernoulli trials
|
||||||
|
* @param p probability of success
|
||||||
|
*
|
||||||
|
* @return the binomial probability of the specified configuration. Computes values down to about 1e-237.
|
||||||
|
*/
|
||||||
|
public static double binomialProbability(long k, long n, double p) {
|
||||||
|
return Arithmetic.binomial(n, k)*Math.pow(p, k)*Math.pow(1.0 - p, n - k);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue