Re: Random Numbers fasters than the osax
Re: Random Numbers fasters than the osax
- Subject: Re: Random Numbers fasters than the osax
- From: Caleb Strockbine <email@hidden>
- Date: Thu, 28 Mar 2002 10:19:00 -0500
On Wednesday, March 27, 2002, at 02:07 PM, <email@hidden> 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. I can probably come up with decent hash functions by digging
through some of my old algorithms books, but the only good changing
number I can think to seed it with is ticks, which is another osax --
and to get real random numbers I'd need to reseed every time, no?
Prof. Steven Skiena has a section in his book, "Calculated Bets," that
talks about monte carlo simulation and random number generators.
There's a great quote in there from John von Neuman regarding random
number generators. I don't remember the quote exactly, but the idea is
along the lines of "anyone who thinks he can get truly random numbers
out of a computer has got rocks in his head."
You don't need to reseed the random number generator every time you
use it you seed it once with some difficult-to-predict number, like the
tick count, just to get it started (hence the term "seed").
It seems to me that most of the penalty of using an osax command for
generating (pseudo-)random numbers probably comes from whatever
overhead is involved in calling any osax function. I'd imagine this might
include making sure the resouce is loaded, locking it in memory,
converting arguments to the right types, etc. The time spent actually
executing the PRNG to get a number is probably a smallish fraction of
the entire time. If that's all true, then it stands to reason that you
could
speed up performance quite a bit by writing a PRNG osax that would
generate a long list of numbers all at once. If you generate 1000
numbers at a time instead of 1, the cost of the osax-related overhead
is reduced by a factor of 1000.
By the way, "Calculated Bets" is a real page turner, at least by computer
science standards. It describes Skiena's life-long fascination with
Jai-Alai
and particularly his efforts to build a system that predicts the
outcomes of
Jai-Alai matches based on previous statistics. Well worth the $13 or so
that Amazon wants for it. (Full disclosure: although I majored in
computer
science at SUNY at Stony Brook, where Prof. Skiena teaches, I don't think
he'd know me from Adam, and I have no particular personal interest in
the sale of this book. I just bought it, and liked it.)
Caleb Strockbine
_______________________________________________
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.