jeudi 6 octobre 2016

java random number generator and their distribution

I am relying on Java's Random class, specifically on the nextInt method to generate N random numbers. I do not know what N will be ahead of time, it is decided on the fly.

One of the requirements of my todo list is to have the random numbers be representative of the distribution.

For example, if N=100, in the range from 1-100 there should be 10 (approximately) numbers between 1-10, 20 numbers between 1-20 etc.

But N can potentially grow on the fly from 100 to 100,000 and as such the distribution of the generated randoms should adjust on the fly to represent 100,000 generated numbers between 1-100

I'm not sure if this is possible, hope it makes sense what I am trying to achieve.




Aucun commentaire:

Enregistrer un commentaire