mercredi 28 février 2018

How to obtain different random numbers in the same programme

I wrote this :

#include <boost/random.hpp>
#include <boost/random/normal_distribution.hpp>

int main()
{
  boost::mt19937 rng(time(0)); 
  boost::normal_distribution<> nd(0.0, 1.0);

  boost::variate_generator<boost::mt19937&, 
                       boost::normal_distribution<> > var_nor(rng, nd);
 double d = var_nor();
 }

d gives me random numbers as I want. How should I do if I need more random numbers LIKE THIS ONE in the same programme and in the same cicle for example?! Now I am seeding it with the time of th computer . And I am using the boost library.




Aucun commentaire:

Enregistrer un commentaire