← Back to Simulations
Data: Titanic passenger records, grouped by class (1st/2nd/3rd) and survival outcome.

The contingency table

Each passenger falls into one of six bins: their class, crossed with whether they survived. If class and survival were independent, we'd expect each class's survival rate to match the overall rate. The expected table below shows exactly that — each row's total redistributed in proportion to the overall Yes/No split.

Observed vs. expected

1,317 passengers
Observed
Expected under independence

First class passengers survived far more than expected; third class far less.
The \(\chi\) statistic below sums how far every cell strays from its expected value:

\[ \chi = \sum \frac{|\text{observed} - \text{expected}|}{\text{expected}} \]

Testing it: the Big Deck method

The idea. If class truly didn't matter, then survival cards should be given out independently of class. We simulate this independence by pooling every outcome into one Big Deck (500 survived cards, 817 did-not cards), shuffle the deck, then deal it out into the 3 classes, same sizes as before (324/284/709). Recompute X for that deal. Do that thousands of times and we get the distribution of X we'd see from pure chance alone.

Big Deck shuffle test

Classes fixed, survival shuffled

Each shuffle keeps every class's passenger count fixed and randomly reassigns who survived, producing one draw from the null distribution of X.

Form the Big Deck stacks all 1,317 real passenger cards (gold = survived, red = did not) vertically, then visibly shuffles them. Shuffle and deal, count each pile deals that same real, shuffled deck into the 3 classes, keeping their real sizes, and counts what landed where — the exact deal used for the histogram below.

Pseudo-observed (Oi)
for the shuffled deck:

Expected (E):

Mt. Fuji: how far outside chance?

Each colored bar is a class's actual number of survivors. The gray band is the 99% insignificance band — the range of survivor counts that pure chance produces for that class. A bar that pokes out past its own gray band is a result that chance alone struggles to explain.

Survival count vs. chance

Gray band: 0.5th–99.5th percentile of that class's survivor count across all shuffles run here.