On Mon, Oct 8, 2012 at 4:23 PM, Victor <[email protected]> wrote:
> Dear all,
>
> I want to use R function mvrnorm (package MASS) in my c++ scripts. Below is
> the R code:
>
>     library(MASS)
>
>     x<-matrix(c(1.5,0,0,0,1.5,0,0,0,1.5),3,3)
>
>     mvrnorm(1,c(15,33,26),x)
>
>
> I will appreciate you very much if you give me some help and advice! Thank
> you so much!

Read the source code for the mvrnorm function.  You will find that it
is implemented by taking an eigenvalue-eigenvector decomposition of
the Sigma matrix.  If your Sigma matrix is fixed, then simply take the
decomposition in R and pass the components.  If it varies then use
RcppEigen or RcppArmadillo to obtain the decomposition.

This is not difficult but also not trivial.  You will need to do some
reading and experimenting.  Ask yourself if the amount of time you
will save in execution of the function warrants the time you will need
to spend to learn the necessary programming.
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to