Article View: sci.math.stat
Article #420Re: Generating a set of random bits
From: Vattulainen Ilpo
Date: Thu, 20 Aug 1992 19:59
Date: Thu, 20 Aug 1992 19:59
43 lines
2345 bytes
2345 bytes
>In article <36984@sdcc12.ucsd.edu>, whart@cs.ucsd.edu (Bill Hart) writes: >|> I have an application for which I need to generate a random 'vector' of >|> bits of length N. > >nmm@cl.cam.ac.uk (Nick Maclaren) writes: >Standard warnings: > > 2) Don't trust Numerical Recipes - about half of its techniques are >reliable, but the others contain serious traps. I agree. >Perhaps the best method for your application is a Tausworthe (also called >shift-register, primitive polynomial over GF(2), etc.) with a generating >polynomial of order at least N. Indeed, although one cannot generalize the properties of shift-register generators, especially many GFSR (generalized feedback shift-register) generators have been noticed to have good statistical bit-wise properties. The results, however, depend strongly on initialization and the choice of exponents in the primitive polynomial (like p and q in a polynomial x**p + x**q + 1 ). Hence it might be a quite good choice to call such a generator with integers, and transform them to bits. These words of bits you could use for your purpose. Notice, however, that this rng should not be called to get real numbers distributed [0,1) and then multiplied with some integer (like 2**p - 1, where p is the number of bits in a particular cpu). This way you will get only 24 random bits out of 31 (on a 32-bit machine), due to 24-bit mantissas in real mode... >I am afraid that there is no simple solution to the general case of random >vectors of bits, but there are several fairly reliable ones. And one quite reliable method is to take only few most significant bits out of random numbers. Usually all the bits are not random, but at least 10 of the most significant ones are. But - do not use RAN3 (in Numerical Recipes ), if you want random bit-wise properties... This is due to my own experiences :-/ vattu@ee.tut.fi
Technical Details
Message-ID:
<1992Aug20.195901.2259@cc.tut.fi>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!cc.tut.fi!vattuReferences:
<36984@sdcc12.ucsd.edu> <1992Aug19.122345.27772@cl.cam.ac.uk>Show Full Headers
Complete Article Headers
Newsgroups: sci.math.stat Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!news.funet.fi!cc.tut.fi!vattu From: vattu@cc.tut.fi (Vattulainen Ilpo) Subject: Re: Generating a set of random bits Message-ID: <1992Aug20.195901.2259@cc.tut.fi> Organization: Tampere University of TeXnology References: <36984@sdcc12.ucsd.edu> <1992Aug19.122345.27772@cl.cam.ac.uk> Date: Thu, 20 Aug 92 19:59:01 GMT Lines: 42