[algogeeks] Re: Generate random number from 1 to 10.

2014-02-07 Thread Don
Because if you put that in a loop you will get a series like: 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5... On Thursday, February 6, 2014 8:27:27 PM UTC-5, SVIX wrote: Just curious... Why is this more random than (getSystemTimeInMilliseconds() % 10) On Thursday, February

Re: [algogeeks] Re: Generate random number from 1 to 10.

2014-02-07 Thread Don
A random generator will not always (or even usually) produce a permutation of the possible values before repeating. If you call my function 10 million times and tally up the results, you will get a distribution with about a million of each value, as close as you would expect for a random

Re: [algogeeks] Re: Generate random number from 1 to 10.

2014-02-07 Thread atul anand
@don : awesome +1 . I was not aware of George Marsaglia's Multiply With Carry generator. But it is soo clll . If you have any good link for its proof or explanation of the idea behind it then please mention it. I never knew generating random number can be few lines of code :) Thanks :)