I am wondering how to draw samples in matlab, where I have precision matrix and mean as the input argument.
I know mvnrnd is a typical way to do so, but it requires the covariance matrix (i.e inverse of precision)) as the argument.
I only have precision matrix, and due to the computational issue, I can't invert my precision matrix, since it will take too long (my dimension is about 2000*2000)
Good question. Note that you can generate samples from a multivariant normal distribution using samples from the standard normal distribution by way of the procedure described in the relevant Wikipedia article.
Basically, this boils down to evaluating A*z + mu
where z
is a vector of independent random variables sampled from the standard normal distribution, mu
is a vector of means, and A*A' = Sigma
is the covariance matrix. Since you have the inverse of the latter quantity, i.e. inv(Sigma)
, you can probably do a Cholesky decomposition (see chol
) to determine the inverse of A
. You then need to evaluate A * z
. If you only know inv(A)
this can still be done without performing a matrix inverse by instead solving a linear system (e.g. via the backslash operator).
The Cholesky decomposition might still be problematic for you, but I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With