mercredi 24 mai 2017

Which simple (pseudo) random number generator/method to choose from?

I have a batch script that has to randomly read a quote from a text file.

But: Which PRNG method is most random i.e. least predictable?

We all know %RANDOM% isn't that great, but i've noticed that executing %RANDOM% multiple times in a row (in same session) gives a more satisfying number of results.

Is this true or am i better off using the below j(ava)script?

function getRandomNumber(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

WScript.echo(getRandomNumber(0, 32767));

/copyitright




Aucun commentaire:

Enregistrer un commentaire