**Mail Archives: djgpp/1997/05/02/02:10:34**
George Foot wrote:
>
> Alan Wilson (awilson AT wilshire DOT com) wrote:
> : What is the best way to write code that generates random numbers? What is
> : the code to generate Random numbers say from 1-100 or some number in C.
>
> John Aldrich told you about the libc functions; if you were more
> interested in algorithms to generate random numbers I'd suggest you get
> (or rather, borrow) Knuth's Seminumerical Algorithms - The Art of Computer
> Programming, Volume 2. Half the book is about random numbers, how to
> generate them, how random they are, etc. Only get this if you are heavily
> into mathematics, though!
>
> You could, of course, also look at the source code for the rand[om]()
> functions in libc.
>
> --
> George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
> Merton College, Oxford
On a related, albeit somewhat tangential line, there is a short
desccription in this week's Science magazine of an algorithm to
measure the 'randomness' of the random numbers which they call
ApEn (Approximate Entropy). It is a relatively trivial test that
looks at the frequency of the generated numbers (which should be
equal if truly random), the frequency of sequential pairs of
numbers (which should also be equal - i.e., no order), the frequency
of sequential triples, etc.
- David

*- Raw text -*