Click or drag to resize
Accord.NET (logo)

DirichletDistribution Class

Dirichlet distribution.
Inheritance Hierarchy
SystemObject
  Accord.Statistics.DistributionsDistributionBase
    Accord.Statistics.Distributions.MultivariateMultivariateContinuousDistribution
      Accord.Statistics.Distributions.MultivariateDirichletDistribution

Namespace:  Accord.Statistics.Distributions.Multivariate
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class DirichletDistribution : MultivariateContinuousDistribution
Request Example View Source

The DirichletDistribution type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCovariance
Gets the variance-covariance matrix for this distribution.
(Overrides MultivariateContinuousDistributionCovariance.)
Public propertyDimension
Gets the number of variables for this distribution.
(Inherited from MultivariateContinuousDistribution.)
Public propertyMean
Gets the mean for this distribution.
(Overrides MultivariateContinuousDistributionMean.)
Public propertyMedian
Gets the median for this distribution.
(Inherited from MultivariateContinuousDistribution.)
Public propertyMode
Gets the mode for this distribution.
(Inherited from MultivariateContinuousDistribution.)
Public propertyVariance
Gets the variance for this distribution.
(Overrides MultivariateContinuousDistributionVariance.)
Top
Methods
  NameDescription
Public methodClone
Creates a new object that is a copy of the current instance.
(Overrides DistributionBaseClone.)
Public methodComplementaryDistributionFunction
Gets the complementary cumulative distribution function (ccdf) for this distribution evaluated at point x. This function is also known as the Survival function.
(Inherited from MultivariateContinuousDistribution.)
Public methodDistributionFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFit(Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, Double)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, Int32)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodFit(Double, Double, IFittingOptions)
Not supported.
(Overrides MultivariateContinuousDistributionFit(Double, Double, IFittingOptions).)
Public methodFit(Double, Int32, IFittingOptions)
Fits the underlying distribution to a given set of observations.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Double)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Double, Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Double)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Int32)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Random)
Generates a random observation from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Double, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGenerate(Int32, Int32, Random)
Generates a random vector of observations from the current distribution.
(Inherited from MultivariateContinuousDistribution.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodInnerComplementaryDistributionFunction
Gets the complementary cumulative distribution function (ccdf) for this distribution evaluated at point x. This function is also known as the Survival function.
(Inherited from MultivariateContinuousDistribution.)
Protected methodInnerDistributionFunction
Not supported.
(Overrides MultivariateContinuousDistributionInnerDistributionFunction(Double).)
Protected methodInnerLogProbabilityDensityFunction
Gets the log-probability density function (pdf) for this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerLogProbabilityDensityFunction(Double).)
Protected methodInnerProbabilityDensityFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Overrides MultivariateContinuousDistributionInnerProbabilityDensityFunction(Double).)
Public methodLogProbabilityDensityFunction
Gets the log-probability density function (pdf) for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProbabilityDensityFunction
Gets the probability density function (pdf) for this distribution evaluated at point x.
(Inherited from MultivariateContinuousDistribution.)
Public methodToString
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(IFormatProvider)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String)
Returns a String that represents this instance.
(Inherited from DistributionBase.)
Public methodToString(String, IFormatProvider)
Returns a String that represents this instance.
(Overrides DistributionBaseToString(String, IFormatProvider).)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)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.)
Public Extension MethodToTOverloaded.
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.)
Top
Remarks

The Dirichlet distribution, often denoted Dir(α), is a family of continuous multivariate probability distributions parameterized by a vector α of positive real numbers. It is the multivariate generalization of the beta distribution.

Dirichlet distributions are very often used as prior distributions in Bayesian statistics, and in fact the Dirichlet distribution is the conjugate prior of the categorical distribution and multinomial distribution. That is, its probability density function returns the belief that the probabilities of K rival events are xi given that each event has been observed αi−1 times.

References:

Examples
// Create a Dirichlet with the following concentrations
var dirich = new DirichletDistribution(0.42, 0.57, 1.2);

// Common measures
double[] mean = dirich.Mean;     // { 0.19, 0.26, 0.54 }
double[] median = dirich.Median; // { 0.19, 0.26, 0.54 }
double[] var = dirich.Variance;  // { 0.048, 0.060, 0.077 }
double[,] cov = dirich.Covariance; // see below


//       0.0115297440926238 0.0156475098399895 0.0329421259789253 
// cov = 0.0156475098399895 0.0212359062114143 0.0447071709713986 
//       0.0329421259789253 0.0447071709713986 0.0941203599397865

// (the above matrix representation has been transcribed to text using)
string str = cov.ToString(DefaultMatrixFormatProvider.InvariantCulture);


// Probability mass functions
double pdf1 = dirich.ProbabilityDensityFunction(new double[] { 2, 5 }); // 0.12121671541846207
double pdf2 = dirich.ProbabilityDensityFunction(new double[] { 4, 2 }); // 0.12024840322466089
double pdf3 = dirich.ProbabilityDensityFunction(new double[] { 3, 7 }); // 0.082907634905068528
double lpdf = dirich.LogProbabilityDensityFunction(new double[] { 3, 7 }); // -2.4900281233124044
See Also