5
votes

I'm trying to fit a multivariate normal distribution to data that I collected, in order to take samples from it. I know how to fit a (univariate) normal distribution, using the fitdist function (with the 'Normal' option).

How can I do something similar for a multivariate normal distribution?

Doesn't using fitdist on every dimension separately assumes the variables are uncorrelated?

3
Have you tried copulafit? mathworks.com/help/stats/copulafit.html - amo
@rayryeng I think gmdistribution.fit does the job. Thanks! - Shaked
@Shaked - You're welcome. Good luck! - rayryeng

3 Answers

1
votes

There isn't any need for a specialized fitting function; the maximum likelihood estimates for the mean and variance of the distribution are just the sample mean and sample variance. I.e., compute the sample mean and sample variance and you're done.

0
votes

Estimate the mean with mean and the variance-covariance matrix with cov. Then you can generate random numbers with mvnrnd. It is also possible to use fitmgdist, but for just a multivariate normal distribution mean and cov are enough.

Yes, using fitdist on every dimension separately assumes the variables are uncorrelated and it's not what you want.

0
votes

You can use [sigma,mu] = robustcov(X) function, where X is your multivariate data, i.e. X = [x1 x2 ... xn] and xi is a column vector data.

Then you can use Y = mvnpdf(X,mu,sigma) to get the values of the estimated normal probability density function.

https://www.mathworks.com/help/stats/normfit.html https://www.mathworks.com/help/stats/mvnpdf.html