How To Fit Multivariate Normal Distribution To Data In MATLAB?
10,385
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.
Author by
Shaked
Updated on June 18, 2022Comments
-
Shaked almost 2 years
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? -
Masterfool about 8 yearsI have had much better results with fitdist on univariate data than with manual calculation of mean and variance.
-
Robert Dodier about 8 years@Masterfool I'm honestly curious to know what you mean by "better results". What is
fitdist
returning, if not the sample mean and variance? -
Masterfool about 8 yearsBig caveat: I mistook matlab for R. With that said, fitdist can use any of the methods in the Details section of that link. method "mme" uses sample mean and variance, but the others use some kind of numerical optimization. The fitted parameters produced, for me, a better fit to the sample histogram. My understanding is rusty, but I suppose the sample mean and variance are not actually a mle of the parameters, and higher-likelihood params can be found via numerical optimization.
-
Robert Dodier about 8 years@Masterfool Thanks for the update. Sample mean and variance are mle for distribution mean and variance for a normal distribution, and OP did mention the normal distribution specifically. But I agree, if you broaden the search to look at other types of distributions, then in general you'll need something more than sample mean and variance.
-
Masterfool about 8 yearsMy mistake; indeed I didn't consider that your comment was true for the normal distribution in particular.