Re: How random is random number?
Re: How random is random number?
- Subject: Re: How random is random number?
- From: email@hidden (Michael Sullivan)
- Date: Tue, 9 Jul 2002 00:29:45 -0400
- Organization: Society for the Incurably Pompous
>
I know there was an extensive report on this issue a while back, but I can't
>
find it anywhere in the archives. Does anyone remember the results? I
>
thought Arthur Knapp helped out a bit, but I can't remember. Thanks
I'm the one who ended up writing an applemod to duplicate the random
number function.
As far as I could tell from testing (I never took the time to test it
with as large a data set as i did my own mod, since it's 40-130 times
slower), it looks like a very reasonable pseudo-random sequence. If you
need really truly random data, it's not good enough, but for most
purposes it's just fine.
You'll get the best data by seeding it with a true random number from a
service that provides "true" random numbers based on some natural random
sequence such as cosmic background radiation or quantum decay. If you
need truly killer random data, then get a large set of such numbers and
just use those, forgetting about pseudo-random sequences entirely.
BTW, both my mod and the random number osax default to a time of day
based seed. This limits you to 88400 possible first random numbers (60
times that if you modify mine as I recommend to use the ticks). For
this reason the *last* thing you want to do is reseed everytime you call
it, unless you're using outside random data to do so. You'll get much
better data by seeding it once, and then calling as many times as
necessary.
I suspect that the osax gives data that it is similar in quality to that
of my pseudoRand mod, though possibly with a lower total bit spread.
Mine spreads data just a couple bits short of the IEEE double precision
floating point that AS supports (I think it's around 50 bits). I've
gotten decent chiSquare and entropy results from it on fairly large
samples. If you need numbers that spread thorughout a very large range
(between 27 and 50 bits), my mod may give somewhat better data. I can't
really confirm this though, as it would take a longer run to really test
than I care to make. I'm using a simple 54 bit prime modulus algorithm,
and I'm trusting my tests from when it was using a 30 bit number to
carry over to a larger one (A 30 bit number gave me good random numbers
up to about 26 bits -- it takes too long for AS to generate a good data
set for 50 bits). I've tested the random number osax at around 20 bits
with a smaller than ideal size data set, but it looked as good as what
my mod produced -- much better than a lot of native pseudo-random number
services (such as gcc's)
The real reason to use my mod is speed. If you're doing monte carlos
that get moderately extensive, random number really starts to slow you
down due to the osax dispatch times. That was the whole reason I wrote
pseudoRand. I wrote an order flow sim that makes over 1,000,000 calls
for a typical run. This takes about 10 minutes with my mod and half of
a workday with the osax.
If you only need to make a few (i.e. less than a thousand) calls, you
won't really notice the slowness of random number, and I would recommend
using it for simplicity. Otherwise you can find pseudoRand at
www.applemods.com. I've also got a de Minimis implementation available
by request if you don't need all the fancy stuff.
Michael
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.