• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dice


  • Subject: Re: Dice
  • From: email@hidden
  • Date: Fri, 29 Oct 2004 11:23:46 -0400

At 12:10 AM -0700 10/26/04, Michelle Steiner wrote:
On Oct 25, 2004, at 10:36 PM, Joseph Weaks wrote:

I don't really understand what you mean. You need to be more specific. Perhaps something like this?

set theDie to "one two three four five six"
some word of theDie

Hmm, which of the following is the fastest?

random number from 1 to 6
some word of "1 2 3 4 5 6"
some item of {1,2,3,4,5,6}

Some item is by far the fastest.

But none of these are nearly as fast as writing your own random number generator in applescript. :)

I developed an applemod called pseudoRand to do this because I was running monte carlo sims that needed millions of trials and I wanted them to finish in an hour or two instead of weeks.

Whatever happened to applemods anyway? The link has been saying "under construction for a year or more. Is it dead? Is that a sign of general bad things at macscripter.net?

Anyway, if anyone who didn't download back when applemods was working would like it, I could send out the script to them (or to the list if there is a lot of interest).

The disadvantage, of course is that you have to include a few dozen lines of code or so, but it's very fast.

Ticks results from grabbing 100,000 each of RandomReal (a floating point number between zero and 1), RandomInt (an integer between 1 and applescript integer limit) and Random(a,b) (an integer between a and b inclusive) are in the following list: --> {189, 172, 982}

So for the common case, you get roughly 6,000 numbers per second on my G4/450. I'm on OS 9, where nothing else works even *close* to that fast. Looking at Emmanuel's numbers, I suspect that osaxen have been speeded up some in X.

The "some item" and "some word" calls vary in speed depending on the size of the list/string, which my Random(a,b) does not (whatever range you choose, it takes approximately the same time to generate a number).


Michael

--
Michael Sullivan                             613 West Johnson Avenue
                                             Cheshire, CT 06410
Business Card Express                        800-962-4030
Thermographers to the Trade                  email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re:Dice (From: Kevin <email@hidden>)
 >Re: Dice (From: Joseph Weaks <email@hidden>)
 >Re: Dice (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Dice
  • Next by Date: [OT] Typo, someone was asking?
  • Previous by thread: Re: Dice
  • Next by thread: Re: Dice
  • Index(es):
    • Date
    • Thread