[n,m] = size(X);

param = inimix(X,3);

cont = 1; it = 1; L = [];

while (cont), 
   param = em(X,param); 
   loglik = evalmix(X,param);

   if (length(L)<1), L = [loglik]; else L = [L;loglik]; end;

   if (it>2), cont = (L(it)-L(it-1)>eps) & (it<10000); end;
   it = it + 1;
end;

