public class NegativeBinomialDistribution extends DiscreteDistribution
An alternative definition is that X is the total number of trials needed to get r failures, not simply the number of successes. This alternative parameterization can be used as an alternative to the Poisson distribution. It is especially useful for discrete data over an unbounded positive range whose sample variance exceeds the sample mean. If a Poisson distribution is used to model such data, the model mean and variance are equal. In that case, the observations are overdispersed with respect to the Poisson model. Since the negative binomial distribution has one more parameter than the Poisson, the second parameter can be used to adjust the variance independently of the mean. In the case of modest overdispersion, this may produce substantially similar results to an overdispersed Poisson distribution.
The negative binomial distribution also arises as a continuous mixture of Poisson distributions where the mixing distribution of the Poisson rate is a gamma distribution. That is, we can view the negative binomial as a Poisson(λ) distribution, where λ is itself a random variable, distributed according to Γ(r, p/(1 - p)).
| Constructor and Description |
|---|
NegativeBinomialDistribution(double r,
double p)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
cdf(double k)
Cumulative distribution function.
|
double |
entropy()
Shannon entropy.
|
double |
logp(int k)
The probability mass function in log scale.
|
double |
mean()
The mean of distribution.
|
int |
npara()
The number of parameters of the distribution.
|
double |
p(int k)
The probability mass function.
|
double |
quantile(double p)
The quantile, the probability to the left of quantile is p.
|
double |
rand()
Generates a random number following this distribution.
|
double |
sd()
The standard deviation of distribution.
|
java.lang.String |
toString() |
double |
var()
The variance of distribution.
|
likelihood, logLikelihood, logp, p, quantileinverseTransformSampling, likelihood, logLikelihood, quantile, quantile, rejectionpublic NegativeBinomialDistribution(double r,
double p)
r - the number of failures until the experiment is stopped.p - success probability in each experiment.public int npara()
Distributionpublic double mean()
Distributionpublic double var()
Distributionpublic double sd()
Distributionpublic double entropy()
public java.lang.String toString()
toString in class java.lang.Objectpublic double rand()
Distributionpublic double p(int k)
DiscreteDistributionp in class DiscreteDistributionpublic double logp(int k)
DiscreteDistributionlogp in class DiscreteDistributionpublic double cdf(double k)
Distributionpublic double quantile(double p)
Distribution