DPRG
DPRG List  



DPRG: BOUNCE dprglist@dprg.org: Non-member submission from ["Dickens, Thomas P" <Thomas.Dickens@pss.boeing.com>]

Subject: DPRG: BOUNCE dprglist@dprg.org: Non-member submission from ["Dickens, Thomas P" <Thomas.Dickens@pss.boeing.com>]
From: Jim Brown jimbrown at airmail.net
Date: Wed Jan 14 20:11:49 CST 1998

>Return-Path: <owner-dprglist at dprg.org>
>Date: Wed, 14 Jan 1998 12:57:12 -0600
>From: owner-dprglist at dprg.org
>X-Authentication-Warning: horta.ncc.com: mail set sender to
owner-dprglist at dprg.org using -f
>To: owner-dprglist at dprg.org
>Subject: BOUNCE dprglist at dprg.org:    Non-member submission from
["Dickens, Thomas P" <Thomas.Dickens at pss.boeing.com>]   
>
>>From dprglist-owner at horta.ncc.com  Wed Jan 14 12:57:11 1998
>Received: from nimon.ncc.com (nimon.ncc.com [199.1.173.2])
>	by horta.ncc.com (8.8.5/8.8.5) with SMTP id MAA04058
>	for <dprglist at horta.ncc.com>; Wed, 14 Jan 1998 12:57:09 -0600
>Received: from thomas.dickens at pss.boeing.com [199.238.248.100] by
nimon.ncc.com (OS/2 NCCmail v0.33) with SMTP
>          for dprglist at dprg.org; Wed, 14 Jan 98 11:43:16 CST
>Received: from xch-pssbh-01.ca.boeing.com ([130.42.112.150])
>	by mailgate2.boeing.com (8.8.5/8.8.5) with ESMTP id JAA13042
>	for <dprglist at dprg.org>; Wed, 14 Jan 1998 09:54:31 -0800 (PST)
>Received: by xch-pssbh-01.ca.boeing.com with Internet Mail Service
(5.0.1458.49)
>	id <CP5757ZC>; Wed, 14 Jan 1998 09:54:03 -0800
>Message-ID: <91FEE75C6CBAD011991D00805FFE1A4B5A97AC at xch-sea-11.ca.boeing.com>
>From: "Dickens, Thomas P" <Thomas.Dickens at pss.boeing.com>
>To: DPRG <dprglist at dprg.org>,
>        seattle robotics society
>	 <srs at seattlerobotics.org>,
>        "'robojoc at postoffice.worldnet.att.net'"
>	 <robojoc at postoffice.worldnet.att.net>
>Subject: RE: "Random" Numbers
>Date: Wed, 14 Jan 1998 09:53:59 -0800
>X-Priority: 3
>MIME-Version: 1.0
>X-Mailer: Internet Mail Service (5.0.1458.49)
>Content-Type: text/plain;
>	charset="iso-8859-1"
>
>
>A random-number routine I've run across which I like is:
>
>/***********************************************************************
>*
>**********************      Random With Seed
>***********************
>************************************************************************
>/
>double      random_with_seed( long number )
>{
>
>union {
>   unsigned long      next;
>   struct {
>      unsigned short      : 1  ;
>      unsigned short     n : 15 ; } bits;
>} seed ;
> 
>seed.next = number * 1103515245 + 12345 ;
>return( (double)seed.bits.n / 32767.0 ) ;   /** return 0.0 to 1.0 **/
>}
> 
>Of course for the HC11 we would not convert the result to a 0.0 to 1.0
>float.
>
>Another approach to randomness in electronics is to generate white noise
>and to sample the voltage level at a discrete point in time (with an
>analog
>E-port input on the HC11).  I've seen references that this can easily be
>done using a simple transistor circuit. 
>
>Anyone know the details on this???
>
>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
>Tom Dickens    thomas.p.dickens at boeing.com
>
>> ----------
>> From: 	Eric B. Olsen[SMTP:robojoc at worldnet.att.net]
>> Sent: 	Monday, January 12, 1998 9:15 PM
>> To: 	DPRG; seattle robotics society
>> Subject: 	"Random" Numbers
>> 
>> Hi all,
>> 
>> Regarding random number generators, I have taken someone's advice out
>> there and looked in to my Numerical Recipes in C book!  The write-up
>> turned out to be very interesting ... The truth about many RNG's out
>> there is that they are not very good at all, and while even bad random
>> number generators may work for given robotic application, why use them
>> if there's something better?
>> 
>> In my gaming experience, I 've come across several different forms of
>> algorithms; two of the most dominent are "linear congruential type",
>> and
>> "shift register feedback" type.  I've chosen to list the former type
>> as
>> this is documented in the Numerical Recipes book and has test
>> references
>> available.
>> 
>> The routine is documented as a quick and fast method that yields
>> acceptable results.  The book also instructs that 32 bit RNG's are
>> highly preferred over other shorter sequence algorithms.  The routine
>> is:
>> 
>> 
>> 
>> unsigned long idum;
>> 
>> idum = 1664525L * idum + 1013904223L;
>> 
>> 
>>  That's it!  Everytime you need a number, execute the recurrence
>> equation (remember, don't trash 'idum', it'll be needed exactly as is
>> in
>> the next call).  The seed value is any number that you initially start
>> idum with.
>> 
>> If you need a floating point number, a (somewhat dirty) trick that is
>> documented in the book as follows: (which is apparently specific to
>> IEEE
>> format floating point numbers)
>> 
>> 
>> unsigned long idum, itemp;
>> float rand;
>> 
>> static unsigned long jflone = 0x3f800000;
>> static unsigned long jflmsk = 0x007fffff;
>> 
>> idum  = 1664525L * idum + 1013904223L;
>> itemp = jflone | (jflmsk & idum);
>> rand = (*(float *)&temp)-1.0;
>> 
>> 
>> Of course, the down side to these routines is the need for 32 bit
>> integer operations, however, this is required if the RNG is going to
>> yeild minimally acceptable results in terms of sequence length (repeat
>> period).
>> 
>> The book also mentions that to generate a range of random numbers, it
>> is
>> best to use the most significant digits of the number as opposed to
>> the
>> least significant bits, thus, when requiring a random number between 1
>> and 10, you should use something like:
>> 
>> j = 1 + (int)(10.0 * rand( ) / (RAND_MAX + 1.0))
>> 
>> of course, notice that this means you have floating point available.
>> 
>> The book says that forms like:
>> 
>> j = 1 + (rand( ) % 10)
>> 
>> are not recommended as they use lower order bits...although I'll have
>> to
>> admit I've used these when the generators are "free-running".
>> 
>> You'll have to take the above statements and place them into a
>> function
>> call, remembering that "idum" is a global variable.
>> 
>> In electronic gaming devices, another trick is used to keep the
>> randomness of the generator very high, that is, keep the RNG
>> "free-running" in the background, perhaps in a timer interrupt if
>> possible.  (Free running means the generator keeps pulling numbers
>> regardless of whether they are needed or not!)  This means that you'll
>> have to structure a routine to retreive a valid state of the RNG,
>> which
>> can be a bit tricky  (disable interrupts!!) ... however, the results
>> are
>> amazing since your gnerator generates a "random" number, not just
>> "psuedo-random numbers"!   i.e. the real world is influencing when the
>> numbers are pulled from a generator that is constantly going!
>> 
>> Hope some of this stuff's been useful!
>> 
>> 
>> Eric Olsen
>> 
>> --
>> 
>> "Time will tell if the human race can handle the responsibility of
>> it's
>> own evolution"
>> 
>> Spectronix, Inc.
>> Fax:
>> Email:  robojoc at worldnet.att.net
>> Web-Site:
>> Henderson, NV
>> 
>> 
>
>
>
>
- - - ____ - - - - - - ___ - - - - - - - - - - - - - - - - - - - - - - - - - -
    \/\_\@  ____    /  /\ __  ___          ___    http://www.dprg.org 1-17
    / / /\ / / /\  /--/ //\_\/\_/\ /\/\/\ /\_/\  http://users.why.net/jbrown
/__/ / / // / / / /__/ // / /__/ //_/_/ // // / (972)519-2868, (972)495-3821
\__\/  \/ \/\/\/  \__\/ \/  \__\/ \_\_\/ \/ \/ jgbrown at spdmail.spd.dsccc.com

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


More information about the DPRG mailing list