C++ implementation of multivariate normal probability density function for multiple inputs
Source:R/RcppExports.R
mvnpdfC.Rd
Based on the implementation from Nino Hardt and Dicko Ahmadou https://gallery.rcpp.org/articles/dmvnorm_arma/ (accessed in August 2014)
Examples
mvnpdf(x=matrix(1.96), mean=0, varcovM=diag(1), Log=FALSE)
#> [1] 0.05844094
mvnpdfC(x=matrix(1.96), mean=0, varcovM=diag(1), Log=FALSE)
#> [1] 0.05844094
mvnpdf(x=matrix(1.96), mean=0, varcovM=diag(1))
#> [1] -2.839739
mvnpdfC(x=matrix(1.96), mean=0, varcovM=diag(1))
#> [1] -2.839739
if(require(microbenchmark)){
library(microbenchmark)
microbenchmark(dnorm(1.96),
mvnpdf(x=matrix(1.96), mean=0, varcovM=diag(1), Log=FALSE),
mvnpdfC(x=matrix(1.96), mean=0, varcovM=diag(1), Log=FALSE),
times=10000L)
}else{
cat("package 'microbenchmark' not available\n")
}
#> Unit: nanoseconds
#> expr min
#> dnorm(1.96) 791
#> mvnpdf(x = matrix(1.96), mean = 0, varcovM = diag(1), Log = FALSE) 51596
#> mvnpdfC(x = matrix(1.96), mean = 0, varcovM = diag(1), Log = FALSE) 4308
#> lq mean median uq max neval
#> 931 1264.260 1302.0 1493 13836 10000
#> 54241 59183.584 55198.5 56746 2942525 10000
#> 4779 6313.462 5861.0 6372 2776827 10000