jeudi 21 janvier 2021

Generating random numbers based on a probability function

We can generate random numbers in an interval x in [a,b] easily if we want to make it uniformely:

rand()*(b-a) + a,

where rand() is a function which can generate a uniform random number between 0 and 1.

How can i generate a random number based on a distribution function e.g. (y=x^2 - x) in [a,b]?




Aucun commentaire:

Enregistrer un commentaire