function p1()

notposdef = 1;

% choose a random pos semi definite matrix
while (notposdef > 0),
  LAMBDA = rand(5,5); 

  % make it symmetric
  LAMBDA = LAMBDA - tril(LAMBDA) + triu(LAMBDA)';

  zeroidxs = [2 4 5 6 8 10 12 15 16 21 22 23];
  LAMBDA(zeroidxs) = 0;
  [x notposdef] = chol(LAMBDA);
end;

  LAMBDA
  mu = zeros(size(LAMBDA,1),1)';
  samples = gausssamp(mu,LAMBDA,50000);

  % MIXTURE OF GAUSSIAN COVARIANCE ESTIMATE
  MIXCOV = cov(samples)
  % ERROR
  MIXCOV_ERROR = MIXCOV - LAMBDA

  % 
  x1x3 = cov(samples(:,[1 3]));
  x2x4 = cov(samples(:,[2 4]));
  x3x4 = cov(samples(:,[3 4]));
  x4x5 = cov(samples(:,[4 5]));
  x3x3 = cov(samples(:,[3]));
  x4x4 = cov(samples(:,[4]));
  x5x5 = cov(samples(:,[5]));
  
  % now form new estimate of covariance matrix
  MC = zeros(5,5);
  MC(1,1) = x1x3(1,1);
  MC(1,3) = x1x3(1,2);
  MC(2,2) = x2x4(1,1);
  MC(2,4) = x2x4(1,2);
  MC(3,3) = x1x3(2,2) + x3x4(1,1) - x3x3;
  MC(3,4) = x3x4(1,2);
  MC(4,4) = x2x4(2,2) + x3x4(2,2) + x4x5(1,1) - x4x4 - x4x4;
  MC(4,5) = x4x5(1,2);
  MC(5,5) = x4x5(2,2);
  MC = MC - tril(MC) + triu(MC)';  

  MIXCOV = MC
  
end