mardi 14 mai 2019

How to generate integers between min and max using normal distribution?

I learnt that we use

 unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
 std::default_random_engine generator (seed);
 std::normal_distribution<double> distribution (mean_value,variance_value);

to generate real numbers. But I don't know how to give a range (min and max) to this generation and how to generate only integers in this scenario. In case of uniform_distribution, it is straight forward. Can anyone help please? Thanks!




Aucun commentaire:

Enregistrer un commentaire