[NCLUG] My attempts using /dev/random...

Sean Reifschneider jafo at tummy.com
Sun Apr 13 15:15:59 MDT 2008


I went ahead and generated a bunch of randomness from /dev/random on
several different hosts.  My laptop, over the last 4 days or so, didn't
even get enough randomness for 100,000 rolls of 2 dies (using the mechanism
suggested by Stephen's research).  The other systems I tried were able to
get enough randomness for 4 iterations of 100,000 rolls.

See the README for more details, but I ran this against an OpenSolaris
(backup1) system, 2 Linux systems with plenty of activity on them (routera
and mirrors), /dev/urandom on my laptop, and then also a pass running the
Python random number generator.

The results are:

======================== randomness-backup1 ========================
chi squared: 13.56146 iters: 100000
chi squared: 10.712816 iters: 100000
chi squared: 9.986612 iters: 100000
chi squared: 15.16541 iters: 100000

======================== randomness-mirrors ========================
chi squared: 9.383732 iters: 100000
chi squared: 5.289914 iters: 100000
chi squared: 7.222466 iters: 100000
chi squared: 10.234694 iters: 100000

======================== randomness-routera ========================
chi squared: 6.807866 iters: 100000
chi squared: 10.522898 iters: 100000
chi squared: 9.53456 iters: 100000
chi squared: 3.227186 iters: 100000

======================== urandomness-guin ========================
chi squared: 8.0114 iters: 100000
chi squared: 7.466174 iters: 100000
chi squared: 9.163472 iters: 100000
chi squared: 7.094624 iters: 100000

======================== pyrandomness-guin ========================
chi squared: 12.198728 iters: 100000
chi squared: 16.710518 iters: 100000
chi squared: 14.67455 iters: 100000
chi squared: 14.655584 iters: 100000

My findings:

   1,008 and 10,000 iterations were really showing huge discrepancies
   between iterations.  Which isn't surprising for random data sets.
   Things seemed to settle down at 100,000, but there are still fairly
   large swings (3-10 in one set).

   The Python random number generator isn't great.  I'll probably continue
   to use it though, as I don't think I have anything that really cares
   about things being THAT random.

   Linux /dev/random seems to be pretty good, if we say that random.org is
   scoring a chi^2 of 7-ish.

   OpenSolaris' /dev/random is not as good as Linux's, /dev/random *OR*
   /dev/urandom.

   Linux's /dev/urandom is probably good enough.  I'd definitely use it for
   populating randomness on a hard drive before putting a crypto
   file-system on it, for example.

Code and data is 13MB and available at
http://dev.tummy.com/~jafo/randomness-20080413.tar

Sean
-- 
 I didn't spend 6 years in evil medical school to be called *MISTER* Evil!
                 -- Dr. Evil, _Austin_Powers:_International_Man_of_Mystery_
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability




More information about the NCLUG mailing list