## Types in MathNet.Numerics.Distributions

Type NormalGamma

Namespace MathNet.Numerics.Distributions

Interfaces IDistribution

Multivariate Normal-Gamma Distribution.

The NormalGamma distribution is the conjugate prior distribution for the Normal distribution. It specifies a prior over the mean and precision of the Normal distribution.

It is parameterized by four numbers: the mean location, the mean scale, the precision shape and the precision inverse scale.

The distribution NG(mu, tau | mloc,mscale,psscale,pinvscale) = Normal(mu | mloc, 1/(mscale*tau)) * Gamma(tau | psscale,pinvscale).

The following degenerate cases are special: when the precision is known, the precision shape will encode the value of the precision while the precision inverse scale is positive infinity. When the mean is known, the mean location will encode the value of the mean while the scale will be positive infinity. A completely degenerate NormalGamma distribution with known mean and precision is possible as well.

.

### Public Constructors

#### NormalGamma(double meanLocation, double meanScale, double precisionShape, double precisionInverseScale, Random randomSource)

Initializes a new instance of the NormalGamma class.
##### Parameters
###### `double` meanLocation

The location of the mean.

###### `double` meanScale

The scale of the mean.

###### `double` precisionShape

The shape of the precision.

###### `double` precisionInverseScale

The inverse scale of the precision.

###### `Random` randomSource

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

#### NormalGamma(double meanLocation, double meanScale, double precisionShape, double precisionInverseScale)

Initializes a new instance of the NormalGamma class.
##### Parameters
###### `double` meanLocation

The location of the mean.

###### `double` meanScale

The scale of the mean.

###### `double` precisionShape

The shape of the precision.

###### `double` precisionInverseScale

The inverse scale of the precision.

### Public Static Functions

#### boolIsValidParameterSet(double meanLocation, double meanScale, double precShape, double precInvScale)

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

The location of the mean.

###### `double` meanScale

The scale of the mean.

###### `double` precShape

The shape of the precision.

###### `double` precInvScale

The inverse scale of the precision.

#### MeanPrecisionPairSample(Random rnd, double meanLocation, double meanScale, double precisionShape, double precisionInverseScale)

Generates a sample from the `NormalGamma` distribution.
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `double` meanLocation

The location of the mean.

###### `double` meanScale

The scale of the mean.

###### `double` precisionShape

The shape of the precision.

###### `double` precisionInverseScale

The inverse scale of the precision.

##### Return
###### `MeanPrecisionPair`

a sample from the distribution.

#### IEnumerable<MeanPrecisionPair>Samples(Random rnd, double meanLocation, double meanScale, double precisionShape, double precisionInvScale)

Generates a sequence of samples from the NormalGamma distribution
##### Parameters
###### `Random` rnd

The random number generator to use.

###### `double` meanLocation

The location of the mean.

###### `double` meanScale

The scale of the mean.

###### `double` precisionShape

The shape of the precision.

###### `double` precisionInvScale

The inverse scale of the precision.

##### Return
###### `IEnumerable<MeanPrecisionPair>`

a sequence of samples from the distribution.

### Public Methods

#### doubleDensity(MeanPrecisionPair mp)

Evaluates the probability density function for a NormalGamma distribution.
##### Parameters
###### `MeanPrecisionPair` mp

The mean/precision pair of the distribution

Density value

#### doubleDensity(double mean, double prec)

Evaluates the probability density function for a NormalGamma distribution.
##### Parameters
###### `double` mean

The mean of the distribution

###### `double` prec

The precision of the distribution

Density value

#### doubleDensityLn(MeanPrecisionPair mp)

Evaluates the log probability density function for a NormalGamma distribution.
##### Parameters
###### `MeanPrecisionPair` mp

The mean/precision pair of the distribution

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

The log of the density value

#### doubleDensityLn(double mean, double prec)

Evaluates the log probability density function for a NormalGamma distribution.
##### Parameters
###### `double` mean

The mean of the distribution

###### `double` prec

The precision of the distribution

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

The log of the density value

#### StudentTMeanMarginal()

Returns the marginal distribution for the mean of the `NormalGamma` distribution.
##### Return
###### `StudentT`

the marginal distribution for the mean of the `NormalGamma` distribution.

#### GammaPrecisionMarginal()

Returns the marginal distribution for the precision of the NormalGamma distribution.
##### Return
###### `Gamma`

The marginal distribution for the precision of the NormalGamma distribution/

#### MeanPrecisionPairSample()

Generates a sample from the `NormalGamma` distribution.
##### Return
###### `MeanPrecisionPair`

a sample from the distribution.

#### IEnumerable<MeanPrecisionPair>Samples()

Generates a sequence of samples from the `NormalGamma` distribution
##### Return
###### `IEnumerable<MeanPrecisionPair>`

a sequence of samples from the distribution.

#### stringToString()

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

a string representation of the distribution.

### Public Properties

#### MeanPrecisionPairMean get;

Gets the mean of the distribution.
Value:

#### doubleMeanLocation get;

Gets the location of the mean.

#### doubleMeanScale get;

Gets the scale of the mean.

#### doublePrecisionInverseScale get;

Gets the inverse scale of the precision.

#### doublePrecisionShape get;

Gets the shape of the precision.

#### RandomRandomSource get; set;

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

#### MeanPrecisionPairVariance get;

Gets the variance of the distribution.
Value: