Skip to content
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

Sampling from degenerate multivariate normal. #366

Open
mschauer opened this issue Apr 22, 2015 · 4 comments
Open

Sampling from degenerate multivariate normal. #366

mschauer opened this issue Apr 22, 2015 · 4 comments

Comments

@mschauer
Copy link
Member

Including a degenerate multivariate normal would be nice. Some concepts, e.g. gradlogpdf(d, x) would need a different interpretation and could be skipped for now.

@lindahua
Copy link
Contributor

This means zero variance along certain directions. It is interpretable mathematically.

However, it is tricky in implementation. As much of the computation relies on Cholesky decomposition, which requires positive definiteness.

@mschauer
Copy link
Member Author

The random variable Lz + μ where L is a dxℓ-matrix and LL' = A and z ~ Nℓ(0, I) is well defined and said to have a multivariate normal distribution Nd(μ, A). It is not absolutely continuous on R^d, but has density with respect to the Lebesgue measure on an adequate subspace, see http://en.wikipedia.org/wiki/Multivariate_normal_distribution#Degenerate_case . Given μ and A sampling is possible for example via

function randsmvn(mu, A) 
    S = cholfact(A, :L, Val{true})
    return mu + ipermute!(S[:L]*permute!(randn(size(S,1)),S[:p]), S[:p]) 
end

@lindahua
Copy link
Contributor

I think the issue should be to PDMats.jl, to add a degenerated covariance matrix type there.

@mschauer
Copy link
Member Author

Ref JuliaStats/PDMats.jl#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants