Package ubic.basecode.math
Class SpecFunc
- java.lang.Object
-
- ubic.basecode.math.SpecFunc
-
public class SpecFunc extends Object
Assorted special functions, primarily concerning probability distributions. For cumBinomial use cern.jet.stat.Probability.binomial.Mostly ported from the R source tree (dhyper.c etc.), much due to Catherine Loader.
- Author:
- Paul Pavlidis
- See Also:
- cern.jet.stat.gamma , cern.jet.math.arithmetic
-
-
Constructor Summary
Constructors Constructor Description SpecFunc()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
dbinom(double x, double n, double p)
See dbinom_raw.static double
dhyper(int x, int r, int b, int n)
Ported from R (Catherine Loader)static double
phyper(int x, int NR, int NB, int n, boolean lowerTail)
Ported from R phyper.cstatic double
trigammaInverse(double x)
static cern.colt.matrix.DoubleMatrix1D
trigammaInverse(cern.colt.matrix.DoubleMatrix1D x)
Ported from limma
-
-
-
Method Detail
-
dbinom
public static double dbinom(double x, double n, double p)
See dbinom_raw.- Parameters:
x
- Number of successesn
- Number of trialsp
- Probability of success- Returns:
-
dhyper
public static double dhyper(int x, int r, int b, int n)
Ported from R (Catherine Loader)DESCRIPTION
Given a sequence of r successes and b failures, we sample n (\le b+r) items without replacement. The hypergeometric probability is the probability of x successes:
choose(r, x) * choose(b, n-x) (x; r,b,n) = ----------------------------- = choose(r+b, n) dbinom(x,r,p) * dbinom(n-x,b,p) = -------------------------------- dbinom(n,r+b,p)
for any p. For numerical stability, we take p=n/(r+b); with this choice, the denominator is not exponentially small.
-
phyper
public static double phyper(int x, int NR, int NB, int n, boolean lowerTail)
Ported from R phyper.cSample of n balls from NR red and NB black ones; x are red
- Parameters:
x
- - number of reds retrieved == successesNR
- - number of reds in the urn. == positivesNB
- - number of blacks in the urn == negativesn
- - the total number of objects drawn == successes + failureslowerTail
-- Returns:
- cumulative hypergeometric distribution.
-
trigammaInverse
public static double trigammaInverse(double x)
- Parameters:
x
-- Returns:
-
trigammaInverse
public static cern.colt.matrix.DoubleMatrix1D trigammaInverse(cern.colt.matrix.DoubleMatrix1D x)
Ported from limma- Parameters:
x
- vector to be operated on- Returns:
- solution for y: trigamma(y) = x
-
-