Menu
CoddyTech

Recap: Dice Stall Odds

Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 18 of 64.

challenge icon

Challenge

Medium

Time to price the school fair's dice stall. Each visitor rolls two dice: the total opens a prize box, and doubles (both dice alike) win a bonus ticket. tokens holds each box's tokens:

The prize boxes for the totals 2 to 12 as a row of cells: 12 tokens for 2 and for 12, 3 for 5 and for 9, 5 for 7, and 0 for every other total

The starter simulated 2400 visits into first and second; the program reads a goal total. Print:

  1. the chance of doubles,
  2. the chance of the goal or more,
  3. that chance after doubles,
  4. the expected tokens per visit, using each total's simulated share as its chance.

Chances to 3 decimals, tokens to 2. For another simulation and the goal 6:

Chance of doubles: 0.171
Chance of 6 or more: 0.705
Chance of 6 or more after doubles: 0.616
Expected tokens per visit: 2.16

Try it yourself

import numpy as np
import pandas as pd

goal = int(input())

# Tokens in the prize box for each total from 2 to 12, in order
tokens = np.array([12, 0, 0, 3, 0, 5, 0, 3, 0, 0, 12])

# Don't change the lines below: 2400 simulated visits, two dice each
rng = np.random.default_rng(18)
first = rng.integers(1, 7, size=2400)
second = rng.integers(1, 7, size=2400)

# Write your code below

All lessons in Statistics for ML

Practice on your own: Online Python compiler