SSJ
V. 1.1.9.

umontreal.iro.lecuyer.probdist
Class NegativeBinomialDist

java.lang.Object
  extended by umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
      extended by umontreal.iro.lecuyer.probdist.NegativeBinomialDist

public class NegativeBinomialDist
extends DiscreteDistributionInt

Extends the class DiscreteDistributionInt for the negative binomial distribution with parameters n and p, where n is a positive integer and 0 <= p <= 1. Its mass function is

p(x) = nCr(n + x - 1, x)pn(1 - p)x,        for x = 0, 1, 2,…

where nCr is defined in BinomialDist. This p(x) can be interpreted as the probability of having x failures before the nth success in a sequence of independent Bernoulli trials with probability of success p. For n = 1, this gives the geometric distribution.


Field Summary
static double MAXN
           
 
Fields inherited from class umontreal.iro.lecuyer.probdist.DiscreteDistributionInt
EPSILON
 
Constructor Summary
NegativeBinomialDist(int n, double p)
          Creates an object that contains the probability terms and the distribution function for the negative binomial distribution with parameter n and p.
 
Method Summary
 double barF(int x)
          Returns bar(F)(x), the complementary distribution function.
 double cdf(int x)
          Returns the distribution function F evaluated at x (see).
static double cdf(int n, double p, int x)
          Computes the distribution function.
 int getN()
          Returns the parameter n of this object.
 double getP()
          Returns the parameter p of this object.
 int inverseF(double u)
          Returns the inverse distribution function F-1(u), where 0 <= u <= 1.
static int inverseF(int n, double p, double u)
          Computes the inverse function without precomputing tables.
 double prob(int x)
          Returns p(x), the probability of x, which should be a real number in the interval [0, 1].
static double prob(int n, double p, int x)
          Computes the probability mass function.
 void setParams(int n, double p)
          Sets the parameter n and p of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXN

public static double MAXN
Constructor Detail

NegativeBinomialDist

public NegativeBinomialDist(int n,
                            double p)
Creates an object that contains the probability terms and the distribution function for the negative binomial distribution with parameter n and p.

Method Detail

prob

public double prob(int x)
Description copied from class: DiscreteDistributionInt
Returns p(x), the probability of x, which should be a real number in the interval [0, 1].

Specified by:
prob in class DiscreteDistributionInt
Parameters:
x - value at which the mass function must be evaluated
Returns:
the mass function evaluated at x

cdf

public double cdf(int x)
Description copied from class: DiscreteDistributionInt
Returns the distribution function F evaluated at x (see).

Specified by:
cdf in class DiscreteDistributionInt
Parameters:
x - value at which the distribution function must be evaluated
Returns:
the distribution function evaluated at x

barF

public double barF(int x)
Description copied from class: DiscreteDistributionInt
Returns bar(F)(x), the complementary distribution function.

Overrides:
barF in class DiscreteDistributionInt
Parameters:
x - value at which the complementary distribution function must be evaluated
Returns:
the complementary distribution function evaluated at x

inverseF

public int inverseF(double u)
Description copied from class: DiscreteDistributionInt
Returns the inverse distribution function F-1(u), where 0 <= u <= 1. The default implementation uses binary search.

Overrides:
inverseF in class DiscreteDistributionInt
Parameters:
u - value in the interval (0, 1) for which the inverse distribution function is evaluated
Returns:
the inverse distribution function evaluated at u

prob

public static double prob(int n,
                          double p,
                          int x)
Computes the probability mass function.


cdf

public static double cdf(int n,
                         double p,
                         int x)
Computes the distribution function.


inverseF

public static int inverseF(int n,
                           double p,
                           double u)
Computes the inverse function without precomputing tables. This method computes the CDF at the mode (maximum term) and performs a linear search from that point.


getN

public int getN()
Returns the parameter n of this object.


getP

public double getP()
Returns the parameter p of this object.


setParams

public void setParams(int n,
                      double p)
Sets the parameter n and p of this object.


SSJ
V. 1.1.9.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.