Wednesday, 15 June 2011

is there a way to set independent random streams in c++ using the armadillo c++ library? -


I want two independent random streams from Armandro Rand library. It seems as if they both use the same global random stream

I can generate random numbers using the Armandillo library through the following:

  arma :: arma_rng :: set_seed (13) double r = arma :: randu ()  

but I'm not sure how to get two random streams in Python I know that I randomize it Using the library, I can do the following:

  rn = random.RandomState (13) rn2 = random.RandomState (11)  

Now if I run rn.rand () and rn2.rand () then they are independent And do not affect each other. Any ideas?

Thank you!

Independent random number generator can be used in combination with the function in Armadillo.

The code below is optimized with std :: mt19937 and std :: uniform_real_distribution . A C + + 11 compiler is required to use

  std :: mt19937 engine1; // Mersen Twister Random Number Engine std :: mt19937 engine 2; // ... Set the Seed for Engine 1 and Engine 2 ... std :: uniform_real_distribution & lt; Double & gt; Distr (0.0, 1.0); Mat A (4,5); Mat B (4, 10); Eimbus ([& amp;] () {Ritter Destor (Engine 1);}); Beamboo ([& amp;] () {return distr (engine2);}); 


No comments:

Post a Comment