samedi 4 février 2017

C++ generate multiple random numbers without loop

I want to generate 10000 random numbers from a normal distribution. Following lines gave me one number at a time. Is there a faster way to generate them? Maybe avoid looping?

  std::default_random_engine generator;
  std::normal_distribution<double> distribution(0.0,1.0);
  double number[10000];
  for (int i =0; i< 10000; i++)
     number[i] = distribution(generator);




Aucun commentaire:

Enregistrer un commentaire