mercredi 31 octobre 2018

C++: Generate random numbers with a given (numerical) distribution

TL&DR:

How to implement a function in C++ like numpy.random.choice(numpy.arange(1, 7), p=[0.1, 0.05, 0.05, 0.2, 0.4, 0.2]) in Python?


Related Question Generate random numbers with a given (numerical) distribution

I have a file with some probabilities for different values e.g.:

1 0.1
2 0.05
3 0.05
4 0.2
5 0.4
6 0.2

I would like to generate random numbers using this distribution in C++. Does an existing module that handles this exist?

Thx in advance.




Aucun commentaire:

Enregistrer un commentaire