Repeatedly rolling a six sided die four times and summing the highest three results gives you a distribution with what mean and standard deviation?
I've only taken AP statistics, but I would like to learn how to do this.
Repeatedly rolling a six sided die four times and summing the highest three results gives you a distribution with what mean and standard deviation?
I've only taken AP statistics, but I would like to learn how to do this.
(D&D player?) It's easy enough to just enumerate the whole distribution. In R:
> a1 <- rep(1:6,times=216)
> a2 <- rep(1:6,times=36,each=6)
> a3 <- rep(1:6,times=6,each=36)
> a4 <- rep(1:6,each=216)
> tot <- a1+a2+a3+a4-pmin(a1,a2,a3,a4)
That's all it takes (there's a bunch of other ways to do it). Results:
> mean(tot)
[1] 12.2446
> n <- length(tot)
> sd(tot)*sqrt((n-1)/n) # we have the whole distribution; we want n-denominator, not n-1
[1] 2.846844
> quantile(tot)
0% 25% 50% 75% 100%
3 10 12 14 18
> table(tot) #frequencies
tot
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
1 4 10 21 38 62 91 122 148 167 172 160 131 94 54 21
> print(table(tot)/sum(table(tot))*100,d=2) # as percentages
tot
3 4 5 6 7 8 9 10 11 12 13
0.077 0.309 0.772 1.620 2.932 4.784 7.022 9.414 11.420 12.886 13.272
14 15 16 17 18
12.346 10.108 7.253 4.167 1.620
expand.grid to replace the first four lines of your code.
– cardinal
Jun 17 '12 at 13:25
p <- tabulate(apply(gtools::permutations(6,4, repeats.allowed=TRUE), 1, FUN=function(x) sum(sort(x)[-1]))) / 6^4 yields the probability distribution all at once.
– whuber
Jun 19 '12 at 00:38
Each roll has a uniform distribution on $\{1, 2, 3, 4, 5, 6 \}$ and to get the distribution for the minimum you can use $P[m>k] = {\rm probability \ that \ all \ four \ rolls \ are \ } >k$ and by independence this is the probability that each roll is $\geq k$ raised to the fourth power where $m$ is the minimum of the 4 rolls. Now for each roll $P[X>k] =(6-k)/6 = 1 - k/6$ So $P[m>k] = (1-k/6)^4$ and therefore $P[m<=k]=1 - (1-k/6)^4$.
From this we get $P[m=k]=P[m \leq k]-P[m \leq k-1]$ - knowing that $m=k$ means that the smallest of the three in the sum you calculate is at least $k$.
Let $S$ be the sum of the three highest rolls. You want $P[S=k]$ for $k=3,...,18$. You can calculate this as $P[S=k]=∑_{j=1}^{6} P[S=k|m=j] P[m=j]$. Note that for a variety of $k$s and $j$s $P[S=k|m=j]=0$. For example $P[S=3|m=k]=0$ for $k=2,3,4,5,6$. Of course once you determine $P[S=k]$ for $3 \leq k \leq 18$ you can calculate the mean and variance.