Random-ness of RNG's 
Author Message
 Random-ness of RNG's

If I would write a 'better' routine than rand(), how exactly should I
test it?  How can I know how random any series of numbers are?
--

"Everything should be made as simple as possible, but not simpler."
                    --- Albert Einstein ---


Mon, 19 Nov 2001 03:00:00 GMT  
 Random-ness of RNG's

   If I would write a 'better' routine than rand(), how exactly should I
   test it?  How can I know how random any series of numbers are?

See _Art of Computer Programming, Vol. 2: Seminumerical Algorithms_
for an introduction to this science.
--
"You call this a *C* question? What the hell are you smoking?" --Kaz



Mon, 19 Nov 2001 03:00:00 GMT  
 Random-ness of RNG's

Quote:

>If I would write a 'better' routine than rand(), how exactly should I
>test it?  How can I know how random any series of numbers are?

You could dump a large amount of them into a file and then try to
compress it. If the sequence is truly random, compression should be very
inefficient.

Gergo

--
"Reintegration complete," ZORAC advised.  "We're back in the universe
again ..."  An unusually long pause followed, "... but I don't know
which part.  We seem to have changed our position in space."  A
spherical display in the middle of the floor illuminated to show the
starfield surrounding the ship.

"Several large, artificial constructions are approaching us," ZORAC
announced after a short pause.  "The designs are not familiar, but they
are obviously the products of intelligence.  Implications: we have been
intercepted deliberately by a means unknown, for a purpose unknown, and
transferred to a place unknown by a form of intelligence unknown.
Apart from the unknowns, everything is obvious."
                -- James P. Hogan, "Giants Star"

GU d- s:+ a--- C++>$ UL+++ P>++ L+++ E>++ W+ N++ o? K- w--- !O !M !V
PS+ PE+ Y+ PGP+ t* 5+ X- R>+ tv++ b+>+++ DI+ D+ G>++ e* h! !r !y+



Tue, 20 Nov 2001 03:00:00 GMT  
 Random-ness of RNG's

Quote:

>If I would write a 'better' routine than rand(), how exactly should I
>test it?  How can I know how random any series of numbers are?

----------
If you are serious about this,  the book by Knuth allluded to upstrream is the
way to go.  But I never bothered to do that, you always have to learn the
repertoire and foibles of his {*filter*} little hypothetical computer in order to
understand, at least thouroughly, his stuff.  If he is still alive and
interested in making money, I wish he (or someone younger and hungrier) would
rewrite his books using something like Pascal or Algol 60 as a base.    I think
any programmer can at least read ( but not write) those two languages.  

Here is something I did several years ago.  I plotted a single black pixel on
an x-y plane and watched as the screen gradually turned black, looking for
patterns of some sort.  For a 16 bit number, say 10 bits for x and 6 bits for
y.  
I don't know that this is defensible mathematically but I found it very
appealling at an intuitive level.  And, yes, I know one shouldn't use intuition
in this field especailly.

Another way that appeals to me (again indefensible) is to collect say 1600
numbers and plot a histogram of any four bit field (contiguous or
non-contiguous) from the set of numbers.  The 16 bars should all be of
approximately equal length.  You could watch these histograms being repainted
in real time and it doesn't require knowlege of Windows or some other God awful
GUI.  (I did my work on an Atari ST, the last decent computer made.)

I guess properly this belongs on some math newsgroup.  Where you will be fresh
meat and subject to all kinds of ridicule because you don't know about 'Abel's
incompleteness theorem on the computability of rational approximations' or some
such bit of esoterica.

If you repost, I would appreciate an E-mail about where you go since I find it
a fascinating subject.  But not fascinating enough to wade through Knuth.  My
address is real and works, as is true of all AOL addresses.



Tue, 20 Nov 2001 03:00:00 GMT  
 Random-ness of RNG's


Quote:

>>If I would write a 'better' routine than rand(), how exactly should I
>>test it?  How can I know how random any series of numbers are?

There are tests but the theory can get quite involved. It is not a simple
subject.

Quote:
>You could dump a large amount of them into a file and then try to
>compress it. If the sequence is truly random, compression should be very
>inefficient.

Unfortunately many non-random sequence also compress poorly so this
would only show up generators that are severely broken e.g. repeat the
same value a lot of times.

--
-----------------------------------------


-----------------------------------------



Tue, 20 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Comparing 7 inlined RNG codes /Re: Timing differences for a random number generator

2. preserving 'const'ness

3. why aren't my random numbers random ?

4. Create Random Password isn't random

5. asking for help on 'random number'

6. A challenge -- C preprocessor expression for machine's `endian-ness'?

7. Detecting endian-ness via a #if ?

8. enforcing ansi-ness on gcc

9. C storage class for endian-ness

10. testing for endian-ness

11. CArchive object and Endian-ness

12. Bit fields and Endian-ness

 

 
Powered by phpBB® Forum Software