Re: Random Numbers fasters than the osax
Re: Random Numbers fasters than the osax
- Subject: Re: Random Numbers fasters than the osax
- From: email@hidden (Michael Sullivan)
- Date: Tue, 2 Apr 2002 10:27:20 -0500
- Organization: Society for the Incurably Pompous
has wrote:
>
Michael Sullivan wrote:
>
>That's not a huge deal, but I'm wondering if one of you math wiz folks
>
>has a vanilla random number generator handy, or a suggestion on how to
>
>build one.
>
Catching up on a weeks' worth of mail... Did anyone mention the following
>
option?
>
some item of {0, 1, 2, 3, 4, 5, 6, 7, 8, 9,...}
This came up peripherally in a couple of proposed suggestions and I had
not been aware of it. The biggest problem is that having a long list
slows it down significantly. It's probably fine for a lot of things,
but I'm looking for 2 significant digits, and with a 100 item list, it's
slower than the osax call. You can do it twice on a 10 item list to
speed it up some, but not that much. That was Arthur's first
contribution. It still ends up at best around twice the speed, plus it's
about as complicated as the much faster and more flexible prime number
based algorithm.
With a 31 bit prime number algorithm, you've got 9 orders of magnitude
to play with and get really good pseudo-random data. So if you need 2
significant digits, you can get 10^7 samples before you start losing the
edges of your normal curve. If you need 3 digits, then you have 10^6,
etc.
This isn't great for really extended simulations, or dealing with huge
spaces (such as dealing random hands for card games). But for what I
want, and a lot of typical small monte carlo simulations, it's plenty.
I'm simulating order flow to come up with contract per order pricing
that meets the expected profit given a typical range of 1-lot, 2-lots,
etc.
For this, I'm looking at a max of around 10 million samples and
something like 2 digits of significance (a percentage chance that a
possible order will show up in a given time frame). I'm probably
pushing the algorithm slightly if I needed the best possible data, but I
don't. I could probably get away with.1 significant digit, and I don't
lose much randomness even at 100 million to 1 billion samples. A
billion samples would take 11 hours to generate, so I'm probably not
going to be using even that many. If I needed that many samples, I'd
probably code the whole thing in a faster language like C.
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.