Jump to content
  • Advertisement
Sign in to follow this  
mousetail

formula for propibility

This topic is 2123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
  | 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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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. smile.png

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!