Statistics [was Re: Dice]
Statistics [was Re: Dice]
- Subject: Statistics [was Re: Dice]
- From: Graff <email@hidden>
- Date: Tue, 26 Oct 2004 14:48:53 -0400
On Oct 26, 2004, at 2:28 PM, Graff wrote:
On Oct 26, 2004, at 1:48 PM, Emmanuel wrote:
At 12:46 PM -0400 10/26/04, Graff wrote:
I just ran it 1000 times and got the following distribution:
1 161
2 167
3 173
4 170
5 169
6 160
std deviation = 5.16
So no, it doesn't seem to be perfect but it's probably good enough
for most applications.
Out of curiosity, what would the std deviation be if the random was
perfect?
A perfectly even distribution would be for every value to show up the
same number of times. In that case the std deviation would be 0.
<snip>
To calculate standard deviation you first get the mean of your data
set. You then calculate the deviation of each element from the mean
and square it. You sum up these squared deviations and divide them by
the number of items in your data set. Finally you take the square
root of this number.
Since we are an AppleScript list here's a quick handler to calculate
the standard deviation of a list of numbers:
----
on stddev(theSet)
set n to count of theSet
set sum to 0
repeat with val in theSet
set sum to sum + val
end repeat
set mean to sum / n
set sum to 0
repeat with val in theSet
set sum to sum + (val - mean) ^ 2
end repeat
return (sum / (n - 1)) ^ 0.5
end stddev
stddev({161, 167, 173, 170, 169, 160})
--> 5.163977794943
----
- Ken
_______________________________________________
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: Adrian Milliner <email@hidden>) |
| >Re: Dice (From: Robert Poland <email@hidden>) |
| >Re: Dice (From: Graff <email@hidden>) |
| >Re: Dice (From: Emmanuel <email@hidden>) |
| >Re: Dice (From: Graff <email@hidden>) |