Microsimulation API: /home/marcle/src/R/microsimulation/src/rngstream-example.cpp Source File

Microsimulation API

/home/marcle/src/R/microsimulation/src/rngstream-example.cpp
Go to the documentation of this file.
1
2 #include "rngstream-boost.hpp"
3 #include <boost/random/uniform_01.hpp>
4 #include <iostream>
5
6 int main() {
7 boost::rngstream gen, gen2;
8 boost::uniform_01<> dist;
9 std::cout << gen2 << std::endl;
10 std::cout << "Expected: 0.127011; observed: " << dist(gen) << std::endl;
11 std::cout << "Expected: 0.759582; observed: " << dist(gen2) << std::endl;
12 gen.ResetNextSubstream();
13 std::cout << "Expected: 0.079399; observed: " << dist(gen) << std::endl;
14 std::cout << gen << std::endl;
15 return 0;
16 }
17 // R -q -e "require(parallel); base=c(407L,rep(12345L,6)); .Random.seed=base; runif(2); .Random.seed=nextRNGStream(base); runif(2); .Random.seed=nextRNGSubStream(base); runif(2)"
boost::random::rngstream
Definition: rngstream-boost.hpp:57
rngstream-boost.hpp
ssim::RngStream::ResetNextSubstream
void ResetNextSubstream()
Definition: RngStream.cpp:381
main
int main()
Definition: rngstream-example.cpp:6