From: Yusuke ENDOH Date: 2010-04-13T12:48:58+09:00 Subject: [ruby-core:29490] Re: [RubySpec #3128] Randomness specs Hi, 2010/4/11 Marc-Andre Lafortune : > 1) r.rand(N) will eventually return all values in 0...N I could be paranoid, but I doubt whether it can be guaranteed currently. This is because there is Bignum in Ruby. Pseudorandom numbers generator (even Mersenne Twister) creates long, but finite cycle of sequence of numbers. IOW, eventually the sequence repeats. So, when N is bigger than the period (cycle length), there is a number (in 0..N) that cannot be returned from r.rand(N). It is Pigeonhole principle. If there is a PRNG whose period can be configurable, it can be solved. But as far as I know, the period of MT19937 is fixed amount of 2**19937-1. Of course, it is not problematic in practice. But I guess it should not be declared as the spec. Just my two cents, -- Yusuke Endoh