Monte Carlo simulations power DartCannon, but it can be difficult to develop an intuitive understanding of how it works. Using dice, we're going to walk through running a simulation by hand so you can develop a sense for how it all works.

The Goal

What is the most likely outcome from rolling two dice?

Chances are you know the answer, but we're going to walk through the Monte Carlo method of getting the answer.

The Approach

At its simplest, Monte Carlo approach is easily stated:

Run a test many times and count the results

The idea underlying this is instead of doing 'complex' analysis, we just repeat an activity and then count. Once we have our counts, it is easy to do some basic statistics to get other pieces of information.

Applied to our dice example, we're going to roll two dice a lot (more on 'a lot' later) and count up how many times each total comes up.

🎲 Rolling Dice

Lets start by rolling a pair of dice 30 times:

βšƒβš€ βšβš‚ βš„βšƒ βšβš„ βš…βšƒ βš„βš βš€βš βšβš… βš„βš„ βš…βš‚ βšƒβš„ βš€βš… βšβš‚ βš„βš βšβš… βš‚βš‚ βšƒβšƒ βš„βš βšƒβš… βšβš„ βšβš… βš…βš„ βšβšƒ βš„βš… βš€βš… βš‚βš βš„βš€ ⚁⚁ βš€βš‚ βšβš€

And count how many times each total came out:

Results of 30 rolls

Looks good? Maybe?

While in this case we know that while we got the peak in the correct spot (7) and the general shape looks right, it should be a smoother triangle. This is where the question of how many times we need to roll our dice comes into play.

How Many Rolls?

We can repeat our simple experiment with increasing number of rolls. Plotting the result, we can see that the more rolls, the smoother the output.

Results of 30 - 1k rolls

Perhaps more importantly, if we repeat the process, the more runs, the more 'stable' the results. With 30 rolls, the results can change wildly between tests while with 1,000 they largely stay constant.

This is true even of the simplest possible case. Before the advent of modern computers, one of the famous tests of large numbers was from John Kerrich who, while imprisoned during World War 2, had the time to flip a coin 10,000 times.

Penny flip results

You can see it takes 1,000+ flips for the result to start to stabilize at 50%. Rolling a dice is more complicated and the simulations you need for a business decision is far more complicated.

So why not run as many simulations as we can every time? The trade-off is in time. As complexity goes up, the amount of time needed for a single simulation (or roll or flip) goes up. A good way to find how many runs you need for a given simulation is to ask yourself what questions you're trying to answer and what degree of precision you need to answer them.


Understanding Monte Carlo methods isn't necessary to use DartCannon but getting the basics down will help you better interpret the results and make more informed decisions.

Photo by Lea BΓΆhm on Unsplash