Package cern.jet.random
Class NegativeBinomial
- java.lang.Object
-
- cern.colt.PersistentObject
-
- cern.jet.random.AbstractDistribution
-
- cern.jet.random.AbstractDiscreteDistribution
-
- cern.jet.random.NegativeBinomial
-
- All Implemented Interfaces:
DoubleFunction,IntFunction,java.io.Serializable,java.lang.Cloneable
public class NegativeBinomial extends AbstractDiscreteDistribution
Negative Binomial distribution; See the math definition.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. Compound method.
- This is a port of nbp.c from the C-RAND / WIN-RAND library. C-RAND's implementation, in turn, is based upon
J.H. Ahrens, U. Dieter (1974): Computer methods for sampling from gamma, beta, Poisson and binomial distributions, Computing 12, 223--246.
- Version:
- 1.0, 09/24/99
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Gammagammaprotected intnprotected doublepprotected Poissonpoissonprotected static NegativeBinomialshared-
Fields inherited from class cern.jet.random.AbstractDistribution
randomGenerator
-
Fields inherited from class cern.colt.PersistentObject
serialVersionUID
-
-
Constructor Summary
Constructors Constructor Description NegativeBinomial(int n, double p, RandomEngine randomGenerator)Constructs a Negative Binomial distribution.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(int k)Returns the cumulative distribution function.java.lang.Objectclone()Returns a deep copy of the receiver; the copy will produce identical sequences.intnextInt()Returns a random number from the distribution.intnextInt(int n, double p)Returns a random number from the distribution; bypasses the internal state.doublepdf(int k)Returns the probability distribution function.voidsetNandP(int n, double p)Sets the parameters number of trials and the probability of success.static intstaticNextInt(int n, double p)Returns a random number from the distribution with the given parameters n and p.java.lang.StringtoString()Returns a String representation of the receiver.private static voidxstaticSetRandomGenerator(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, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
-
-
-
-
Field Detail
-
n
protected int n
-
p
protected double p
-
gamma
protected Gamma gamma
-
poisson
protected Poisson poisson
-
shared
protected static NegativeBinomial shared
-
-
Constructor Detail
-
NegativeBinomial
public NegativeBinomial(int n, double p, RandomEngine randomGenerator)Constructs a Negative Binomial distribution. Example: n=1, p=0.5.- Parameters:
n- the number of trials.p- the probability of success.randomGenerator- a uniform random number generator.
-
-
Method Detail
-
cdf
public double cdf(int k)
Returns the cumulative distribution function.
-
clone
public java.lang.Object clone()
Returns a deep copy of the receiver; the copy will produce identical sequences. After this call has returned, the copy and the receiver have equal but separate state.- Overrides:
clonein classAbstractDistribution- Returns:
- a copy of the receiver.
-
nextInt
public int nextInt()
Returns a random number from the distribution.- Specified by:
nextIntin classAbstractDiscreteDistribution
-
nextInt
public int nextInt(int n, double p)Returns a random number from the distribution; bypasses the internal state.
-
pdf
public double pdf(int k)
Returns the probability distribution function.
-
setNandP
public void setNandP(int n, double p)Sets the parameters number of trials and the probability of success.- Parameters:
n- the number of trialsp- the probability of success.
-
staticNextInt
public static int staticNextInt(int n, double p)Returns a random number from the distribution with the given parameters n and p.- Parameters:
n- the number of trialsp- the probability of success.
-
toString
public java.lang.String toString()
Returns a String representation of the receiver.- Overrides:
toStringin 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.
-
-