Parallel Colt 0.7.2

cern.jet.random.tdouble
Class HyperGeometric

java.lang.Object
  extended by cern.colt.PersistentObject
      extended by cern.jet.random.tdouble.AbstractDoubleDistribution
          extended by cern.jet.random.tdouble.AbstractDiscreteDistribution
              extended by cern.jet.random.tdouble.HyperGeometric
All Implemented Interfaces:
DoubleFunction, IntFunction, Serializable, 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
Author:
wolfgang.hoschek@cern.ch
See Also:
Serialized Form

Field Summary
 
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
 
Constructor Summary
HyperGeometric(int N, int s, int n, DoubleRandomEngine randomGenerator)
          Constructs a HyperGeometric distribution.
 
Method Summary
 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.
 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.
 
Methods inherited from class cern.jet.random.tdouble.AbstractDiscreteDistribution
nextDouble
 
Methods inherited from class cern.jet.random.tdouble.AbstractDoubleDistribution
apply, apply, clone, makeDefaultGenerator
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HyperGeometric

public HyperGeometric(int N,
                      int s,
                      int n,
                      DoubleRandomEngine randomGenerator)
Constructs a HyperGeometric distribution.

Method Detail

nextInt

public int nextInt()
Returns a random number from the distribution.

Specified by:
nextInt in class AbstractDiscreteDistribution

nextInt

public int nextInt(int N,
                   int s,
                   int n)
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 String toString()
Returns a String representation of the receiver.

Overrides:
toString in class Object

Parallel Colt 0.7.2

Jump to the Parallel Colt Homepage