Comments on: How do I calculate the probability of a specific sum of repeated die rolls?
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls/
Comments on Ask MetaFilter post How do I calculate the probability of a specific sum of repeated die rolls?Fri, 28 Sep 2012 22:16:58 -0800Fri, 28 Sep 2012 23:15:41 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: How do I calculate the probability of a specific sum of repeated die rolls?
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls
I'm looking to learn how to calculate probabilities for a multi-round dice game. I've researched this question some, and it looks like I might need to know how to use the multinomial distribution, but I can't find any good introductions. Please point me to the most layman-accessible educational material on this subject, and help me to help myself. <br /><br /> The game I'm playing can be abbreviated like this:<br>
<br>
I roll two six sided dice and add them.<br>
I then subtract a (fixed) penalty value, and score as many points as remain.<br>
I cannot score less than 0. If I would score less than 0 points, I score 0 instead.<br>
I repeat this process several times, without altering the penalty between rolls.<br>
<br>
How do I predict the probability of any 1 particular cumulative score?<br>
I am not interested in simulating this event and taking a random sample; I want to calculate all possible outcomes and their precise probabilities. Examples follow:<br>
<br>
<br>
Example #1:<br>
My penalty value is 0, and I repeat the die roll 36 times.<br>
Each roll will produce a number between 2 and 12 inclusive, and my final score will be between 72 and 432. What is the chance that I will score 7 points exactly 6 times.<br>
<br>
Example #2:<br>
My penalty value is 11, and I repeat the procedure 40 times.<br>
Each roll will produce a value between 0 and 1 inclusive, and my final total score will be between 0 and 40, and likely closer to 0 than 40.<br>
I wish to predict the chance that I will score a cumulative total of exactly 2 points across the sum of all 40 trials.<br>
<br>
Example #3:<br>
My penalty value is -5, and I repeat the procedure 5 times.<br>
Each roll will produce a value between 7 and 17 inclusive (negative penalty). I wish to plot the probability of a arriving at each possible total: 35 through 85. <br>
<br>
Again, I think maybe this is a case of the muiltinomial distribution, but everything I can find about it (wikipedia) is confusing and not written as educational but as reference material. <br>
<br>
I'm familiar with MS Excel and have a basic Liberal Arts understanding of calculus and probability/statistics, though I'm quite rusty. I'm willing to re-learn what I have forgotten, and also to learn new skills - within reason. If this procedure requires me to learn lots of new math, I would appreciate links or book titles to pursue as well as a general outline of what the fields of study are called, and what I'll need to know to pursue them intelligently (i.e. help me ask questions without sounding ignorant/clueless). <br>
<br>
I gather that the program R might be helpful in this, so please feel free to recommend a good introduction to both R and Statistics.<br>
<br>
Thanks for any help you're able to give!post:ask.metafilter.com,2012:site.225560Fri, 28 Sep 2012 22:16:58 -0800Richard DalyprobabilitystatisticsdiedicegamegamespointpointsmathmultinomialmultinomialdistributiondistributioneducationmathspenaltypenaltiesBy: Nomyte
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls#3263908
<em>Example #1:<br>
My penalty value is 0, and I repeat the die roll 36 times.<br>
Each roll will produce a number between 2 and 12 inclusive, and my final score will be between 72 and 432. What is the chance that I will score 7 points exactly 6 times.</em><br>
<br>
Ugh, dice.<br>
<br>
The probability of getting a sum of 7 on two dice is the probability of getting any of (1,6), (2,5), (3,4), (4,3), (5,2), or (6,1). So, 6 out of 36 combinations of two dice lead to a sum of 7, for a probability of 1/6.<br>
<br>
You want to score 7 (each time at 1/6 probability) exactly 6 times and not 7 (each time at 5/6 probability) the remaining 30 times.<br>
<br>
How many ways of arranging 6 of one thing and 30 of another thing are there? It's 36!/(6! * 30!) = 34*33*31*8*7 ways, which is a rather big number.<br>
<br>
So the answer is the probability of getting a sum score of 7 six times, multiplied by the probability of getting another score 30 times, multiplied by the number of ways this combination of events can occur:<br>
<br>
(1/6)^6 * (5/6)^30 * (34*33*31*8*7) ≈ 0.176<br>
<br>
A program like R will come in handy for calculating these large numbers.comment:ask.metafilter.com,2012:site.225560-3263908Fri, 28 Sep 2012 23:15:41 -0800NomyteBy: Nomyte
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls#3263910
<em>Example #2:<br>
My penalty value is 11, and I repeat the procedure 40 times.<br>
Each roll will produce a value between 0 and 1 inclusive, and my final total score will be between 0 and 40, and likely closer to 0 than 40.<br>
I wish to predict the chance that I will score a cumulative total of exactly 2 points across the sum of all 40 trials.</em><br>
<br>
Why am I doing this?<br>
<br>
Anyway, the probability of getting a score of 1 in this case is the same as getting (6,6) on two dice, or 1/36. The probability of getting a score of 0 is 35/36.<br>
<br>
You want two instances of the 1/36-chance event and thirty-eight instances of the 35/36-chance event.<br>
<br>
Again, how many ways are there of arranging 2 of one thing and 38 of another? It's 40!/(2! * 38!).<br>
<br>
So your answer in this case is (1/36)^2 * (35/36)^38 * 40!/(2! * 38!) ≈ 0.206.comment:ask.metafilter.com,2012:site.225560-3263910Fri, 28 Sep 2012 23:29:15 -0800NomyteBy: Nomyte
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls#3263911
Example #3 is left as an exercise for the reader.comment:ask.metafilter.com,2012:site.225560-3263911Fri, 28 Sep 2012 23:29:21 -0800NomyteBy: ceribus peribus
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls#3263955
Nomyte has answered already, and it's a fine answer that I don't disagree with. But I worked all of the following out already, and am posting in the spirit of "sometimes it takes two different explanations before understanding sets in". Apologies if I end up over explaining some of the steps. <small>In retrospect, I hope this isn't homework.</small><br>
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
<br>
Okay. All of your examples are essentially the same calculation, with different values and number of repetitions. <br>
<br>
Your problem is indeed a multinomial distribution problem. There's a fairly accessible description/example of this formula on <a href="http://stattrek.com/probability-distributions/multinomial.aspx">this page</a>.<br>
<br>
The multinomial formula is: P = [N!/(n1!*n2!...nk!)] * [(p1^n1)*(p2^n2)...*(pk^nk)], as you can see from that web page. You just have to figure out what n's and p's to plug in for each of your questions. <br>
<br>
Your standard trial is going to be a roll of two dice. You know that the result will be between 2 and 12, with the following probability: <br>
<pre><br>
n1 = 2 === 1/36 for p1<br>
n2 = 3 === 2/36 for p2<br>
n3 = 4 === 3/36 for p3<br>
n4 = 5 === 4/36 for p4<br>
n5 = 6 === 5/36 for p5<br>
n6 = 7 === 6/36 for p6<br>
n7 = 8 === 5/36 for p7<br>
n8 = 9 === 4/36 for p8<br>
n9 = 10=== 3/36 for p9<br>
n10 =11=== 2/36 for p10<br>
n11 =12=== 1/36 for p11<br>
/ Total 11 different possible outcomes<br>
</pre><br>
Above is the probability distribution function (aka pdf) of a double-roll before considering any penalty. <br>
The penalty simply changes the score from [2,12] to some other range. Start your answers by calculating the probability distribution for the penalty scenario of your question. If your penalty is going to combine several outcomes, figure that out at this point.<br>
<br>
For example, a penalty of -3:<br>
<pre> = 2-3 = 0 === 1/36<br>
= 3-3 = 0 === 2/36 Total for outcome "0" = 1/36+2/36 = 3/36<br>
So, n0 = 0 === 3/36 for p0<br>
n1 = 4-3 = 1 === 3/36 for p1<br>
n2 = 5-3 = 2 === 4/36 for p2<br>
n3 = 6-3 = 3 === 5/36 for p3<br>
n4 = 7-3 = 4 === 6/36 for p4<br>
n5 = 8-3 = 5 === 5/36 for p5<br>
n6 = 9-3 = 6 === 4/36 for p6 <br>
n7 = 10-3= 7 === 3/36 for p7<br>
n8 = 11-3= 8 === 2/36 for p8<br>
n9 = 12-3= 9 === 1/36 for p9<br>
/ Total 10 different possible outcomes<br>
</pre>Note that I've changed the numbering so that n4 and p4 are for the case where the score is "4", etc. It's easier to remember that way. <br>
<br>
Now, let's pick the n's and p's to plug into the multinomial probability formula. <br>
The value to use for N (just N by itself, not n1,n2,etc) in the formula is easy; that's the number of trials.<br>
<br>
What about the n1, n2,...nk for the formula? In order to figure that out, you have to determine which outcome cases you're interested in. There is no easy way to automate it; you have to figure these out based on what question you are asking. <u>Tip</u>: the n1...nk you use should add up to the value you use for N, or else you're doing it wrong. <br>
<br>
<u>Example 1:</u><br>
"What is the chance I will score 7 points six times" --- means you want outcome "7" to happen six times. <br>
So, the cases you are interested in are case 7, and case "anything other than 7". <br>
That first case means n7. We want n7 to happen six times, so we set n7=6 in the formula. Now we need p7. <br>
From your probability distribution, you see that p7 (for outcome "7") has a probability of 6/36.<br>
"Everything else" should happen the rest of the rolls, so n_other = 30. <br>
For the probability of "anything else", p_other, you can either add up n1,n2,n3... leaving out n7, or just recognize that because they all sum to 1.00, the probability of "every other outcome" is 1-p7, or 30/36.<br>
<br>
Plugging these into the formula, we get: <br>
<blockquote>P = [N!/(n7!*n_other!)] * [(p7^n7)*(p_other^n_other)]<br>
P = [36!/(6!*30!)] * [(6/36^6)*(30/36^30)]<br>
which I trust will work out to ~0.176, as Nomyte said. </blockquote><br>
<br>
<u>Example 2:</u><br>
"The chance of a cumulative total of exactly 2 points across the sum of all 40 trials"<br>
<br>
You've already figured out that on each roll (trial), you'll either get 0 or 1 points, so there is only outcome n0 and n1 to consider. You can figure out p0 and p1 fairly simply, too. <br>
N is obviously 40. <br>
Next, list all possible ways of getting exactly 2 points from a sum of 40 trials. <br>
<blockquote>That's pretty easy, yes? It only happens if we get the single point outcome twice.</blockquote><br>
So, this gives the n0, n1 for the desired number of instances: n0=38, n1=2. <br>
Putting this into the formula, we get: <br>
<blockquote>P = [40!/(38!+2!)] * [ (p0^38)*(p1^2)] </blockquote><br>
Which again, simplifies to the same formula and should work out to the same answer as when using Nomyte's method above. <br>
<br>
<u>Example 3:</u><br>
Five rolls, so N = 5<br>
Each roll gives a value from 7 to 17. Go ahead and prepare the pdf table giving n7...n17 and p7...p17. <br>
You want to know the probability of getting 35 through 85? That's actually 51 different questions, to be answered independently, one at a time. <br>
I'll walk you through a couple of them. <br>
<br>
<li>For the probability of getting 35, figure out what combinations of results for the five rolls will sum to 35: </li><br>
<blockquote>7,7,7,7,7 is the only possibility. <br>
That means five results of 7, and 0 results of anything else. <br>
So you only have to use n7=5, and p7 in the multinomial distribution formula. </blockquote><br>
<li>For the probability of getting 40, figure out what combination of outcomes sum to 40:</li><blockquote>It turns out there are seven possible ways to get sums of 40: <br>
12,7,7,7,7=== one n12, four n7's <br>
11,8,7,7,7=== one n11, one n8, three n7's <br>
10,9,7,7,7etc<br>
10,8,8,7,7<br>
9,9,8,7,7<br>
9,8,8,8,7<br>
8,8,8,8,8<br>
For each of these seven ways above, figure out the N's and corresponding P's, plug them into the multinomial formula to get the probability of getting 40 <i>that way</i>, and then sum those seven results to get the total probability of getting a sum of 40 from any of the possible ways. </blockquote><br>
<li>etc, etc for the other sums. You can probably find a creative use of excel to help you enumerate all possible ways of forming the sums.</li><br>
<br>
So, that is the method; no further probability theory necessary. The calculation is full of tedious mechanical repetition, making it a prime candidate for automating the steps in excel or a programming tool of your choice.comment:ask.metafilter.com,2012:site.225560-3263955Sat, 29 Sep 2012 03:11:05 -0800ceribus peribusBy: fleacircus
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls#3263964
Example 3 is just rolling 10 dice and adding 25, so you really just want the chances for various sums on 10 dice. There's <a href="http://en.wikipedia.org/wiki/Dice#Probability">formulas</a> for that. Or you can kind of dirtily/wonderfully use Excel like <a href="http://www.wikihow.com/Calculate-Multiple-Dice-Probabilities">this</a>. It's actually useful to understand how the Excel method works, and how you might change it for 4-sided dice, or dice with sides 0, 0, 0, 1, 2, 3 for example.<br>
<br>
Your examples skirt around what you'd have to do if your penalty was some interesting value like 4 so you roll 2 dice and subtract 4 each round. That would make you have to consider each round as a variable that can have different values with a non-flat distribution. With penalty 4 specifically your possible results would be (0, 1, 2, 3, 4, 5, 6, 7, 8) and the probabilities would be (6/36, 4/36, 5/36, 6/36, 5/36, ... , 1/36).<br>
<br>
In that case, calculating it can be pretty effectively done by a program using the recursive formula based on what the Excel trick above is doing. What is your chance of getting X over N rounds? Think of the final round. You've done N-1 rounds so far and have one more roll. For a given total, express the chances of getting that as what you got on the previous N-1 rounds along with the chance of what you got this round. For example to get to 22 on 10 dice, you could roll (1, 2, 3, 4, 5, 6) on the last roll and over the N-1 previous rolls you had (21, 20, 19, 18, 17, 16). you had 18 on N-1 trials and then you rolled a 4. Or maybe it was 17 and 5. Etc.<br>
<br>
Or just run a few million simulations to get an approximation and call it close enough.<br>
<br>
If you want (cougharesupposedtocough) use multinomials, well you could brute force out all possibilities of the N rounds (on a computer). Then for each possibility you calculate the sum and the probability of rolling that sum using the multinomial distribution formula, and add it to whichever pile as you go along. This is an inefficient way to do things but it's straightforward.comment:ask.metafilter.com,2012:site.225560-3263964Sat, 29 Sep 2012 04:01:21 -0800fleacircusBy: a robot made out of meat
http://ask.metafilter.com/225560/How-do-I-calculate-the-probability-of-a-specific-sum-of-repeated-die-rolls#3265009
Fwiw, you say that you aren't interested in simulation, but<br>
1) You should use simulation to check your answer as you learn probability arguments. Given the comparative complexity, you are much more likely to make a mistake in implementation of the exact calculation.<br>
2) as an applied problem, the calculation that you have to do to use the above for penalty greater than 2 will be microscopically faster (if at all) and perhaps less accurate (numerical issues when dealing with small and large numbers) than just simulating to get accurate probability estimates for all but rare events. <br>
<br>
For example, in R (which is a slowish but easy to write way to do this)<br>
set.seed(1)<br>
number_rolls = seq(from=36, to=43)<br>
penalty = 10<br>
number_simulations = 100000<br>
simulation_output <-list()<br>
for( i in number_rolls) {<br>
temp<-pmax(ceiling(runif(number_simulations*i)*6) + ceiling(runif(number_simulations*i)*6) - penalty, 0)<br>
simulation_output[[i]]<-table( colSums( matrix(temp, nrow=i) ) ) / number_simulations<br>
}<br>
cbind(simulation_output[[36]])<br>
<br>
0 0.04304<br>
1 0.09660<br>
2 0.14861<br>
3 0.16905<br>
4 0.16361<br>
5 0.13632<br>
6 0.09689<br>
7 0.06506<br>
8 0.03934<br>
9 0.02134<br>
10 0.01106<br>
11 0.00507<br>
12 0.00240<br>
13 0.00090<br>
14 0.00044<br>
15 0.00018<br>
16 0.00005<br>
17 0.00004<br>
<br>
cbind(simulation_output[[38]])<br>
[,1]<br>
0 0.03559<br>
1 0.08540<br>
2 0.13710<br>
3 0.16313<br>
4 0.16485<br>
5 0.13944<br>
6 0.10672<br>
7 0.07103<br>
8 0.04465<br>
9 0.02583<br>
10 0.01357<br>
11 0.00691<br>
12 0.00333<br>
13 0.00148<br>
14 0.00060<br>
15 0.00024<br>
16 0.00011<br>
17 0.00001<br>
18 0.00001comment:ask.metafilter.com,2012:site.225560-3265009Sun, 30 Sep 2012 10:19:00 -0800a robot made out of meat