mercredi 23 décembre 2015

Are the results of seedrandom unbiased with 8 decimals precision?

I'm using the seedrandom lib in javascript and I want to generate a random number between 0.00010000 and 10.00000000 (8 decimals precision).

The generated random number should be unbiased. I'm using:

pngr = new Math.seedrandom(seed);
number = (pngr() * 10).toFixed(8);

Will give this unbiased (uniformly distributed) random numbers between the range above ?


Another try I did is with:

number = Math.floor(pngr() * (100000000 - 10000) + 10000);
number = (number / 10000000000).toFixed(8);

With the last code, I generate an integer that I after convert to float with fixed decimals.

Which one of two solutions will give unbiased random numbers ? (if they do)




Aucun commentaire:

Enregistrer un commentaire