Comments (10)
I made a quick correction at 19d958e
from distributions.jl.
Thanks.
from distributions.jl.
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.
from distributions.jl.
@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 pdf
is tiny, 1.43721e-7
, and hence the calculation should be done in logs. MATLAB and Mathematica don't do that and get results with large errors.
from distributions.jl.
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.
from distributions.jl.
The problem was the transpose of the cholesky factor. I have pushed a fix 19d958e.
from distributions.jl.
@andreasnoackjensen Oh, it is my fault I did not test the correction myself. The problem was that I did not notice it was d.covchol.LR
instead of d.covchol
. The correct version of the quadratic part should be
(x - d.mean) * (d.covchol \ (x - d.mean))
. Instead of (x - d.mean) * (d.covchol.LR \ (x - d.mean))
from distributions.jl.
The pdf
is not very large (at the level of 1.4e-7
, but this is not enough to produce such big difference. Actually, a correct implementation will produce very accurate result as long as the pdf is not over/underflow.
from distributions.jl.
You are right about the 1.4e-7
. I should have waited half an hour and looked at it again before posting. However, hopefully we now have a correct version. You are also completely right about the tests. It is so easy to get these things wrong.
from distributions.jl.
@andreasnoackjensen I made a revision at 819db1f
It is now correct (I added a test to ensure this) and much faster (see my gist ).
from distributions.jl.
Related Issues (20)
- Add CDF for Multinomial Distribution HOT 2
- MvNormal constructor unnecessarily recomputes cholesky every time with ForwardDiff HOT 1
- Inconsistent Type Behavior for Uniform Distribution HOT 4
- [Feature request] `gradlogpdf` on arrays
- [Feature request] Pretty printing
- Adding WishartCholesky and InverseWishartCholesky HOT 3
- Adding gradlogpdf for AbstractMixture
- Failing tests on master HOT 7
- Allocations when generating samples from MvNormal with full covariance matrix
- [Feature request] Marginal
- Adding normalized invariant measure for semi-orthogonal matrices
- Inconsistent behaviour of `truncate` for discrete distributions HOT 1
- Relaxing `::Real` requirement HOT 1
- Handle SparseArrays via Pkg extention? HOT 2
- Quantile of MixtureModel seems to never converge HOT 1
- random log-gamma for taming underflow issues HOT 1
- support for multivariate t distribution
- `inv*` functions are not really inverses HOT 9
- rand! with Uniform distribution does not work with CUDA arrays HOT 8
- Mixing `UnivariateDistribution`s and `MultivariateDistribution`s in `product_distribution`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distributions.jl.