Package sim.util.distribution
Class HyperGeometric
java.lang.Object
sim.util.distribution.AbstractDistribution
sim.util.distribution.AbstractDiscreteDistribution
sim.util.distribution.HyperGeometric
- All Implemented Interfaces:
Serializable
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.
Static methods operate on a default uniform random number generator; they are synchronized.
This is a port of hprsc.c from the C-RAND / WIN-RAND library.
C-RAND's implementation, in turn, is based upon
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 invalid input: '<'= N.
Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
Implementation: High performance implementation. Patchwork Rejection/Inversion method.
H. Zechner (1994): Efficient sampling from continuous and discrete unimodal distributions, Doctoral Dissertation, 156 pp., Technical University Graz, Austria.
- See Also:
-
Field Summary
FieldsFields inherited from class sim.util.distribution.AbstractDistribution
randomGenerator -
Constructor Summary
ConstructorsConstructorDescriptionHyperGeometric(int N, int s, int n, MersenneTwisterFast randomGenerator) Constructs a HyperGeometric distribution. -
Method Summary
Modifier and TypeMethodDescriptionprotected inthmdu(int N, int M, int n, MersenneTwisterFast randomGenerator) Returns a random number from the distribution.protected inthprs(int N, int M, int n, MersenneTwisterFast randomGenerator) Returns a random number from the distribution.intnextInt()Returns a random number from the distribution.intnextInt(int N, int s, int n) Returns a random number from the distribution; bypasses the internal state.protected intnextInt(int N, int M, int n, MersenneTwisterFast randomGenerator) Returns a random number from the distribution; bypasses the internal state.doublepdf(int k) Returns the probability distribution function.voidsetState(int N, int s, int n) Sets the parameters.toString()Returns a String representation of the receiver.Methods inherited from class sim.util.distribution.AbstractDiscreteDistribution
nextDoubleMethods inherited from class sim.util.distribution.AbstractDistribution
apply, apply, getRandomGenerator, setRandomGenerator
-
Field Details
-
my_N
protected int my_N -
my_s
protected int my_s -
my_n
protected int my_n
-
-
Constructor Details
-
HyperGeometric
Constructs a HyperGeometric distribution.
-
-
Method Details
-
hmdu
Returns a random number from the distribution. -
hprs
Returns a random number from the distribution. -
nextInt
public int nextInt()Returns a random number from the distribution.- Specified by:
nextIntin classAbstractDiscreteDistribution
-
nextInt
public int nextInt(int N, int s, int n) Returns a random number from the distribution; bypasses the internal state. -
nextInt
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. -
toString
Returns a String representation of the receiver.
-