Im using the rand() function from the Standard c Library to generate numbers for a Monte Carlo simulation in the range 0 to 1 using:
(double)rand()/RAND_MAX
But I noticed that the result was slightly of. I checked at which value the generated numbers averaged out and it was slightly under the expected 0.5.
I read that rand() ist Modulo biased but I’m not using modulo here. Is there a more precise way to generate numbers between 1 and 0?
Aucun commentaire:
Enregistrer un commentaire