public class HyperGeometric extends AbstractDiscreteDistribution
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.
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.
Modifier and Type | Field and Description |
---|---|
protected int |
my_n |
protected int |
my_N |
protected int |
my_s |
protected static HyperGeometric |
shared |
randomGenerator
serialVersionUID
Constructor and Description |
---|
HyperGeometric(int N,
int s,
int n,
RandomEngine randomGenerator)
Constructs a HyperGeometric distribution.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
toString()
Returns a String representation of the receiver.
|
nextDouble
apply, apply, clone, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
protected int my_N
protected int my_s
protected int my_n
protected static HyperGeometric shared
public HyperGeometric(int N, int s, int n, RandomEngine randomGenerator)
protected int hmdu(int N, int M, int n, RandomEngine randomGenerator)
protected int hprs(int N, int M, int n, RandomEngine randomGenerator)
public int nextInt()
nextInt
in class AbstractDiscreteDistribution
public int nextInt(int N, int s, int n)
protected int nextInt(int N, int M, int n, RandomEngine randomGenerator)
public double pdf(int k)
public void setState(int N, int s, int n)
public static double staticNextInt(int N, int M, int n)
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.