6. gibbsR <- function(N,thin){ mat<-matrix(0,nrow=N,ncol=2) x <- 0 y <- 0 for(i in 1:N){ for(j in 1:thin){ x <- rgamma(1, 3, 1/(y*y+4)) y <- rnorm(1, 1/(x+1), 1/sqrt(2*x+2)) } mat[i,] <- c(x,y) } return(mat) } Rã®ã³ã¼ãä¾ ã®ãã¹ãµã³ãã©ã¼ ã¤ãã§ã« cmpfun ã§ã³ã³ãã¤ã«ãã¦ã¿ã gibbsC <- compiler::cmpfun(gibbsR) 7. Rcppã®ã³ã¼ãä¾ #include <Rcpp.h> using namespace Rcpp; âãããæ¸ãã¨Rcpp::ã¯æ¸ããªãã¦è¯ã // [[Rcpp::export]] âãã®ç´ä¸ã®é¢æ°ãRã«èªã¿è¾¼ã¾ãã Rcp
{{#tags}}- {{label}}
{{/tags}}