Calculating the Gaussian distribution paramaters
Show older comments
Hello,
I'm trying do a small script to try the EM algorithm in which I have 2 sets of 1 dimension points that belong to 2 different guassians but I don't know which point belongs to which data set, and the EM algorithm estimates the gaussian parameters (mean,variance) for both.
For that I first create a small data set
data1 = normrnd(-6,3,[200 1]);
data2 = normrnd(6,1,[200 1]);
data = [data1;data2];
Then to compare the results outputed by the EM algoritm, I first calculate the gaussian distrubution parameters. However the result I get is slightly different if i use the matlab funtion fitdist or if I code the math it self: (left is manual math, right is fitdist)

Why is that?
PS:
The math I did was for mu and sigma:


The manual math is coded as:
% (μ,σ²)
distGauss1.mu = mean(data1);
distGauss1.sigma = mean((data1-distGauss1.mu).^2);
distGauss2.mu = mean(data2);
distGauss2.sigma = mean((data2-distGauss1.mu).^2);
Accepted Answer
More Answers (0)
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!