Randoms numbers on iPhone
What is better? I have the prioritized in the order of "goodness", am I correct?
开发者_如何学Go- arc4random
- randmom
- rand
1 - best, 3 - worst
I need a really good randmon number gen for a lowe number (< 50), so I using % 50 to obtain numbers below 50.
Thanks
I'm pretty sure randMOM is the one to use.
Oh, well, first google hit.
If you need a number in the range [n, m), the very best approach is to use a function explicitly designed to do so. Both scaling (from say [0, 1)) and applying a modulus may slightly alter the distribution. Of course, such skewing may be entirely irrelevant (and for most applications is probably only a theoretical consideration) -- especially if only a basic PRNG is employed.
精彩评论