public class SpecFunc extends Object
Mostly ported from the R source tree (dhyper.c etc.), much due to Catherine Loader.
Constructor and Description |
---|
SpecFunc() |
Modifier and Type | Method and 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.c
|
static double |
trigammaInverse(double x) |
static cern.colt.matrix.DoubleMatrix1D |
trigammaInverse(cern.colt.matrix.DoubleMatrix1D x)
Ported from limma
|
public static double dbinom(double x, double n, double p)
x
- Number of successesn
- Number of trialsp
- Probability of successpublic static double dhyper(int x, int r, int b, int n)
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.
public static double phyper(int x, int NR, int NB, int n, boolean lowerTail)
Sample of n balls from NR red and NB black ones; x are red
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
- public static double trigammaInverse(double x)
x
- public static cern.colt.matrix.DoubleMatrix1D trigammaInverse(cern.colt.matrix.DoubleMatrix1D x)
x
- vector to be operated onCopyright © 2003–2023 UBC Michael Smith Laboratories. All rights reserved.