Kikimora01 / pmtk3

Automatically exported from code.google.com/p/pmtk3
MIT License
0 stars 0 forks source link

gaussLogprob and positive definiteness #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Follow the tutorial on: 
http://pmtk3.googlecode.com/svn/trunk/docs/tutorial/html/tutFoundations.html
2. From this line on I get different outputs to the ones shown in the tutorial: 
m2 = gaussFit(X(1:50,:)); cond(m2.Sigma)
3. Later, this crashes: L = gaussLogprob(m3, X);
Saying: ??? Error using ==> chol
Matrix must be positive definite.

What is the expected output? What do you see instead?
An output for L is expected. I get an error.

What version / revision of the product are you using? On what operating
system?
R2011a (64bit) on Windows 7 64bit system

Please provide any additional information below.
Looking inside the gaussLogprob function, it says:

% Full covariance case
  if 0
       logp2 = -0.5*sum((X/Sigma).*X, 2);
       logZ2 = (d/2)*log(2*pi) + 0.5*logdet(Sigma);
       logp2 = logp2 - logZ2;
  end
  %   slightly faster version
  R    = chol(Sigma);
  logp = -0.5*sum((X/R).^2, 2);
  logZ = 0.5*d*log(2*pi) + sum(log(diag(R)));
  logp = logp - logZ;

Maybe the 'if 0' should be replaced by a test for positive definiteness.

Original issue reported on code.google.com by arnold.m...@gmail.com on 5 Jul 2011 at 1:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Moved to GitHub: https://github.com/probml/pmtk3/issues/28

Original comment by irosen on 4 Jan 2014 at 2:35