NegativeBinomialDistribution<T>

Models & Types · AiDotNet.Distributions

Represents a Negative Binomial probability distribution.

Inheritance: DistributionBase<T> → NegativeBinomialDistribution<T>

For Beginners

Use Negative Binomial instead of Poisson when your count data has variance larger than its mean (overdispersion). This is common in real-world data:

  • Number of accidents (some people are accident-prone)
  • Disease counts (clustering in certain areas)
  • Customer purchases (some customers buy much more)

The extra parameter r controls the degree of overdispersion.

How It Works

The Negative Binomial distribution models the number of failures before r successes occur, or equivalently, overdispersed count data where variance exceeds the mean. It generalizes the Poisson distribution to handle overdispersion.

PMF: P(X = k) = C(k+r-1, k) * p^r * (1-p)^k Alternative parametrization with mean μ and dispersion r: P(X = k) = C(k+r-1, k) * (r/(r+μ))^r * (μ/(r+μ))^k

Constructors

Constructor Summary
NegativeBinomialDistribution(T r, T prob) Initializes a new Negative Binomial distribution.

Properties

Property Summary
T Mean { get; }
T Probability { get; } Gets the success probability.
T R { get; } Gets the dispersion parameter (r).
T Variance { get; }
Vector<T> Parameters { get; set; }
int NumParameters { get; }
string[] ParameterNames { get; }

Methods

Method Summary
Matrix<T> FisherInformation()
NegativeBinomialDistribution<T> FromMeanDispersion(T mean, T dispersion) Creates a Negative Binomial distribution from mean and dispersion.
NegativeBinomialDistribution<T> FromMeanVariance(T mean, T variance) Creates a Negative Binomial distribution from mean and variance.
T Cdf(T x)
T InverseCdf(T pQuantile)
T LogPdf(T x)
T LogPmf(int k) Computes the log probability mass function at integer k.
T Pdf(T x)
T Pmf(int k) Computes the probability mass function (PMF) at integer k.
T Sample(Random random)
Vector<T> GradLogPdf(T x)