Class NegativeBinomialDistribution
- java.lang.Object
-
- smile.stat.distribution.AbstractDistribution
-
- smile.stat.distribution.DiscreteDistribution
-
- smile.stat.distribution.NegativeBinomialDistribution
-
- All Implemented Interfaces:
- Distribution
public class NegativeBinomialDistribution extends DiscreteDistribution
Negative binomial distribution arises as the probability distribution of the number of successes in a series of independent and identically distributed Bernoulli trials needed to get a specified (non-random) number r of failures. If r is an integer, it is usually called Pascal distribution. Otherwise, it is often called Polya distribution for the real-valued case. When r = 1 we get the probability distribution of number of successes before the first failure, which is a geometric distribution.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 Summary
Constructors Constructor and Description NegativeBinomialDistribution(double r, double p)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecdf(double k)Cumulative distribution function.doubleentropy()Shannon entropy.doublelogp(int k)The probability mass function in log scale.doublemean()The mean of distribution.intnpara()The number of parameters of the distribution.doublep(int k)The probability mass function.doublequantile(double p)The quantile, the probability to the left of quantile is p.doublerand()Generates a random number following this distribution.doublesd()The standard deviation of distribution.java.lang.StringtoString()doublevar()The variance of distribution.-
Methods inherited from class smile.stat.distribution.DiscreteDistribution
likelihood, logLikelihood, logp, p
-
Methods inherited from class smile.stat.distribution.AbstractDistribution
likelihood, logLikelihood
-
-
-
-
Constructor Detail
-
NegativeBinomialDistribution
public NegativeBinomialDistribution(double r, double p)Constructor.- Parameters:
r- the number of failures until the experiment is stopped.p- success probability in each experiment.
-
-
Method Detail
-
npara
public int npara()
Description copied from interface:DistributionThe number of parameters of the distribution.
-
mean
public double mean()
Description copied from interface:DistributionThe mean of distribution.
-
var
public double var()
Description copied from interface:DistributionThe variance of distribution.
-
sd
public double sd()
Description copied from interface:DistributionThe standard deviation of distribution.
-
entropy
public double entropy()
Shannon entropy. Not supported.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
rand
public double rand()
Description copied from interface:DistributionGenerates a random number following this distribution.
-
p
public double p(int k)
Description copied from class:DiscreteDistributionThe probability mass function.- Specified by:
pin classDiscreteDistribution
-
logp
public double logp(int k)
Description copied from class:DiscreteDistributionThe probability mass function in log scale.- Specified by:
logpin classDiscreteDistribution
-
cdf
public double cdf(double k)
Description copied from interface:DistributionCumulative distribution function. That is the probability to the left of x.
-
quantile
public double quantile(double p)
Description copied from interface:DistributionThe quantile, the probability to the left of quantile is p. It is actually the inverse of cdf.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG