Dice Probabilities

Probabilities of the sum results from rolling n dice with s sides.

View the Project on GitHub carlosvega/DiceProbabilities

Dice Probabilities

Probabilities of the sum results from rolling n dice with s sides

The problem statement reads:

Given a certain number d of dice and a number n of throws, write a function that plots the distribution of the sum of the dice (i.e. an histogram of how many times a particular sum occurs).

The solution is based on the two following articles, in which they use the solution shown in the book Introduction To Mathematical Probability (mirror) by James Victor Uspensky in pages 14 to 26 with the following formula depicted in page 24.

Formula

References

The code

The MATLAB code spans 3 files. The code is just quick scratch wibbly wobbly wimey stuff, so please, don’t blame me. 😇

Formula 2nd version

A version in Python can be found in the following Jupyter Notebook from the interactive plot.

The MATLAB version prints a PDF such as this. Careful with big number of dice and the xticks.

Matlab result example