## Types in MathNet.Numerics.Distributions

Type NegativeBinomial

Namespace MathNet.Numerics.Distributions

Interfaces IDiscreteDistribution

Discrete Univariate Negative Binomial distribution. The negative binomial is a distribution over the natural numbers with two parameters r, p. For the special case that r is an integer one can interpret the distribution as the number of failures before the r'th success when the probability of success is p..

### Public Constructors

#### NegativeBinomial(double r, double p, Random randomSource)

Initializes a new instance of the NegativeBinomial class.
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

###### `Random` randomSource

The random number generator which is used to draw random samples.

#### NegativeBinomial(double r, double p)

Initializes a new instance of the NegativeBinomial class.
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

### Public Static Functions

#### doubleCDF(double r, double p, double x)

Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x).
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

###### `double` x

The location at which to compute the cumulative distribution function.

##### Return
###### `double`

the cumulative distribution at location x.

#### boolIsValidParameterSet(double r, double p)

Tests whether the provided values are valid parameters for this distribution.
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

#### doublePMF(double r, double p, int k)

Computes the probability mass (PMF) at k, i.e. P(X = k).
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

###### `int` k

The location in the domain where we want to evaluate the probability mass function.

##### Return
###### `double`

the probability mass at location k.

#### doublePMFLn(double r, double p, int k)

Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

###### `int` k

The location in the domain where we want to evaluate the log probability mass function.

##### Return
###### `double`

the log probability mass at location k.

#### intSample(Random rnd, double r, double p)

Samples a random variable.
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

#### intSample(double r, double p)

Samples a random variable.
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

#### voidSamples(Int32[] values, double r, double p)

Fills an array with samples generated from the distribution.
##### Parameters
###### `Int32[]` values

The array to fill with the samples.

###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

#### voidSamples(Random rnd, Int32[] values, double r, double p)

Fills an array with samples generated from the distribution.
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `Int32[]` values

The array to fill with the samples.

###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

#### IEnumerable<int>Samples(Random rnd, double r, double p)

Samples a sequence of this random variable.
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

#### IEnumerable<int>Samples(double r, double p)

Samples a sequence of this random variable.
##### Parameters
###### `double` r

The number of successes (r) required to stop the experiment. Range: r ≥ 0.

###### `double` p

The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.

### Public Methods

#### doubleCumulativeDistribution(double x)

Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x).
##### Parameters
###### `double` x

The location at which to compute the cumulative distribution function.

##### Return
###### `double`

the cumulative distribution at location x.

#### doubleProbability(int k)

Computes the probability mass (PMF) at k, i.e. P(X = k).
##### Parameters
###### `int` k

The location in the domain where we want to evaluate the probability mass function.

##### Return
###### `double`

the probability mass at location k.

#### doubleProbabilityLn(int k)

Computes the log probability mass (lnPMF) at k, i.e. ln(P(X = k)).
##### Parameters
###### `int` k

The location in the domain where we want to evaluate the log probability mass function.

##### Return
###### `double`

the log probability mass at location k.

#### intSample()

Samples a `NegativeBinomial` distributed random variable.
##### Return
###### `int`

a sample from the distribution.

#### IEnumerable<int>Samples()

Samples an array of `NegativeBinomial` distributed random variables.
##### Return
###### `IEnumerable<int>`

a sequence of samples from the distribution.

#### voidSamples(Int32[] values)

Fills an array with samples generated from the distribution.

#### stringToString()

Returns a String that represents this instance.
##### Return
###### `string`

A String that represents this instance.

### Public Properties

#### doubleEntropy get;

Gets the entropy of the distribution.

#### intMaximum get;

Gets the largest element in the domain of the distributions which can be represented by an integer.

#### doubleMean get;

Gets the mean of the distribution.

#### doubleMedian get;

Gets the median of the distribution.

#### intMinimum get;

Gets the smallest element in the domain of the distributions which can be represented by an integer.

#### intMode get;

Gets the mode of the distribution

#### doubleP get;

Gets the probability of success. Range: 0 ≤ p ≤ 1.

#### doubleR get;

Gets the number of successes. Range: r ≥ 0.

#### RandomRandomSource get; set;

Gets or sets the random number generator which is used to draw random samples.

#### doubleSkewness get;

Gets the skewness of the distribution.

#### doubleStdDev get;

Gets the standard deviation of the distribution.

#### doubleVariance get;

Gets the variance of the distribution.