Rob Arthan rda at lemma-one.com
Mon Jan 6 15:47:10 UTC 2014

```On 3 Jan 2014, at 22:57, Albert Y. C. Lai wrote:

> On 14-01-03 11:28 AM, Rob Arthan wrote:
>> roll n = take n . randomRs ('1', '6') . mkStdGen \$ n
>>
>> However, this produces a string beginning with a '6' for 0 <= n <= 53667.
>
> It seems to me such small numbers do not have enough entropy to be worthy seeds to begin with. Say, in the 64-bit binary form of 53667, how many consecutive 0's are there?

I don't think the entropy of the number considered as a string of bits is relevant.
The later part of my post strongly suggests that there is a pattern.
And in fact this pattern turns out to repeat indefinitely. The following calculates
about 10^7+1 values  starting with a large integer that I obtained from /dev/urandom:

map (\l -> (head l, length l)) . group . map (fst . randomR (1, 6) . mkStdGen) \$ [0x383b0d54718ac75f..0x383b0d54718ac75f+1000000]

The result is:

[(2,36076),(1,53669),(6,53668),(5,53668),(4,53669),(3,53668),(2,53668),(1,53669),(6,53668),(5,53668),(4,53668),(3,53669),(2,53668),(1,53668),(6,53669),(5,53668),(4,53668),(3,53669),(2,51563)]

So we keep on getting long runs of seed values that produce the same value on the first call of randomR even
when we start with a seed that will have around 60 bits of entropy (if /dev/urandom on my heavily used iMac
is doing its job).

Regards,

Rob.

> _______________________________________________