Package cern.jet.random
Class HyperGeometric
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.jet.random.AbstractDistribution
-
- cern.jet.random.AbstractDiscreteDistribution
-
- cern.jet.random.HyperGeometric
-
- All Implemented Interfaces:
DoubleFunction
,IntFunction
,java.io.Serializable
,java.lang.Cloneable
public class HyperGeometric extends AbstractDiscreteDistribution
HyperGeometric distribution; See the math definition The hypergeometric distribution with parameters N, n and s is the probability distribution of the random variable X, whose value is the number of successes in a sample of n items from a population of size N that has s 'success' items and N - s 'failure' items.p(k) = C(s,k) * C(N-s,n-k) / C(N,n) where C(a,b) = a! / (b! * (a-b)!).
valid for N >= 2, s,n <= N.
Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
- Static methods operate on a default uniform random number generator; they are synchronized.
Implementation: High performance implementation. Patchwork Rejection/Inversion method.
- This is a port of hprsc.c from the C-RAND / WIN-RAND library. C-RAND's implementation, in turn, is based upon
H. Zechner (1994): Efficient sampling from continuous and discrete unimodal distributions, Doctoral Dissertation, 156 pp., Technical University Graz, Austria.
- Version:
- 1.0, 09/24/99
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private int
b
private double
c_pm
private double
dl
private double
dr
private double
f1
private double
f2
private double
f4
private double
f5
private double
fm
private int
k1
private int
k2
private int
k4
private int
k5
private double
ll
private double
lr
private int
m
private int
M_last
private int
mp
private double
Mp
protected int
my_n
protected int
my_N
protected int
my_s
private int
n_last
private int
N_last
private int
N_Mn
private double
np
private double
p1
private double
p2
private double
p3
private double
p4
private double
p5
private double
p6
private double
r1
private double
r2
private double
r4
private double
r5
protected static HyperGeometric
shared
-
Fields inherited from class cern.jet.random.AbstractDistribution
randomGenerator
-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Constructor Description HyperGeometric(int N, int s, int n, RandomEngine randomGenerator)
Constructs a HyperGeometric distribution.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static double
fc_lnpk(int k, int N_Mn, int M, int n)
protected int
hmdu(int N, int M, int n, RandomEngine randomGenerator)
Returns a random number from the distribution.protected int
hprs(int N, int M, int n, RandomEngine randomGenerator)
Returns a random number from the distribution.int
nextInt()
Returns a random number from the distribution.int
nextInt(int N, int s, int n)
Returns a random number from the distribution; bypasses the internal state.protected int
nextInt(int N, int M, int n, RandomEngine randomGenerator)
Returns a random number from the distribution; bypasses the internal state.double
pdf(int k)
Returns the probability distribution function.void
setState(int N, int s, int n)
Sets the parameters.static double
staticNextInt(int N, int M, int n)
Returns a random number from the distribution.java.lang.String
toString()
Returns a String representation of the receiver.private static void
xstaticSetRandomGenerator(RandomEngine randomGenerator)
Sets the uniform random number generated shared by all static methods.-
Methods inherited from class cern.jet.random.AbstractDiscreteDistribution
nextDouble
-
Methods inherited from class cern.jet.random.AbstractDistribution
apply, apply, clone, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
-
-
-
-
Field Detail
-
my_N
protected int my_N
-
my_s
protected int my_s
-
my_n
protected int my_n
-
N_last
private int N_last
-
M_last
private int M_last
-
n_last
private int n_last
-
N_Mn
private int N_Mn
-
m
private int m
-
mp
private int mp
-
b
private int b
-
Mp
private double Mp
-
np
private double np
-
fm
private double fm
-
k2
private int k2
-
k4
private int k4
-
k1
private int k1
-
k5
private int k5
-
dl
private double dl
-
dr
private double dr
-
r1
private double r1
-
r2
private double r2
-
r4
private double r4
-
r5
private double r5
-
ll
private double ll
-
lr
private double lr
-
c_pm
private double c_pm
-
f1
private double f1
-
f2
private double f2
-
f4
private double f4
-
f5
private double f5
-
p1
private double p1
-
p2
private double p2
-
p3
private double p3
-
p4
private double p4
-
p5
private double p5
-
p6
private double p6
-
shared
protected static HyperGeometric shared
-
-
Constructor Detail
-
HyperGeometric
public HyperGeometric(int N, int s, int n, RandomEngine randomGenerator)
Constructs a HyperGeometric distribution.
-
-
Method Detail
-
fc_lnpk
private static double fc_lnpk(int k, int N_Mn, int M, int n)
-
hmdu
protected int hmdu(int N, int M, int n, RandomEngine randomGenerator)
Returns a random number from the distribution.
-
hprs
protected int hprs(int N, int M, int n, RandomEngine randomGenerator)
Returns a random number from the distribution.
-
nextInt
public int nextInt()
Returns a random number from the distribution.- Specified by:
nextInt
in classAbstractDiscreteDistribution
-
nextInt
public int nextInt(int N, int s, int n)
Returns a random number from the distribution; bypasses the internal state.
-
nextInt
protected int nextInt(int N, int M, int n, RandomEngine randomGenerator)
Returns a random number from the distribution; bypasses the internal state.
-
pdf
public double pdf(int k)
Returns the probability distribution function.
-
setState
public void setState(int N, int s, int n)
Sets the parameters.
-
staticNextInt
public static double staticNextInt(int N, int M, int n)
Returns a random number from the distribution.
-
toString
public java.lang.String toString()
Returns a String representation of the receiver.- Overrides:
toString
in classjava.lang.Object
-
xstaticSetRandomGenerator
private static void xstaticSetRandomGenerator(RandomEngine randomGenerator)
Sets the uniform random number generated shared by all static methods.- Parameters:
randomGenerator
- the new uniform random number generator to be shared.
-
-