Simulation and Modeling

Simulating Dice Rolls in a Spreadsheet

Set up a two-dice experiment in a spreadsheet with RANDBETWEEN and COUNTIF, build a frequency table, and compare results with the exact probabilities.

On this page
  1. Why a spreadsheet works
  2. Step 1: simulate one die
  3. Step 2: add a total and fill down
  4. Step 3: build a frequency table
  5. Step 4: compare theory and experiment
  6. Why the numbers keep changing
  7. Running the experiment more than once
  8. Checking whether your dice are fair
  9. Common problems

Why a spreadsheet works

You do not need to write code to run a simulation. Any common spreadsheet program can generate random numbers, apply a rule to them and count the results. That makes it a friendly place to see random variation for yourself, and a good way to check an answer you worked out by hand.

This walkthrough builds a two-dice experiment. The function names below are the ones used in Excel and Google Sheets, and other spreadsheet programs have close equivalents.

Step 1: simulate one die

Put a heading “Die 1” in cell A1 and “Die 2” in B1. In A2 enter:

=RANDBETWEEN(1,6)

This returns a whole number from 1 to 6, each with equal chance. An equivalent that works in older programs is =INT(RAND()*6)+1. RAND gives a decimal from 0 up to but not including 1; multiplying by 6 stretches it to the range 0 up to 6, INT drops the decimal part to give 0 to 5, and adding 1 shifts to 1 to 6. If you ever need a different die, change the 6 to the number of sides.

Copy the same formula into B2 for the second die.

Step 2: add a total and fill down

In C1 write “Total” and in C2 enter =A2+B2. Now select A2:C2 and drag the fill handle down to row 1001. You now have 1,000 simulated rolls of two dice. Each row is independent of the others, which is exactly what a fair-dice experiment needs.

Step 3: build a frequency table

In column E list the possible totals 2 through 12 starting in E2. In F2 enter:

=COUNTIF($C$2:$C$1001,E2)

and fill down to F12. Column F now shows how many times each total occurred. In G2 convert to a proportion with =F2/1000 and fill down.

For comparison, add a column H with the exact number of ways to make each total out of 36 equally likely combinations. These are 1, 2, 3, 4, 5, 6, 5, 4, 3, 2 and 1 ways for totals 2 through 12, adding to 36. Column I then holds =H2/36, the theoretical probability.

For example, the total of 7 can happen six ways (1+6, 2+5, 3+4, 4+3, 5+2, 6+1), so its probability is 6/36, about 0.167. This is why seven is the most common total of two dice, a pattern covered in more detail in the article on two-dice sums.

Step 4: compare theory and experiment

With 1,000 rolls you expect about 167 sevens (1,000 divided by 6, rounded). You will not get exactly 167. The typical wobble in a count like this is the standard deviation, the square root of 1,000 × (1/6) × (5/6), which is about 11.8. So counts anywhere from roughly 155 to 179 are completely ordinary. A result of 140 or 200 would be unusual and worth a second look.

Try the same comparison for totals 2 and 12. Each has probability 1/36, so you expect about 28 of each in 1,000 rolls, with a wobble of about 5. The rare totals show proportionally bigger swings, a reminder that small counts are noisy.

Why the numbers keep changing

RAND and RANDBETWEEN are volatile functions: the spreadsheet recalculates them whenever anything on the sheet changes, and on a manual recalculation command. That means your results will shift each time you edit a cell. This is useful for rerunning the experiment, since every recalculation is a fresh 1,000-roll trial.

To keep one run, select the dice columns, copy them, and paste as values only. The formulas turn into fixed numbers, so the COUNTIF table stops changing and you can study a single result. Keep a copy with live formulas to rerun.

Running the experiment more than once

A single run teaches the most when you compare it with others. Recalculate several times and write down the count of sevens each time. You might see numbers scattered around 167 without ever matching it exactly. That spread is what random variation looks like.

Then try different sizes. With 100 rolls the proportion of sevens will bounce around widely; with 10,000 rolls it will sit much closer to 0.167. The link between how many rolls you run and how tight the result gets is the subject of simulation trials, and it is the same square-root pattern as in any Monte Carlo simulation. Expanding to many thousands of rows is easy, though very large sheets recalculate slowly.

Checking whether your dice are fair

The same setup can be turned into a test of a physical die. Roll a real die 120 or so times, type the results into a column and use COUNTIF to count each face. For a fair die each face has an expected count of one sixth of the total. A real-life check is covered under dice fairness, but the principle is the same: compare the counts to what chance alone would produce, allowing for the natural wobble.

Common problems

  • Counts do not add up to 1,000. Check that the COUNTIF range matches the fill-down range exactly.
  • Totals look off. Make sure both dice use RANDBETWEEN(1,6) and the sum cell refers to the right row.
  • Sheet seems frozen. Very large formulas can slow recalculation. Reduce the row count or paste values.
  • Results seem to favor some numbers. Small samples often look uneven. Increase the rolls before suspecting the formula.

A spreadsheet will not replace a full programming environment for complicated games, but for dice, coins and simple events it is quick, visual and good for building intuition about how randomness behaves. As with any simulation, results are estimates that vary from run to run.

The complete guide to simulation and modeling

Monte Carlo Simulation for Game Odds: A Starter Guide
Read the guide

Keep exploring

Guides from other topics

All topics →