Below is an implementation of EM Algorithm in Octave:
- Replace the inverse function with pinv if you get machine precision errors.
- r2 is the mean matrix for both clusters.
- data_cluster_1_cov is the covariance matrix for first cluster whereas data_cluster_2_cov is the covariance matrix for second cluster.
- h is the label matrix for both clusters.