0

I had read someone's blog that the high precision random number is hard to get, he said if we want to get a chance in a million, using :

Random(1,1000)*Random(1,1000) < 2 is better than Random(1,1000000)<2 ( we suppose Random(1,n) generate integer numbers between 1 to n )

theoretically, the probilities of two are the same, but what's different action of those expression in a real program? for example rand() function in standard C language, and please give more information.

  • 7
    No, the properties of Rand(1,1000)*Rand(1,1000) are not the same as Rand(1,1000000), as [this answer](http://stackoverflow.com/questions/3956478/understanding-randomness/3956538#3956538) shows. – rcollyer Sep 07 '11 at 04:24
  • Notwithstanding what rcollyer said (that is absolutely correct), if you are looking for EXACTLY 1 possibility over X, they should be equivalent. And I don't know what you mean with "high precision". If you mean "generating random double numbers is very difficult" then yes, but here you are working with integers. – xanatos Sep 07 '11 at 04:55
  • Did you mean `Random(1,1000) + 1000 * Random(0,999)`? Please provide a link to the blog entry. – starblue Sep 07 '11 at 07:34

1 Answers1

1

What you probably want by asking for 'high-precision' is a cryptographically secure pseudorandom number generator, that is, one with a high enough entropy that it's certifiably random enough for high security applications. LavaRnd is one of these, if you provide it with a lens capped webcam (ideally a webcam in a box completely devoid of light) for input.

Another cryptographically sound algorithm is Blum-Blum-Shub, but it's very slow. You could also take a look at Fortuna.