Lesson 1 — Adding up coin flips until a bell appears

BIO 202, Spring 2026 — draft v1. Build the bell from coin flips. Discover that the mean is the best constant prediction when you have no other information. Meet the formula y ~ Normal(μ, σ) at the end and see that it is just what you have been doing the whole time.

What this lesson is asking

When you do not know the answer, what is your best single guess, and how wrong will you typically be? Build the answer four ways: coins, simulated heights, a head-to-head between two predictors, and finally a real dataset.

A — Flip a coin, 20 times. Three rounds.

Pick a number. Flip 20 coins. See how close you got. Do it three times.

Locked — confirm your name above to unlock this section.

What to do

Pick how many heads you expect, on the right. Then click Flip Coin until you have flipped 20. Three rounds; the running tally below tracks how close you were each time.

Number of heads

flips so far: 0 / 20  |  heads: 0

A guess of 10 counts as ✓ only when 10 heads actually come up. That happens about 1 round in 6. Watch what's happening to your guesses themselves across the three rounds even when individual rounds come up ✗.

Round 1 of 3

Prediction

How many heads do you expect to see in 20 single coin flips?

Controls

42

R code

set.seed(42)flips <- rbinom(20, size = 1, prob = 0.5)sum(flips)   # count of heads

Pause — what your "error" looked like

How far off each round's prediction was from the actual heads count.

Complete Stage A to unlock this section.

Your three rounds

RoundYou predictedHeads observedOff by

Average error across 3 rounds:

That last column — how far off each prediction was — is the error. The number underneath it is your average error across the three rounds.

A good predictor doesn't hit zero on every single try (luck of the draw still bites). What it does is land with an average error near zero — being too high about as often as too low. Stage B turns this into a running tracker.

B — Guess a person's height

Real human heights. Get the average error low across 30 or more draws to move on.

Complete Stage A to unlock this section.

What to do

Pick a single guess (in centimeters) for the height of a random adult. Click Draw to pull one. Repeat. If your average error across 30 draws ends up low — close enough to zero — you move on. If not, the page resets.

Heights you have drawn so far

your guess:  |  draws so far: 0 / 30  |  overestimated: 0  |  underestimated: 0  |  average error:

Controls

cm

R code

# 30 random adult heights from real data.nh <- read.csv("data/clean/nhanes_adults.csv")set.seed(7)truths <- sample(nh$Height, 30)guess <- ___    # type a value; aim for an average error near zeromean(guess - truths)

C — Naming the pieces, on real data

Two numbers behind everything you have done so far.

Complete Stage B to unlock this section.

What to do

Click Draw one adult. Each click pulls one real NHANES height and adds its distance from the population mean to the second plot.

NHANES adult heights — the whole population

μ (best constant guess): cm  |  σ (typical distance from μ): cm

Your draws — distance from μ

draws: 0  |  average signed error:  |  typical |error|:

Prediction

In Stage B you found the height that made your average error fall toward zero. That number has a name. Which is it?

Take 30 draws to wrap up. 0/30 draws

Controls

What the plots are showing

Top: the whole adult population. The solid red line is μ — the same number your Stage B average error settled around. The shaded band is ± σ — a typical distance any single adult sits from μ.

Bottom: the error of each draw (truth − μ). After enough draws, this distribution has width σ, centered at zero.

yi ~ Normal(μ, σ)

R code

nh <- read.csv("data/clean/nhanes_adults.csv")y <- nh$Heightmean(y); sd(y)   # μ and σ from real datahist(y, breaks = 40, freq = FALSE, col = "gray85", border = "white")abline(v = mean(y), col = "#b23a48", lwd = 2)abline(v = mean(y) + c(-1, 1) * sd(y), col = "#b23a48", lty = 3)

Stretch challenge (optional)

Open the downloaded .R and change nh$Height to nh$Weight. Compute μ and σ on weights. Compute the median as well. Which one — mean or median — is closer to "typical weight"? Plot both as vertical lines on the histogram.

Not yet attempted.