Skip to content

Formulas as shortcuts

The t test is a shortcut for the pile of shuffles. See when the shortcut works, what it costs, and how to read a disagreement.

Introductory ~10 min9 steps

What runs in CodeSplash

You will be able to

  • Explain a reference distribution as a stand-in for a simulated null
  • Compare a simulated p-value with a formula p-value
  • Say what a disagreement between them tells you

Read first

01

Two routes to one answer

Read

You've built a p-value by shuffling. Before computers were cheap, nobody could shuffle 2,000 times. So statisticians worked out what the pile looks like: for a difference in means, it follows a t distributiont distributionA bell curve with heavier tails, for a statistic divided by a noise estimated from the data..

For tooth growth, the two routes give:

  • Shuffling: p = .066
  • Welch's t test: p = .061

They agree closely. The curve really is a good stand-in for the pile.

02

What does an outlier do?

Predict

Predict first

Add one extreme value to the second group. The shuffle and the t test both compare means. What happens to their p-values?

They stay close, and both changeThe t test changes, the shuffle doesn'tThe shuffle changes, the t test doesn't
Reveal

They stay close, and both change. Shuffling doesn't protect you here, because the outlier moves the mean, and the mean is what's being compared. To resist the outlier, change the statistic rather than the method.

03

See it

Explore

Turn on Add an outlier and compare Permutation p with Welch t p. Then switch Statistic to the median and see which number barely moves.

BExplorable · Permutation shuffler

Could a difference this large come from shuffling the labels alone?

Shuffle the labels a thousand times. How often will the shuffled difference be as large as the real one?

How sure?

Data

Statistic

+30 on the last value of the second group.

Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

04

Where the shortcut comes from

Read

Divide the signal by its estimated noise, and you get a statistic whose distribution doesn't depend on the unknown spread:

t=xˉ1−xˉ2s12/n1+s22/n2t = \frac{\bar x_1 - \bar x_2}{\sqrt{s_1^2 / n_1 + s_2^2 / n_2}}

Because the noise is estimated, tt varies more than a normal variable does, especially with little data. So small samples need a wider cut-off than 1.96.

05

Feel the small-sample penalty

Explore

Change Degrees of freedom and watch t critical (5%) approach the normal value.

BExplorable · t against z

Why do small samples need the t distribution instead of the normal?

Guess the two-sided 5% critical value of t for these degrees of freedom.

7.45
How sure?
4
1.96
±1.96

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

06

Try a shortcut that breaks

Explore

Shortcuts rely on large-sample theory, so they struggle where data are few. For counts, the normal curve can be badly off.

Find a count where the normal approximation says p < .05 and the exact test doesn't. Then turn on the break-it setting.

EExplorable · Exact test or normal approximation?

When can you trust the normal approximation to a binomial test?

What is the exact two-sided p-value here?

0.50
How sure?
20
0.10
5

Colored bars count toward the exact two-sided p: every outcome no more likely than the one you saw. The curve is the normal approximation.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

07

Check your reading

Checkpoint

Check yourself

A shuffle and a t test on the same data give p-values of 0.041 and 0.044. What should you conclude?

Show the answer

Answer: a

Small differences are normal: the shuffle has simulation noise, and the curve is an approximation. Choose your method before you see the results, and report that one.

Check yourself

A shuffle and a t test disagree badly in a small, skewed sample. What does that suggest?

Show the answer

Answer: b

A disagreement is information. Look at the shape of the data and which statistic answers your question.

08

Run both on your data

In the app

Run a t test and a permutation test on the same outcome and groups. If they agree, the shortcut is safe for these data.

09

Recap

Recap
  • A formula's reference distribution is a stand-in for a simulated pile.
  • When the two agree, the shortcut is working.
  • An outlier affects any method comparing means. To resist it, change the statistic.
  • Shortcuts fail most often with little data, especially with counts.

Concepts in this lesson