Gibbs Sampling in R and C++
I have checked gibbs sampling in different programming languages; in R x <- rgamma(1,3,y*y+4) y <- rnorm(1,1/(x+1),1/sqrt(2*(x+1))) in c++ x = R::rgamma(3.0,1.0/(y*y+4)); y = R::rnorm(1.0/(x+1),1.0/sqrt(2*x+2)); If it uses R functions why it differs in c++ as rgamma takes no n=number of observation and it takes scale instead of rate as default input and rnorm has no n= number of observation as well. For Rcpp it is totaly different such as; y = ::Rf_rnorm(1.0/(x+1),1.0/sqrt(2*x+2)); What's your question? R::rgamma() is from Rcpp too. It conveniently wraps the C-level, non-namespaced ::Rf_rnorm(