t-Tests on a Galton board
Each cart represents one population. Its horizontal position is the actual mean, \( \mu_A \) or \( \mu_B \). The balls released from a cart are observations, \( X_{A1}, \ldots, X_{An} \) and \( X_{B1}, \ldots, X_{Bn} \).
The pin wall is a physical model of random sampling error. At each row, a ball is nudged left or right. If there are \( R \) rows and the left/right chances are roughly equal, the number of rightward moves is approximately \( Y \sim \mathrm{Binomial}(R, 1/2) \). After centering, this binomial distribution is well approximated by a normal distribution when \( R \) is large.
Adding more rows increases the spread. In the ideal binomial model, \( \mathrm{Var}(Y) = R p(1-p) \), so with \( p = 1/2 \), the variance is \( R/4 \) in step units. In the simulation, dragging the lower edge of the pin wall changes \( R \), so it changes the actual variance of the observations.
The bins show the empirical sample distributions after the observations have been drawn. The statistics panel compares the actual means and variance implied by the setup with the empirical means \( \bar X_A, \bar X_B \) and sample variances \( s_A^2, s_B^2 \) produced by the released balls.
- The null hypothesis is \( H_0: \mu_A = \mu_B \): the carts are in the same position.
- The alternative is \( H_1: \mu_A \ne \mu_B \): the carts are in different positions.
The t statistic asks whether the observed distance between the two sample means is large relative to the sampling variation:
\[ t = \frac{\bar X_A - \bar X_B} {\sqrt{s_A^2/n_A + s_B^2/n_B}}. \]
The p-value is the probability, assuming \( H_0 \) is true, of seeing a t statistic at least this extreme:
\[ p = 2\,\Pr\!\left(T_\nu \ge |t| \mid H_0\right). \]
A small p-value means that the released balls would be surprising if the two carts truly had the same mean position. In Guess mode, the carts are hidden so you can experience the same inferential problem directly: decide whether a visible difference in samples is just random noise or evidence that the carts were positioned differently.