2012-01-06から1日間の記事一覧

RとC++:乱数の生成2

こちらには、"3.3 Can I use code from the Rmath header and library with Rcpp ? Can I call functions defined in the Rmath header file and the standalone math library for R–as for example the random number generators?" という質問がある Rで使っ…

RNGscope()

前の記事でRNGScope()、RNGScope zを試して、それを使わないバージョンも試した fx <- cxxfunction(signature(),'RNGScope();return rnorm(5, 0, 100);',plugin="Rcpp") fx2 <- cxxfunction(signature(),'return rnorm(5, 0, 100);',plugin="Rcpp") fx3 <- c…

RとC++:乱数の生成

こちらからの続き 乱数を発生するシミュレーションをしてみる 基本は一様整数乱数を発生させるrand()と計算機の時刻からシード整数を取るsrand() rand()は規定の大きな整数を最大値とする一様整数乱数を作るので、0-1の実数一様乱数を作るには r = (double)r…