delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/07/10:02:22

From: "Stainmaster" <nitegarden AT msn DOT com>
Subject: Re: True random numbers.
References: <01bca8e4$2797c940$165e4ec2 AT xyy> <33F3CF45 DOT 1EDE946 AT NO_SPAMccds DOT cc DOT monash DOT edu>
Organization: Libido Unlimited
Message-ID: <01bcbac8$7daac3a0$ec2b2399@yodasgear>
Newsgroups: comp.os.msdos.djgpp
Date: Sun, 07 Sep 1997 06:27:21 -0700
Lines: 62
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> Well this won;t answer your question because there IS no true random
> numbers - atleast not that computer can do.
> 
> Most random number generators run on chaos maths. Basically, with a
> different 'seed' it sproutes a totally mathmatically predictable tree.
> The trick is to get the seed. Most people will use time, because that's
> about as random as it gets. If you can afford to, ask the user to hit a
> key. Using some time change (i.e from when you ask to when you enter, or
> the mean timing between succesive key strokes), you can get a true
> random number, because the seed is random. Note the implication of what
> i said - only humans (or nature) can produce true chaos! However, this
> is normally not a good soloution unless your writing some encryption
> stuff where you REALLY need true random numbers.  
> 
> Your problem might be a type of 'for' loop. In the case that your only
> soloution is to use time. The best method (i have found), is to make a
> function that computes the random number. No - you don;t need to know
> chaos maths. Simply have a function that stores the current seed value
> in a static variable. Now, if the seed is 0 (ie first call to the fnc),
> initialise it with the current time. With each succesive call, see if
> the time has changed by some value (this could also be random - but make
> sure it is atleast greater than half a second). If this is true, then
> intialise the random generator with this new seed. You'll always get
> different numbers this way (unless of course the chaos demands you don't
> :)). 
> 
> There are libraries avalible with different type of random number
> generators - but i find this method always works for my purposes.

	This just has to be one of those perennial Qs. I've always wondered why
you could'nt
just take that newly allocated mem and use those garbage figures it
contains as your random 
stream. Of course, only at power up before programs get at it and turn it
into whatever. It seems
that, like you say, the application for anything truely random would be
strange indeed. If anyone 
really needs them though.... I am probably a tad ignorant in suggesting
this, and maybe the "garbage"
you get in ram when you flip the BOS has some logical base. Maybe not an
elegant solution, but....
	I just dont figure that everything need be so stinking involved. Life is
complicated. Simplify,
Simplify.

- Raw text -


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