-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect calculation of logpdf for multivariate normal distribution #19
Comments
I made a quick correction at 19d958e |
Thanks. |
Yes, we badly need tests. I would say that everything that's not being brought in from R should be treated as alpha or even pre-alpha software. |
@lindahua I don't think the old version was wrong. Please note that the mean is standardized with respect to the cholesky factor of the covariance matrix and not the covariance itself. Also, in the new version the result of your own example is julia> logpdf(g,x)
-21.291568715206875 I have just tried to reproduce the MATLAB result and first i couldn't, but then I tried julia> log(1/(sqrt(2pi)^3*sqrt(det(c)))*exp(-0.5*x'*(c\x)))
1-element Float64 Array:
-15.7554 The problem is that the |
Okay, please ignore last part of my message. I should have thought a little more about it. The new and my old versions are still wrong but my idea that MATLAB and Mathematica had it wrong was not that smart. I'll think it through after lunch. |
The problem was the transpose of the cholesky factor. I have pushed a fix 19d958e. |
@andreasnoackjensen Oh, it is my fault I did not test the correction myself. The problem was that I did not notice it was |
The |
You are right about the |
I implemented a multivariate gaussian distribution in my Bayesian package, and compared the results from my implementation with those yielded by Distributions.jl. I found that the
logpdf
method forMultivariateNormal
produces incorrect results.Here is a simple example:
This produces
-17.348506846053837
.The correct result should be
-15.75539253001834
. -- You may confirm this with MATLAB or other scientific software.Also,
cond(c) = 3.43
, so it is in pretty good condition. Hence, such a big difference should not be due to numerical errors. There should be a bug somewhere in this package.I think this package needs a thorough test suite to ensure the correctness of implementation -- the role of this package is fundamental for statistics.
The text was updated successfully, but these errors were encountered: