## Types in MathNet.Numerics.Distributions

Type Categorical

Namespace MathNet.Numerics.Distributions

Interfaces IDiscreteDistribution

Discrete Univariate Categorical distribution. For details about this distribution, see. This distribution is sometimes called the Discrete distribution.
The distribution is parameterized by a vector of ratios: in other words, the parameter does not have to be normalized and sum to 1. The reason is that some vectors can't be exactly normalized to sum to 1 in floating point representation.

### Public Constructors

#### Categorical(Histogram histogram)

Initializes a new instance of the Categorical class from a histogram. The distribution will not be automatically updated when the histogram changes. The categorical distribution will have one value for each bucket and a probability for that value proportional to the bucket count.
##### Parameters
###### `Histogram` histogram

The histogram from which to create the categorical variable.

#### Categorical(Double[] probabilityMass, Random randomSource)

Initializes a new instance of the Categorical class.
##### Parameters
###### `Double[]` probabilityMass

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

###### `Random` randomSource

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

#### Categorical(Double[] probabilityMass)

Initializes a new instance of the Categorical class.
##### Parameters
###### `Double[]` probabilityMass

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

### Public Static Functions

#### doubleCDF(Double[] probabilityMass, double x)

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

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

###### `double` x

The location at which to compute the cumulative distribution function.

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

the cumulative distribution at location x.

#### intInvCDF(Double[] probabilityMass, double probability)

Computes the inverse of the cumulative distribution function (InvCDF) for the distribution at the given probability.
##### Parameters
###### `Double[]` probabilityMass

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

###### `double` probability

A real number between 0 and 1.

##### Return
###### `int`

An integer between 0 and the size of the categorical (exclusive), that corresponds to the inverse CDF for the given probability.

#### intInvCDFWithCumulativeDistribution(Double[] cdfUnnormalized, double probability)

Computes the inverse of the cumulative distribution function (InvCDF) for the distribution at the given probability.
##### Parameters
###### `Double[]` cdfUnnormalized

An array corresponding to a CDF for a categorical distribution. Not assumed to be normalized.

###### `double` probability

A real number between 0 and 1.

##### Return
###### `int`

An integer between 0 and the size of the categorical (exclusive), that corresponds to the inverse CDF for the given probability.

#### boolIsValidCumulativeDistribution(Double[] cdf)

Checks whether the parameters of the distribution are valid.
##### Parameters
###### `Double[]` cdf

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

##### Return
###### `bool`

If any of the probabilities are negative returns `false` , or if the sum of parameters is 0.0; otherwise `true`

#### boolIsValidProbabilityMass(Double[] p)

Checks whether the parameters of the distribution are valid.
##### Parameters
###### `Double[]` p

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

##### Return
###### `bool`

If any of the probabilities are negative returns `false` , or if the sum of parameters is 0.0; otherwise `true`

#### doublePMF(Double[] probabilityMass, int k)

Computes the probability mass (PMF) at k, i.e. P(X = k).
##### Parameters
###### `Double[]` probabilityMass

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

###### `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[] probabilityMass, int k)

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

An array of nonnegative ratios: this array does not need to be normalized as this is often impossible using floating point arithmetic.

###### `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(Double[] probabilityMass)

Samples one categorical distributed random variable; also known as the Discrete distribution.
##### Parameters
###### `Double[]` probabilityMass

An array of nonnegative ratios. Not assumed to be normalized.

##### Return
###### `int`

One random integer between 0 and the size of the categorical (exclusive).

#### intSample(Random rnd, Double[] probabilityMass)

Samples one categorical distributed random variable; also known as the Discrete distribution.
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `Double[]` probabilityMass

An array of nonnegative ratios. Not assumed to be normalized.

##### Return
###### `int`

One random integer between 0 and the size of the categorical (exclusive).

#### IEnumerable<int>Samples(Random rnd, Double[] probabilityMass)

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

The random number generator to use.

###### `Double[]` probabilityMass

An array of nonnegative ratios. Not assumed to be normalized.

##### Return
###### `IEnumerable<int>`

random integers between 0 and the size of the categorical (exclusive).

#### IEnumerable<int>Samples(Double[] probabilityMass)

Samples a categorically distributed random variable.
##### Parameters
###### `Double[]` probabilityMass

An array of nonnegative ratios. Not assumed to be normalized.

##### Return
###### `IEnumerable<int>`

random integers between 0 and the size of the categorical (exclusive).

#### voidSamples(Random rnd, Int32[] values, Double[] probabilityMass)

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[]` probabilityMass

An array of nonnegative ratios. Not assumed to be normalized.

##### Return
###### `void`

random integers between 0 and the size of the categorical (exclusive).

#### voidSamples(Int32[] values, Double[] probabilityMass)

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

The array to fill with the samples.

###### `Double[]` probabilityMass

An array of nonnegative ratios. Not assumed to be normalized.

##### Return
###### `void`

random integers between 0 and the size of the categorical (exclusive).

#### IEnumerable<int>SamplesWithCumulativeDistribution(Random rnd, Double[] cdfUnnormalized)

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

The random number generator to use.

###### `Double[]` cdfUnnormalized

An array of the cumulative distribution. Not assumed to be normalized.

##### Return
###### `IEnumerable<int>`

random integers between 0 and the size of the categorical (exclusive).

#### voidSamplesWithCumulativeDistribution(Random rnd, Int32[] values, Double[] cdfUnnormalized)

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[]` cdfUnnormalized

An array of the cumulative distribution. Not assumed to be normalized.

##### Return
###### `void`

random integers between 0 and the size of the categorical (exclusive).

#### IEnumerable<int>SamplesWithCumulativeDistribution(Double[] cdfUnnormalized)

Samples a categorically distributed random variable.
##### Parameters
###### `Double[]` cdfUnnormalized

An array of the cumulative distribution. Not assumed to be normalized.

##### Return
###### `IEnumerable<int>`

random integers between 0 and the size of the categorical (exclusive).

#### voidSamplesWithCumulativeDistribution(Int32[] values, Double[] cdfUnnormalized)

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

The array to fill with the samples.

###### `Double[]` cdfUnnormalized

An array of the cumulative distribution. Not assumed to be normalized.

##### Return
###### `void`

random integers between 0 and the size of the categorical (exclusive).

#### intSampleWithCumulativeDistribution(Random rnd, Double[] cdfUnnormalized)

Samples one categorical distributed random variable; also known as the Discrete distribution.
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `Double[]` cdfUnnormalized

An array of the cumulative distribution. Not assumed to be normalized.

##### Return
###### `int`

One random integer between 0 and the size of the categorical (exclusive).

#### intSampleWithCumulativeDistribution(Double[] cdfUnnormalized)

Samples one categorical distributed random variable; also known as the Discrete distribution.
##### Parameters
###### `Double[]` cdfUnnormalized

An array of the cumulative distribution. Not assumed to be normalized.

##### Return
###### `int`

One random integer between 0 and the size of the categorical (exclusive).

### 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.

#### intInverseCumulativeDistribution(double probability)

Computes the inverse of the cumulative distribution function (InvCDF) for the distribution at the given probability.
##### Parameters
###### `double` probability

A real number between 0 and 1.

##### Return
###### `int`

An integer between 0 and the size of the categorical (exclusive), that corresponds to the inverse CDF for the given probability.

#### 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 Binomially distributed random variable.
##### Return
###### `int`

The number of successful trials.

#### IEnumerable<int>Samples()

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

a sequence of successful trial counts.

#### voidSamples(Int32[] values)

Fills an array with samples generated from the distribution.

#### stringToString()

A string representation of the distribution.
##### Return
###### `string`

a string representation of the distribution.

### 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 he mode of the distribution.
Throws a NotSupportedException.

#### Double[]P get;

Gets the probability mass vector (non-negative ratios) of the multinomial.
Sometimes the normalized probability vector cannot be represented exactly in a floating point representation.

#### 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.
Throws a NotSupportedException.

#### doubleStdDev get;

Gets the standard deviation of the distribution.

#### doubleVariance get;

Gets the variance of the distribution.