I have a data set that behaves approx. Standard normal. It is an image where each observation is a pixel intensity. I want to cluster this into three different sets by fitting a 3-gaussian mixture model. I want one cluster to be "significantly" smaller than the mean (0) one to be around the mean and one "significantly" larger than the mean.
I find the initial moments and mixture coefficients by determining intial sets and calculatins the corresponding sample means and std's. This is:
- Set1:=(x|x smaller than -2std)
- Set2:=(x|x in (-0.5std,0.5std))
- Set3:=(x|x larger than 2std)
Taking the sample means and std's of these sets I can estimate initial moments and mixture coefficients to later use the EM algorithm to get 'optimum' parameters for the 3-gaussian mixture.
Using the pymix package I do:
from pymix import mixture # standard deviation of whole data set standev= np.std(x,ddof=1) # Initial Sets for Negative-Change, No-Change and Positve Change CN = x[x<(-2*standev)] NC = x[ (x > (-1*standev)/2) & (x < (standev/2))] CP = x[x>(2*standev)] # Initial Means and Variances CNimean = np.mean(CN) CNistd = np.std(CN) NCimean = np.mean(NC) NCistd = np.std(NC) CPimean = np.mean(CP) CPistd = np.std(CP) # Load data for mixture model data = mixture.DataSet() data.fromArray(np.squeeze(np.asarray(x))) # Initialize mixture model n1 = mixture.NormalDistribution(CNimean,CNistd) n2 = mixture.NormalDistribution(NCimean,NCistd) n3 = mixture.NormalDistribution(CPimean,CPistd) m = mixture.MixtureModel(3,[0.01,0.98,0.01], [n1,n2,n3]) # Resolver el Mixture model c = m.EM(data,50,0.1)
What I'm no sure on how to estimate is the proportion. For pymix's em to solve this mixture model you also need to supply an initial guessing of the proportion of observations that belong to each of the three gaussians (sum = 1). And after trying some judicious guessing, for example 1% 98% 1% as the extremal sets are before -2stds and after 2stds I end up with a mixture having for example 0.03 0.02 and 0.95 in that order, and with parameters that dont make a lot of sense.
Does anyone know what I might be doing wrong? or is my approach wrong all over? Any help would be deeply appreciatd!