[Tutor] A file containing a string of 1 billion random digits.

Richard D. Moores rdmoores at gmail.com
Sun Jul 18 00:39:37 CEST 2010

On Sat, Jul 17, 2010 at 15:07, Hugo Arts <hugo.yoshi at gmail.com> wrote:
> On Sat, Jul 17, 2010 at 11:48 PM, Richard D. Moores <rdmoores at gmail.com> wrote:
>> On Sat, Jul 17, 2010 at 13:56, Dave Angel <davea at ieee.org> wrote:
>>> Your concern over a leading zero applies equally to two leading zeroes, or
>>> three, or whatever.
>> I don't think so. Look again at my function, randIntOfGivenLength().
>> Try a for loop with it, say with randIntOfGivenLength(9) and looping
>> 100 times:
>> for x in range(100):
>>     n = randIntOfGivenLength(9)
>>     n = str(n)
>>     print(n)
>> You'll see that all strings have 9 digits. The problem is that none of
>> them begin with "0". These are just strings of almost-random digits,
>> and in the script I give the 1st digit a chance to be a "0" by
>> prepending a digit -- just one -- chosen by random.choice() from the
>> string "0123456789".
> This is great, but now your *second* digit will never be zero. So your
> strings are still "almost" random.

Aw, you're right. Just as I was feeling pretty good about myself.

> <rant> Look, randomness is complicated. It's crap like this that trips
> up even cryptographers all the time. I know you won't need your digits
> for security or anything, but if you're concerned that the first digit
> of a sequence is never zero, you should be equally concerned by the
> second digit not being zero. It's the same amount of non-randomness,
> and your 'solution' just moves the problem around, it doesn't solve
> anything. </rant>
> Hugo
> P.S.: I just thought of this: how about generating numbers that are
> one digit too long, and removing the first digit instead of adding an
> extra one? It just gets rid of the digit exhibiting non-randomness
> altogether. (disclaimer: IANA cryptanalyst, so there may be equally
> many things wrong with this)

Looks good to me. I'll do it. And post back.

Thanks, Hugo.


More information about the Tutor mailing list