## The Dirichlet Distribution | Extreme Optimization Numerical Libraries for .NET Professional |

The Dirichlet distribution is a generalization of the The Beta Distribution to the multivariate case. The Dirichlet distribution is often used in Bayesian analysis.

A Dirichlet distribution of order K is defined on the K-dimensional hyperplane with . It has K shape parameters, usually denoted by the Greek letter α. Its probability density function (PDF) is:

When K = 2, the Dirichlet distribution reduces to the Beta distribution.
The Dirichlet distribution is implemented by the
DirichletDistribution
class. It has three constructors. The first constructor takes a
Vector

var alpha = Vector.Create(3.0, 7.0, 5.0); var dirichlet1 = new DirichletDistribution(alpha);

The two remaining constructors estimate the distribution parameters
from a set of variables. One constructor takes a
Vector

The GetParameters
method returns a copy of the parameters α. The
GetMeans method
returns a Vector

There are two options to generate random samples from the distribution.
One is to use the
Sample
method. Sample
takes a System

MersenneTwister random = new MersenneTwister(); var sample = dirichlet1.Sample(random); var samples = dirichlet1.Sample(random, 10000); dirichlet1.FillSample(random, sample); dirichlet1.FillSamples(random, samples);

Copyright © 2004-2021,
Extreme Optimization. All rights reserved.

*Extreme Optimization,* *Complexity made simple*, *M#*, and *M
Sharp* are trademarks of ExoAnalytics Inc.

*Microsoft*, *Visual C#, Visual Basic, Visual Studio*, *Visual
Studio.NET*, and the *Optimized for Visual Studio* logo

are
registered trademarks of Microsoft Corporation.