
function [param] = inimix(X,k)

[n,m] = size(X);

[V,E] = eig(cov(X)); 
e = median(diag(E));
S = diag(e*ones(1,m));    % initial covariance for all mixture components

[rt,I] = sort(rand(n,1)); % random ordering of the examples

param=[];
for i=1:k,
  mean_i = X(I(i),:);  % initial mean is a randomly selected point
  if (length(param) < 1)
    param = [struct('mean',mean_i,'cov',S,'p',1/k)];
  else
    param = [param,struct('mean',mean_i,'cov',S,'p',1/k)];
  end
end;


