Re: Dice
Re: Dice
- Subject: Re: Dice
- From: Tom Humiston <email@hidden>
- Date: Tue, 26 Oct 2004 14:54:35 -0400
set freq to {0, 0, 0, 0, 0, 0}
repeat 10000 times
set roll to random number from 1 to 6
set item roll of freq to (contents of item roll of freq) + 1
end repeat
freq
-- three sequential runs produced:
-- {1663, 1610, 1682, 1633, 1785, 1627}
-- {1669, 1698, 1646, 1644, 1676, 1667}
-- {1664, 1662, 1676, 1722, 1607, 1669}
I used "some item" instead of "random number" and the script runs much
faster -- about 1 sec. vs. about 1.5 min.
set freq to {0, 0, 0, 0, 0, 0}
set nums to {1, 2, 3, 4, 5, 6}
repeat 10000 times
set roll to some item of nums
set item roll of freq to (contents of item roll of freq) + 1
end repeat
freq
set names to {"one", "two", "three", "four", "five", "six"}
set roll to random number from 1 to 6
item roll in names
I tried this and got; -- by running over and over.
"four"
"two"
"two"
"six"
"four"
"two"
"two"
"two"
"four"
Doesn't seem very random at first glance.
Well, yes, because your sample size is so small. That's why the above
script runs 10,000 times, not 9.
- Tom
_______________________________________________
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
- Follow-Ups:
- Re: Dice
- From: David Andrews <email@hidden>
References: | |
| >Re:Dice (From: Kevin <email@hidden>) |
| >Re: Dice (From: Adrian Milliner <email@hidden>) |
| >Re: Dice (From: Robert Poland <email@hidden>) |
| >Re: Dice (From: "Adam K. Wuellner" <email@hidden>) |