Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Apl > Re: picking a n...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 12 Topic 941 of 1019
Post > Topic >>

Re: picking a new random seed

by rbe <bernecky@[EMAIL PROTECTED] > Jan 29, 2008 at 06:15 AM

On Jan 26, 8:47 pm, Sam Sirlin <swsir...@[EMAIL PROTECTED]
> wrote:
> Charles Brenner wrote:
> > When doing Monte Carlo simulations, it may be uninteresting to redo
> > the same ones every time the workspace is loaded. As a crude method to
> > avoid reusing the same random number sequence, I wrote a loop to run
> > for one second generating a random number each time. To my surprise
> > the number of iterations in a second shows very little variation --
> > 85% of 1-second trials ran the same number of iterations hence ended
> > with the same random seed. Also, that number was quite small. (APL
> > +DOS: It was 814 but I did also advance a counter in the loop.)
>
> > I guess it would be better just to read the system clock. At 100 tics
> > per second, there are as many tics in a year as the number of valid
> > values for []RL.
>
> If you really care, you probably want to check out whatever generator
> you use with various tests. There are numerous references on the web,
> for instance
>
>
http://www.math.utah.edu/~pa/Random/Random.htmlhttp://csrc.nist.gov/groups=
/ST/toolkit/rng/index.html
>
> Sam

The real-time cycle counter on modern X86 processors provide a
timestamp that
should change often (every machine cycle!) enough to keep Charles
happy. Here's a DDJ article that
gives a snippet of C code to read it:

http://www.ddj.com/showArticle.jhtml?documentID=3Dddj0405b&pgno=3D2

Here's the  definition of RTDSC from: "Intel=AE 64 and IA-32
Architectures
Optimization Reference Manual":

"The time-stamp counter increments whenever the sleep pin is not
asserted or when
the clock signal on the system bus is active. It is read using the
RDTSC instruction.
The difference in values between two reads (modulo 2**64) gives the
number of
processor clocks between reads."

Now, having said that...

I don't know which RNG you're using, but the one in most early vintage
APL
interpreters (linear congruential) is not the greatest in the world.
You'd be better off adopting
one of the more modern RNG algorithms if cycle size, distribution
characteristics,
etc., are important to your application.

Bob


Bob




 12 Posts in Topic:
picking a new random seed
Charles Brenner <cbren  2008-01-26 17:01:18 
Re: picking a new random seed
Sam Sirlin <swsirlin@[  2008-01-26 17:47:00 
Re: picking a new random seed
"Curtis A. Jones&quo  2008-01-27 13:33:38 
Re: picking a new random seed
Phil Last <phil.last@[  2008-01-27 15:01:01 
Re: picking a new random seed
"Curtis A. Jones&quo  2008-01-28 09:09:42 
Re: picking a new random seed
Phil Last <phil.last@[  2008-01-28 10:08:42 
Re: picking a new random seed
rbe <bernecky@[EMAIL P  2008-01-29 06:15:33 
Re: picking a new random seed
Charles Brenner <cbren  2008-01-29 21:37:30 
Re: picking a new random seed
"James J. Weinkam&qu  2008-01-30 21:57:05 
Re: picking a new random seed
"jk" <*axy*@  2008-01-30 23:06:17 
Re: picking a new random seed
Jane Sullivan <jane@[E  2008-01-31 07:13:48 
Re: picking a new random seed
Charles Brenner <cbren  2008-02-03 13:59:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 10:46:05 CDT 2008.