function parameters=modelData(data,dim,nc,steps,squeeze,howmuch,dim1,dim2) %This function simply strips dim eigenvectors off the Data %Calculates an initial estimate for the nc means of the Gaussian mixtures %Hands the Data off to the EM algorithm for iterative refinement of the %model parameters maxObs = max(data); minObs = min(data); meanObs = mean(data); %Now we can get any number of mean estimates by interpolating from the %maximum observation to the minimum observation. %Hey, its an estimate! if(squeeze==1) %Squeezing the max and min observations towards the mean in an attempt to %avoid modeling outliers minObs = minObs + howmuch*(meanObs-minObs); maxObs = meanObs + (1-howmuch)*(maxObs-meanObs); end %The mean is not likely to be the halfway interpolation between min and max, %but unless the data has a significant skew, its likely to be close. for mn=1:nc means(mn,:)=minObs + ((mn-1)/(nc-1))*(maxObs-minObs); end %Make sure the sample mean is one of the estimates means(ceil(nc/2),:) = meanObs; end alphas = ones(1,nc)*1/nc; parameters = EMND(data,means,alphas,nc,steps,0,1,dim1,dim2)