The Multivariate Normal Distribution | Extreme Optimization Numerical Libraries for .NET Professional |

The multivariate normal distribution is a generalization of the The Normal Distribution. It is characterized by a vector of means μ and a variance-covariance matrix Σ, which must be positive definite. The probability density function is:

where μ is the vector of means and Σ is the variance-covariance matrix. The multivariate normal distribution is also known as the multivariate Gaussian distribution.

The multivariate normal distribution is implemented by the MultivariateNormalDistribution class. It has two constructors. The first constructor takes two arguments. The first argument is a vector containing the means. The second argumentis a symmetric matrix that contains the covariance matrix.

The following constructs the trivariate normal distribution:

var mu = Vector.Create(3.0, 7.0, 5.0); var sigma = Matrix.CreateSymmetric(3, new double[] { 1.0, 0.3, 0.7, 0.3, 3.0, 1.2, 0.7, 1.2, 5 }, MatrixTriangle.Upper, MatrixElementOrder.RowMajor); var mnormal = new MultivariateNormalDistribution(mu, sigma);

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

The GetMeans method
returns a Vector

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

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

Copyright © 2004-20116,
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.