jeudi 11 février 2021

Generate a predictable random number from any number

From a number x, I want a function to get a random number y, uniformly distributed. For same x, the function should return same y.

I tried:

float func(int x) {
  return new Random(x).nextFloat();
}

but apparently only the sequence of numbers provided by a seeded Random is uniformly distributed, not first values. Is this possible?




Aucun commentaire:

Enregistrer un commentaire