mardi 17 octobre 2017

What is the fastest method to create uniform random numbers in c++

I need to generate uniform random numbers in a for loop. for loop goes for 1000000 numbers. There is another for loop which goes to 2000 inside it. So I generate 2*10^9 uniform random numbers. I use below method:

#include <random>
    double zeta;
     unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
        auto uniform_rand = bind(uniform_real_distribution<double>(0,1), mt19937(seed)); 
    for(int i=0; i<N; i++)
               for(int i=0; i<N; i++) 
       zeta=-eta/2.0+uniform_rand()*eta; // in the range (-eta/2, +eta/2)
    end
end




Aucun commentaire:

Enregistrer un commentaire