Bill:
Here are snippets of code to generate random numbers based on an algorithm
developed by Hewlett Packard a while back. I set it up to take its initial
seed from the computer date and time, so, unless you are initializing the
seed value on the same day of the month and at the same time (to the nearest
second) , it should not repeat. If necessary, you can extend it to include
the month and year and thus the initial seed would always be different
======================================
-- Set initial seed
set var mydate DATE = .#DATE
set var myday = ( iday (.mydate) )
set var itime1 = ( (.myday * 1000000) )
set var mytime = .#TIME
set var myhr = ( ihr(.mytime) )
set var mymin = ( imin(.mytime) )
set var mysec = ( isec(.mytime) )
set var itime2 INTEGER = ( (.myhr * 10000) + (.mymin * 100) + .mysec )
set var itime INTEGER = ( (.itime1 + .itime2) * 1 )
set var seed DOUBLE = ( float(.itime) / 100000000.0 )
-- The value of seed is the actual random value
======================================
-- In the WHILE loop the random value is regenerated based on the value of
the previous seed
======================================
WHILE...
set var qn = ( (.#PI + .seed) ** 8 )
set var seed = ( .qn - int(.qn))
ENDWHILE
======================================
If you want to generate the random numbers between 2 points, add the
following code:
set var v_range INT = (.v_your_end_point - .v_your_beg_point)
set var v_random INT = ( .v_your beg_point + (NINT( .v_range * .seed) ) )
Actually you can combine the two statements inside the WHILE loop into one:
set var seed = ( .qn - int((.#PI + .seed) ** 8 ) )
for clarity I keep its as two statements.
In your code, once you calculate the initial seed, generating a new random
number is a one line statement.
I hope the information is of help.
Javier
Javier Valencia, PE
President
Valencia Technology Group, L.L.C.
14315 S. Twilight Ln., Suite #14
Olathe, KS 66062-4571
(913)829-0888
(913)649-2904 FAX
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Bill Downall
Sent: Friday, February 07, 2003 6:38 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Here's a Random question
Please help me remember if there is a way to "seed" the R:Base
RANDOM() function.
Now, in a loop, it generates a series of random values that appear truly
random and well distributed. However, If I run the same program later, it
generates the SAME series of random values in the same order.
I remember Wayne -- years ago -- explaining that this is a behavior useful
in testing, and that there was a way to make it truly random. I thought it
was a separate command like RANDOMIZE, but I can't find that.
Thanks for your help.
Bill