I have a distribution with a 1×2 mean vector and a 2×2 covariance matrix. I would like to display the distribution using contour(). Can you please help me?
Best Answer
Say your mean is m, and your covariance is S.
m = [1 2];
S = [2 1; 1 10];
The easy way: If you have the statistics toolbox, there is a function called "gmdistribution"
G = gmdistribution(m,S)
F = @(x,y) pdf(G,[x y])
ezcontour(F)
The hard way: Find the equation for a multivariate normal distribution on Wikipedia:
If your data points were positive, they would look like Gamma or Chi-square distribution. Type distributionFitter in the command window and to open the distribution fitter app. There you will have options to easily fit multiple distributions and find the right one.
Best Answer