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

Drawing from multivariate normal distribution #1262

Open
DJDuque opened this issue Oct 29, 2022 · 2 comments
Open

Drawing from multivariate normal distribution #1262

DJDuque opened this issue Oct 29, 2022 · 2 comments

Comments

@DJDuque
Copy link

DJDuque commented Oct 29, 2022

Background

I have looked at the documentation, and it looks like this is currently not possible (?)

What is your motivation?
I keep going back to Python and Numpy's multivariate_normal whenever I need this, and I was wondering if it was within the scope of the rand_distr crate.

Feature request

I would like to be able to draw samples from a multivariate normal distribution given a covariance matrix.

@dhardy
Copy link
Member

dhardy commented Oct 30, 2022

I believe you are correct; neither rand_distr or statrs support this. rand_distr has a few multivariate distributions (e.g. Dirichlet, unit sphere).

Wikipedia explains how to sample from this distribution — but requires the Cholesky decomposition (available in some other crates).

Yes, ideally we'd implement this in rand_distr. I'll leave this issue open, but don't expect much progress (unless you'd like to provide).

It also brings up the question of whether rand_distr should depend on a linear algebra library. IIRC this may have been brought up before. Possibly it makes sense to start a new crate for multi-variate distributions. @vks?

@TheIronBorn
Copy link
Collaborator

Is this from statrs not sufficient? https://docs.rs/statrs/latest/statrs/distribution/struct.MultivariateNormal.html#impl-MultivariateNormal it supports a covariance matrix

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

3 participants