Recap: Dice Stall Odds
Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 18 of 64.
Challenge
MediumTime 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 starter simulated 2400 visits into first and second; the program reads a goal total. Print:
- the chance of doubles,
- the chance of the goal or more,
- that chance after doubles,
- 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.16Try 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
1Center and Spread
Mean and MedianPercentiles and QuartilesVariance and StdSample or Population?The Most Common ValueRecap: Delivery Times4Samples and Populations
Population and SampleSample Means VaryThe Sampling DistributionBigger Samples, Less NoiseRecap: Polling a Town2Distributions
Density HistogramsShapes of DataThe Normal CurveThe 68-95-99.7 RuleZ-ScoresRecap: Battery Life3Probability by Simulation
Probability as FrequencyThe Law of Large NumbersSums of DiceExpected ValueConditional ProbabilityRecap: Dice Stall Odds6Relationships
Reading Scatter PlotsCorrelationCorrelation MatrixCorrelation HeatmapsCorrelation Is Not CauseRecap: Ice Cream and SunPractice on your own: Online Python compiler