I am trying to implement 2d Dimensional Gaussian Mixture Model
When I go through to recalculate the posterior probability using the variance and means that I calculated, I am getting the error that my SIGMA not positive square symmetric matrix.
The only thing I can think of is that I am implementing the equations wrong in MATLAB.
function [Weighted_Mu, Weighted_Sigma] = Iterative_Parameters_Calculator(Observations,Posteriors)
Weighted_Mu = [0,0];
Weighted_Sigma = [0 0; 0 0];
%Calculate the Means
Mu1 = sum(Posteriors(:,1).*Observations,1)/(sum(Posteriors(:,1),1));
Mu2 = sum(Posteriors(:,2).*Observations,1)/(sum(Posteriors(:,2),1));
Weighted_Mu = {Mu1,Mu2};
Sigma1(1,:) = sum(Posteriors(:,1).*(Observations  Mu1(1)).^2,1)/sum(Posteriors(:,1),1);
Sigma1(2,:) = sum(Posteriors(:,1).*(Observations  Mu1(2)).^2,1)/sum(Posteriors(:,1),1);
Sigma2(1,:) = sum(Posteriors(:,2).*(Observations  Mu2(1)).^2,1)/sum(Posteriors(:,2),1);
Sigma2(2,:) = sum(Posteriors(:,2).*(Observations  Mu1(2)).^2,1)/sum(Posteriors(:,2),1);
Weighted_Sigma = {Sigma1, Sigma2};
end
these are the equations
in the picture gamma is my posteriors, x is the observations, u is mu and sigma is sigma.
Is my implementation wrong?
