• Create Account

# formula for propibility

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1mousetail  Members   -  Reputation: 717

Like
0Likes
Like

Posted 25 September 2013 - 07:15 AM

Is there a easy formula to find how much chance there is for a particular number to be rolled by 2 dice, I just want to be able to put them in order.

### #2Álvaro  Crossbones+   -  Reputation: 8104

Like
2Likes
Like

Posted 25 September 2013 - 08:10 AM

  | 1  2  3  4  5  6
--+-----------------
1 | 2  3  4  5  6  7
2 | 3  4  5  6  7  8
3 | 4  5  6  7  8  9
4 | 5  6  7  8  9 10
5 | 6  7  8  9 10 11
6 | 7  8  9 10 11 12                                                                                                                                      

The probability of rolling K is the number of times K appears in that table divided by 36 (the number of entries). If you want a formula, it's the coefficient of x^K in the polynomial (x*(1-x^6)/(1-x)/6)^2.

Edited by Álvaro, 25 September 2013 - 08:10 AM.

### #3Paradigm Shifter  Crossbones+   -  Reputation: 4064

Like
3Likes
Like

Posted 25 September 2013 - 09:43 AM

A simpler to understand method/pseudocode is probably this:

Probability of rolling x:

if( x < 2 || x > 12) p(x) = 0

else if(x <= 7) p(x) = (x-1) / 36

else p(x) = (13 - x) / 36

due to the triangular shape of the distribution, centred on 7.

EDIT: I assume you are summing the dice values, as does Alvaro. If you want a formula for the chance of rolling a particular number at least once when you roll 2 dice, it is 11/36 (draw a diagram like Alvaro's, each number appears 6 times in its row and column, but rolling a double is one possibility out of 36, not 2). So the probability is:

(6 + 5)/36

Probability of rolling a given number exactly once is 10/36, since that doesn't include the 1/36 chance for rolling the number as a double.

Edited by Paradigm Shifter, 25 September 2013 - 09:55 AM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #4Álvaro  Crossbones+   -  Reputation: 8104

Like
3Likes
Like

Posted 25 September 2013 - 09:59 AM

Here's some code that computes the probabilities. It works for any number of dice.

#include <iostream>

const int dice = 2;

int main() {
double probability[6*dice+1] = {1.0};
for (int die=1; die<=dice; ++die) {
for (int k=6*die; k>=0; --k) {
double sum = 0.0;
for (int roll=1; roll<=6 && roll <= k; ++roll)
sum += probability[k-roll] * (1.0/6.0);
probability[k] = sum;
}
}

for (int i=dice; i<=6*dice; ++i)
std::cout << i << ' ' << probability[i] << '\n';
}

Edited by Álvaro, 25 September 2013 - 10:00 AM.

### #5jbadams  Senior Staff   -  Reputation: 12221

Like
1Likes
Like

Posted 26 September 2013 - 04:57 AM

You might enjoy the article "Probability and Games: Damage Rolls", which discusses modelling traditional table-top dice rolls in some level of detail and provides graphics, interactive diagrams, and some short code snippets.  In particular, the histograms presented very early in the article (along with the accompanying explanation of course!) are directly relevant to your question.