| rmvn_prec | R Documentation |
Draws from N(mu, Q^-1) through a sparse Cholesky factorisation of the precision, Q = P' L L' P, as x = mu + P' L^-T z with z standard normal. Nothing is inverted, and the Cholesky factor keeps the sparsity of Q, so the cost is that of the factorisation rather than of a dense inverse followed by a dense n-by-n Cholesky of it. A dense precision is simply a sparse matrix with no zeros, and costs no more this way than the old route did.
rmvn_prec(n, mu, prec_mat)
n |
Number of samples |
mu |
Mean vector |
prec_mat |
Precision matrix, sparse or dense |
If prec_mat is not positive definite – a fit that has not converged,
or a singular Hessian – there is no Cholesky factor to be had, and this
falls back on prec_to_cov, which uses a generalised inverse
and warns.
Matrix with one row for each sample and one column for each element
of mu
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.