NegativeBinomialDistribution Class 
Namespace: Accord.Statistics.Distributions.Univariate
[SerializableAttribute] public class NegativeBinomialDistribution : UnivariateDiscreteDistribution
The NegativeBinomialDistribution type exposes the following members.
Name  Description  

NegativeBinomialDistribution 
Creates a new Negative Binomial distribution.

Name  Description  

Entropy 
Gets the entropy for this distribution.
(Overrides UnivariateDiscreteDistributionEntropy.)  
Mean 
Gets the mean for this distribution.
(Overrides UnivariateDiscreteDistributionMean.)  
Median 
Gets the median for this distribution.
(Inherited from UnivariateDiscreteDistribution.)  
Mode 
Gets the mode for this distribution.
(Inherited from UnivariateDiscreteDistribution.)  
Quartiles 
Gets the Quartiles for this distribution.
(Inherited from UnivariateDiscreteDistribution.)  
StandardDeviation 
Gets the Standard Deviation (the square root of
the variance) for the current distribution.
(Inherited from UnivariateDiscreteDistribution.)  
Support 
Gets the support interval for this distribution.
(Overrides UnivariateDiscreteDistributionSupport.)  
Variance 
Gets the variance for this distribution.
(Overrides UnivariateDiscreteDistributionVariance.) 
Name  Description  

BaseInverseDistributionFunction 
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p using a numerical
approximation based on binary search.
(Inherited from UnivariateDiscreteDistribution.)  
Clone 
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)  
ComplementaryDistributionFunction(Int32) 
Gets P(X > k) the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.)  
ComplementaryDistributionFunction(Int32, Boolean) 
Gets the complementary cumulative distribution function
(ccdf) for this distribution evaluated at point k.
This function is also known as the Survival function.
(Inherited from UnivariateDiscreteDistribution.)  
CumulativeHazardFunction 
Gets the cumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)  
DistributionFunction(Int32) 
Gets P( X<= k), the cumulative distribution function
(cdf) for this distribution evaluated at point k.
(Overrides UnivariateDiscreteDistributionDistributionFunction(Int32).)  
DistributionFunction(Int32, Boolean) 
Gets P(X ≤ k) or P(X < k), the cumulative distribution function
(cdf) for this distribution evaluated at point k, depending
on the value of the inclusive parameter.
(Inherited from UnivariateDiscreteDistribution.)  
DistributionFunction(Int32, Int32) 
Gets the cumulative distribution function (cdf) for this
distribution in the semiclosed interval (a; b] given as
P(a < X ≤ b).
(Inherited from UnivariateDiscreteDistribution.)  
Equals  Determines whether the specified object is equal to the current object. (Inherited from Object.)  
Finalize  Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)  
Fit(Double) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Int32) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Double, Double) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Double, Int32) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Int32, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Double, Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Overrides UnivariateDiscreteDistributionFit(Double, Double, IFittingOptions).)  
Fit(Double, Int32, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Int32, Double, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Fit(Int32, Int32, IFittingOptions) 
Fits the underlying distribution to a given set of observations.
(Inherited from UnivariateDiscreteDistribution.)  
Generate 
Generates a random observation from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)  
Generate(Int32) 
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)  
Generate(Int32, Double) 
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)  
Generate(Int32, Int32) 
Generates a random vector of observations from the current distribution.
(Inherited from UnivariateDiscreteDistribution.)  
GetHashCode  Serves as the default hash function. (Inherited from Object.)  
GetRange 
Gets the distribution range within a given percentile.
(Inherited from UnivariateDiscreteDistribution.)  
GetType  Gets the Type of the current instance. (Inherited from Object.)  
HazardFunction 
Gets the hazard function, also known as the failure rate or
the conditional failure density function for this distribution
evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)  
InverseDistributionFunction 
Gets the inverse of the cumulative distribution function (icdf) for
this distribution evaluated at probability p. This function
is also known as the Quantile function.
(Inherited from UnivariateDiscreteDistribution.)  
LogCumulativeHazardFunction 
Gets the logcumulative hazard function for this
distribution evaluated at point x.
(Inherited from UnivariateDiscreteDistribution.)  
LogProbabilityMassFunction 
Gets the logprobability mass function (pmf) for
this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionLogProbabilityMassFunction(Int32).)  
MemberwiseClone  Creates a shallow copy of the current Object. (Inherited from Object.)  
ProbabilityMassFunction 
Gets the probability mass function (pmf) for
this distribution evaluated at point x.
(Overrides UnivariateDiscreteDistributionProbabilityMassFunction(Int32).)  
QuantileDensityFunction 
Gets the first derivative of the
inverse distribution function (icdf) for this distribution evaluated
at probability p.
(Inherited from UnivariateDiscreteDistribution.)  
ToString 
Returns a String that represents this instance.
(Inherited from DistributionBase.)  
ToString(IFormatProvider) 
Returns a String that represents this instance.
(Inherited from DistributionBase.)  
ToString(String) 
Returns a String that represents this instance.
(Inherited from DistributionBase.)  
ToString(String, IFormatProvider) 
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).) 
Name  Description  

HasMethod 
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by Matrix.) 
The negative binomial distribution is a discrete probability distribution of the number of successes in a sequence of Bernoulli trials before a specified (nonrandom) number of failures (denoted r) occur. For example, if one throws a die repeatedly until the third time “1” appears, then the probability distribution of the number of non“1”s that had appeared will be negative binomial.
References:
// Create a new Negative Binomial distribution with r = 7 and p = 0.42 var dist = new NegativeBinomialDistribution(failures: 7, probability: 0.42); // Common measures double mean = dist.Mean; // 5.068965517241379 double median = dist.Median; // 5.0 double var = dist.Variance; // 8.7395957193816862 // Cumulative distribution functions double cdf = dist.DistributionFunction(k: 2); // 0.19605133020527743 double ccdf = dist.ComplementaryDistributionFunction(k: 2); // 0.80394866979472257 // Probability mass functions double pmf1 = dist.ProbabilityMassFunction(k: 4); // 0.054786846293416853 double pmf2 = dist.ProbabilityMassFunction(k: 5); // 0.069908015870399909 double pmf3 = dist.ProbabilityMassFunction(k: 6); // 0.0810932984096639 double lpmf = dist.LogProbabilityMassFunction(k: 2); // 2.3927801721315989 // Quantile function int icdf1 = dist.InverseDistributionFunction(p: 0.17); // 2 int icdf2 = dist.InverseDistributionFunction(p: 0.46); // 4 int icdf3 = dist.InverseDistributionFunction(p: 0.87); // 8 // Hazard (failure rate) functions double hf = dist.HazardFunction(x: 4); // 0.10490438293398294 double chf = dist.CumulativeHazardFunction(x: 4); // 0.64959916255036043 // String representation string str = dist.ToString(CultureInfo.InvariantCulture); // "NegativeBinomial(x; r = 7, p = 0.42)"