JA EN
LearnProbability & Statistics
·★ MEMBER·10 min read

Hypothesis Testing and A/B Tests — How to Use a p-value, and How People Misuse It

Ship the identical page to two groups and the numbers still won't match. A hypothesis test converts that gap into 'how many units of noise is this?' — that number is the p-value. From the null hypothesis up through the three failures that actually ruin experiments: power, peeking, and multiple comparisons.

ModalitytextTaskmath

Your button change lifted clicks. Did it?

You ship two versions of a checkout button and split traffic evenly. A converts at 5.0%, B at 5.4% — a 0.4-point lift. Before you say "let's ship B" in the review meeting, there's one thing to check: two identical pages, given identical traffic, will not produce identical click rates.

Try flipping a fair coin 100 times, twice. Getting exactly 50 heads both times would be the surprising outcome. You get 48 and 53, or 45 and 52. Even when the two things being compared are literally the same, a gap appears. So the existence of a gap proves nothing at all. The question worth asking is not is there a difference but how often would a gap this large show up even if the two versions were identical?

A hypothesis test is the tool that answers that question with a number. The p-value is that answer.

The null hypothesis is a presumption of innocence

A test works by contradiction. You start by assuming the opposite of what you want to believe.

Then you compute how unusual today's data would be if H0H_0 were true. If it's unusual enough, you conclude the assumption was the problem and throw H0H_0 out.

Courtrooms work the same way. The defendant is presumed innocent, and is convicted only when the evidence would be absurd under that presumption. And an acquittal is not proof of innocence — it means the evidence wasn't strong enough to convict. Testing inherits this exactly: failing to reject H0H_0 is not proof that there is no difference. Confusing those two is the single most common mistake in practice.

Here is the definition:

p-value = the probability of observing a difference at least as extreme as the one you saw, purely by chance, assuming the null hypothesis is true.

Watch the direction of the conditioning. A p-value is "how surprising the data is, given H0H_0" — not "how likely H0H_0 is, given the data." p = 0.03 does not mean there's a 97% chance B is better. Getting from the first to the second requires a prior, which is exactly what Bayesian thinking does head-on.

Measuring how much noise wiggles

To judge "unusual," you first need a ruler for "how much does this wiggle by chance alone?" For a click rate p^\hat p estimated from nn visitors, that ruler is the standard error:

SE(p^)=p(1p)n\mathrm{SE}(\hat p)=\sqrt{\frac{p(1-p)}{n}}

Here pp is the true click rate and nn is how many people you measured. Put in words: a rate measured on n people jitters by roughly this much every time you measure it. The width shrinks with the square root of nn, which is a brutal exchange rate — halving your error bar costs four times the traffic. (That same 1/n1/\sqrt{n} crawl is why Monte Carlo methods converge so slowly; it's the same root cause.)

Express the observed gap in units of that ruler and you have the test statistic:

z=p^Bp^Apˉ(1pˉ)(1nA+1nB)z=\frac{\hat p_B-\hat p_A}{\sqrt{\bar p\,(1-\bar p)\left(\frac{1}{n_A}+\frac{1}{n_B}\right)}}
(1)

The numerator is the gap you actually saw. The denominator is how large that gap typically gets by chance when H0H_0 holds. pˉ\bar p is the click rate pooled across both groups — under H0H_0 they share one true rate, so you estimate it jointly. Equation (1) is therefore doing one thing only: counting how many units of noise your gap is worth. Once z|z| passes roughly 1.96, the two-sided p-value drops below 0.05.

Why 1.96? Under H0H_0, zz approximately follows the standard normal distribution — the bell curve with mean 0 and standard deviation 1 — and 95% of that curve sits between ±1.96\pm 1.96. The familiar "two-sided 5%" is just the line that trims 2.5% off each tail. And there is nothing natural about 5%: it's an early-20th-century convention that being fooled one time in twenty is tolerable. The threshold is yours to move to fit the stakes. What you may never move is the threshold after you've looked at the data.

From here on it's not about usage — it's about misuse

That's a textbook chapter's worth of material. But what actually breaks experiments in the field is not arithmetic on that formula. It's looking at the data first, and only then choosing the convenient slice, the convenient stopping point, the convenient metric. This isn't really a statistics-specific disease. It's the shape every ML practitioner already knows: the harder you fit what's in front of you, the worse you do in production.

FIG 1Raise the polynomial degree and training error keeps falling while test error climbs. Choosing how to run your test after seeing the data has the same structure — every bit you fit to this sample's noise is a bit that won't reproduce

There are two ways to be wrong.

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

Comments

Sign in to comment