MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Random bits (generation)

  • To: mathgroup at
  • Subject: [mg35120] Re: [mg35045] Random bits (generation)
  • From: Daniel Lichtblau <danl at>
  • Date: Tue, 25 Jun 2002 03:42:35 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

"DIAMOND Mark R." wrote:
> I am not sure whether anyone other than a Wolfram guru will know the answer
> to this. ...
> (1) If I wish to generate a large number of random bits, what is the fastest
> way?
> (2) What is the safest way in the sense of being able to expect the bit
> sequence to pass Marsaglia's Diehard battery of tests Maurer's Universal
> Statistical Test.? or is this requirement impossible to meet with Random?
> More specifically, to be sure that they are independent and random, should I
> use something like Random[Integer, {0,1}] or can one use *all the bits* of,
> say, Random[Integer, {0,2^32-1}] ... or even something  larger.
> Cheers,
> Mark Diamond

Probably best just to generate random bits using e.g.

randomBits[length_] := Table[Random[Integer], {length}]

This is reasonably fast and will give high quality random sequence. You
might get better speed by generating a bigger number and then extracting
bits, but you then run the risk of having a less "random" sequence.

More information as to what methods are used under what circumstances
may be found at:

Among other things it is noted at that link that the method above should
pass all the DIEHARD tests.

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Re: FrameTick Problem
  • Next by Date: Re: FourierTransform problem
  • Previous by thread: Random bits (generation)
  • Next by thread: Re: Random bits (generation)