Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sim.util.distribution
Class NegativeBinomial

    java.lang.Object
      sim.util.distribution.AbstractDistribution
          sim.util.distribution.AbstractDiscreteDistribution
              sim.util.distribution.NegativeBinomial

All Implemented Interfaces:
  java.io.Serializable

    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.

See Also:
  Serialized Form

Field Summary
`protected Gamma` | `gamma`
`protected int` | `n`
`protected double` | `p`
`protected Poisson` | `poisson`

Fields inherited from class sim.util.distribution.AbstractDistribution
`randomGenerator`

Constructor Summary
`NegativeBinomial(int n, double p, MersenneTwisterFast randomGenerator)` Constructs a Negative Binomial distribution.

Method Summary
`double` | `cdf(int k)` Returns the cumulative distribution function.
`int` | `nextInt()` Returns a random number from the distribution.
`int` | `nextInt(int n, double p)` Returns a random number from the distribution; bypasses the internal state.
`double` | `pdf(int k)` Returns the probability distribution function.
`void` | `setNandP(int n, double p)` Sets the parameters number of trials and the probability of success.
`java.lang.String` | `toString()` Returns a String representation of the receiver.

Methods inherited from class sim.util.distribution.AbstractDiscreteDistribution
`nextDouble`

Methods inherited from class sim.util.distribution.AbstractDistribution
`apply, apply, getRandomGenerator, setRandomGenerator`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### n

    protected int n

### p

    protected double p

### gamma

    protected Gamma gamma

### poisson

    protected Poisson poisson

Constructor Detail

### NegativeBinomial

    public NegativeBinomial(int n,
                            double p,
                            MersenneTwisterFast 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.

### nextInt

    public int nextInt()

  Returns a random number from the distribution.

  Specified by:
    `nextInt` in class `AbstractDiscreteDistribution`

### 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 trials
    `p` - the probability of success.

### toString

    public java.lang.String toString()

  Returns a String representation of the receiver.

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD