www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/02/02:10:34

From: David Stockton <stockton AT bcm DOT tmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Random generator?
Date: Thu, 01 May 1997 15:16:57 -0500
Organization: Baylor College of Medicine, Houston, Tx
Lines: 29
Message-ID: <3368FA39.475F@bcm.tmc.edu>
References: <2 DOT 2 DOT 32 DOT 19970429193847 DOT 006a0ec4 AT gate72> <5k76u0$j15 AT news DOT ox DOT ac DOT uk>
NNTP-Posting-Host: ginger.imgen.bcm.tmc.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019