Reading an A/B test on conversion

90 min6 partsCoreFundamentalsChecked Nov 2026
Start the lessonShort steps, each with something to do
What you'll learn
  • Check the split for a sample ratio mismatch before you read any metric
  • Run the two-proportion z-test with the pooled standard error, build the interval with the unpooled one, and say why they differ
  • Compute a two-sided p-value and a confidence interval at the same alpha, with only the standard library
  • Say the lift in points and as a percent, and tell a significant result from one worth shipping
  • Turn a result into a launch call, including what to say when p = 0.04 on day 2 of a 14-day test
  • Answer the follow-ups on peeking and sequential tests, many metrics, novelty effects, guardrails and heavy-tailed revenue
Part 1 of 6about 13 min
The split

A two-proportion test, from counts to a launch call

One OpenAI senior data scientist candidate reports a take-home that asked how you'd define success metrics and decide whether the launch was a success (1 report). Airbnb asks it in other words: a prep site lists Airbnb screens that say "Recommend whether to launch based on an experiment you design" (1 source), and that ask you to design and then analyze an experiment for a luggage locker feature (1 source). Our version reads like this:

We split users at random between the current page, A, and a new one, B. A converted 200 of 2,000 users, and B converted 250 of 2,000. Write two_proportion_test(conv_a, n_a, conv_b, n_b, alpha=0.05, share_b=0.5). Return B's rate minus A's, the z statistic, a two-sided p-value, a 1 - alpha confidence interval for the gap, and whether the split itself missed its plan. Then tell me: do we launch?

The practice comes in four levels, each one a key in the dict the function returns. Level 1 returns diff, B's rate minus A's, and z, with the standard error the null predicts. Level 2 adds p_value, two-sided. Level 3 adds ci, the interval, with each group's own standard error. Level 4 adds srm, which flags a split that missed share_b, the share of users the plan sent to B.

You don't write it yet. The lesson reads a test in the order you'd read a real one: check the split, ask what chance alone could do, build the test and the interval, then make the call and answer the follow-ups. At the end you solve the whole problem, level by level, in an interview simulation with a 35-minute timer.

The sample-size lesson comes next. It plans a test before it runs: how many users the test needs to detect the lift you care about.

An A/B test asks whether a gap is bigger than chance could make

The practice hands you two conversion rates. Before any formula, guess what chance alone could do to them.

Predict

A converts 10.0% and B 12.5%, on 2,000 users each. Could chance alone make a gap this big?

Pick an answer above to see the rest

Check the split before you read any metric

Before you compare the rates, check that the groups are still the ones randomization made. A broken split leaves them unalike.

One way a split breaks (an example)Interactive
users assigned to B.

Randomization promises a ratio, usually 50/50. Sometimes the user counts miss it by more than chance allows. Then something added or removed users on one side: a bug that crashes the treatment on one browser, a redirect that loses people, bot filtering that hits one variant harder.

The users who went missing aren't random. Here B lost its old-browser users and A kept them, so every metric comparison inherits the bias. That's a sample ratio mismatch, or SRM: a split that misses its planned ratio by more than chance allows.

Fabijan and colleagues studied it across four companies, including Microsoft and Booking.com. They put it bluntly: "Sample Ratio Mismatch in most cases completely invalidates experiment results." They found one in "approximately 6% of experiments at Microsoft".

In the editor, users_a and users_b count each group's users by browser, the way a dashboard splits them. Write where_missing(users_a, users_b): the browser where B is shortest against A, which is where to look for the bug.

How far off is too far?

A whole browser gone from B is easy to spot. Most broken splits are subtler, so the check has to say how far off is too far.

from math import sqrt
from statistics import NormalDist

def srm_p_value(n_a, n_b, share_b=0.5):
    n = n_a + n_b
    z = (n_b - n * share_b) / sqrt(n * share_b * (1 - share_b))
    return 2 * (1 - NormalDist().cdf(abs(z)))

for n_a, n_b in [(520, 480), (50_600, 49_400), (821_588, 815_482)]:
    share = max(n_a, n_b) / (n_a + n_b)
    p = srm_p_value(n_a, n_b)
    print(f"{n_a:>7,} vs {n_b:>7,}   "
          f"larger share {share:.1%}   p = {p:.2g}")
Predict

Which split is the real alarm: 52.0% of 1,000 users, or 50.6% of 100,000?

Pick one to see what it prints.
Pick an answer above to see the rest
Predict

The SRM check runs on every experiment. Why use a strict cutoff like p < 0.001 instead of 0.05?

Pick an answer above to see the rest
Part 1 done
Part 2 of 6about 21 min
Chance

The test asks how often chance alone makes a gap this big

With no real difference, the gap still moves from run to run. This code shows how far.

import random
from statistics import pstdev

rng = random.Random(1)
n, rate = 2000, 0.1125
gaps = [rng.binomialvariate(n, rate) - rng.binomialvariate(n, rate)
        for _ in range(100_000)]

share = sum(abs(g) >= 50 for g in gaps) / len(gaps)
print(f"spread of the gap: {pstdev(gaps) / n:.4f}")
print(f"gaps of 50 users or more: {share:.2%}")
Predict

Both pages convert at 11.25%, with 2,000 users each. How often does chance alone make a gap of 2.5 points or more?

Pick one to see what it prints.
Pick an answer above to see the rest

The gap's spread is its standard error

You don't need 100,000 runs to know how far the gap moves. One rule about variances gives it.

Predict

The variance of a difference of two independent estimates is what?

Pick an answer above to see the rest

The test and the interval use different standard errors

What's left is which rates to plug into the standard error. The two halves of the practice function answer that differently, because they ask different questions.

The test centers on 0, and the interval on your gap
0your gap
the test 95% of the gaps the null makes: -1.96 to 1.96
the interval your gap, give or take: 0.54 to 4.46
-3-2-1012345
points
  • The test asks: if both pages had one rate, how odd is a 2.5-point gap? Its curve sits on 0, the null's gap.
  • The interval asks: how big is the gap? It sits on the gap you measured, 2.5 points, and reaches out on both sides.

Each needs a standard error that fits its question.

The test's standard error comes from the null

Predict

Under the null hypothesis, how many conversion rates are there?

Pick an answer above to see the rest

The interval keeps each group's own rate

The interval measures the difference, so it can't assume the difference is zero. Each group keeps its own rate:

SE=p^A(1−p^A)nA+p^B(1−p^B)nB\text{SE} = \sqrt{\frac{\hat p_A(1 - \hat p_A)}{n_A} + \frac{\hat p_B(1 - \hat p_B)}{n_B}} (p^B−p^A)±z1−α/2 SE(\hat p_B - \hat p_A) \pm z_{1 - \alpha/2}\,\text{SE}

In words: this is the unpooled standard error, the variance formula with each group's measured rate. The interval is the gap, plus or minus a multiplier times that standard error.

α\alpha is the significance level, the false positive rate you accept, so α=0.05\alpha = 0.05 gives a 95% interval. z1−α/2z_{1 - \alpha/2} is the multiplier that leaves α/2\alpha/2 of the normal curve in each tail, 1.96 at that α\alpha. The next chapter computes it.

This is the Wald interval, the one the practice problem asks for.

In the editor, write unpooled_se(conv_a, n_a, conv_b, n_b): the interval's standard error, with each group's own rate.

CheckpointThe interval's standard error

Write unpooled_se(conv_a, n_a, conv_b, n_b), the standard error the interval uses, where each group keeps its own rate. On the 10% ramp, 1,000 of 10,000 against 120 of 1,000, it comes out larger than the pooled 0.01003, because the small group is the noisy one.

With equal groups and close rates, the two standard errors barely differ

You now have two standard errors for the same gap. Guess how far apart they are on the worked example.

Predict

Equal groups of 2,000, rates of 10% and 12.5%. How far apart are the pooled and unpooled standard errors?

Pick an answer above to see the rest

With unequal groups, the test and the interval can disagree

With unequal groups the two standard errors can split in either direction. Say the treatment is on a 10% ramp: control converts 1,000 of 10,000 users (10%), and treatment 120 of 1,000 (12%).

Standard errorResult
Pooled z-test0.01003z = 1.99, p = 0.046
Unpooled 95% interval0.01071-0.10 to 4.10 points, so 0 is inside
The 10% ramp, both results right at their line
0the gap
the pooled test the null's 95% range: the gap is just outside, p = 0.046
the unpooled interval -0.10 to 4.10: 0 is just inside
-3-2-1012345
points
Predict

On the ramp, the pooled test says p = 0.046 and the unpooled interval takes in 0. Which one is miscomputed?

Pick an answer above to see the rest
Part 2 done
Part 3 of 6about 12 min
p and the interval

The p-value counts both tails

The z score says how many standard errors the gap sits from 0. The p-value turns it into a share of the null curve: the area beyond your z, on both sides. two_sided_p is the function you write at the end of this step.

from statistics import NormalDist

z = 2.501955
print(round(two_sided_p(z), 6))
Predict

z = 2.502 on the worked example. What's the two-sided p-value?

Pick one to see what it prints.
Pick an answer above to see the rest

Say what a p-value means, and what it doesn't

Computing a p-value is half the job. Interviewers also ask what one means, and the common answer is wrong.

Predict

p = 0.012 on the worked example. Which statement is right?

Pick an answer above to see the rest

The interval's multiplier leaves alpha/2 in each tail

The p-value used cdf to turn a point into a share of the curve. The interval needs the reverse, a share in and a point out, and at alpha = 0.05 that point is 1.96. multiplier is the function you write at the end of this step.

for alpha in (0.10, 0.05, 0.01):
    m = multiplier(alpha)
    level = f"{1 - alpha:.0%}"
    print(f"alpha {alpha:.2f}   {level} interval   multiplier {m:.3f}")
Predict

What multiplier does a 99% interval use?

Pick one to see what it prints.
Pick an answer above to see the rest

A smaller alpha gives a wider interval

Now put the multiplier to work, at three levels of confidence.

Predict

You ask for 99% confidence instead of 95%. What happens to the interval?

Pick an answer above to see the rest
Part 3 done
Part 4 of 6about 8 min
The worked example

The whole function splits into two branches after the rates

Every piece so far fits in one function. After the rates, it splits into two branches, each with its own standard error.

BranchThe rate it usesThen
the testone pooled rate for everyonethe pooled SE, then z, then p_value
the intervaleach group keeps its own ratethe unpooled SE, then ci

Both branches start from the two rates and diff, B's rate minus A's. This is levels 1 to 3 of the practice. Level 4 adds the split check from the first chapter as one more key, srm.

from math import sqrt
from statistics import NormalDist

def two_proportion_test(conv_a, n_a, conv_b, n_b, alpha=0.05):
    pa, pb = conv_a / n_a, conv_b / n_b
    diff = pb - pa
    # the null's one rate
    pooled = (conv_a + conv_b) / (n_a + n_b)
    z = diff / sqrt(pooled * (1 - pooled) * (1 / n_a + 1 / n_b))
    # both tails
    p_value = 2 * (1 - NormalDist().cdf(abs(z)))
    se = sqrt(pa * (1 - pa) / n_a + pb * (1 - pb) / n_b)
    half = NormalDist().inv_cdf(1 - alpha / 2) * se
    return {"diff": diff, "z": z, "p_value": p_value,
            "ci": (diff - half, diff + half)}

for counts in [(200, 2000, 250, 2000), (250, 2000, 200, 2000),
               (100, 1000, 100, 1000)]:
    r = two_proportion_test(*counts)
    low, high = r["ci"]
    print(f"z {r['z']:+.4f}  p {r['p_value']:.5f}  "
          f"ci {low:+.5f} to {high:+.5f}")
Predict

The second run swaps the groups: 250 of 2,000 against 200 of 2,000. What happens to z and p?

Pick one to see what it prints.
Pick an answer above to see the rest

Every number for 200 of 2,000 against 250 of 2,000

Control converts 200 of 2,000 users and treatment 250 of 2,000. These are the practice problem's known-result numbers, so your function should reproduce every row.

StepCalculationValue
Rates200 / 2,000 and 250 / 2,0000.100 and 0.125
Difference0.125 - 0.1000.025
Pooled rate450 / 4,0000.1125
Pooled SE√(0.1125 × 0.8875 × 0.001)0.009992
z0.025 / 0.0099922.5020
p-value2 × (1 - Φ(2.5020))0.01235
Unpooled SE√(0.1 × 0.9 / 2,000 + 0.125 × 0.875 / 2,000)0.009984
Multiplierinv_cdf(0.975)1.95996
Half-width1.95996 × 0.0099840.01957
95% interval0.025 ± 0.01957(0.00543, 0.04457)

The 0.001 in the pooled row is 1/2000+1/20001/2000 + 1/2000.

Read the result like this. Treatment converted 2.5 points better. If the pages were equally good, a gap that big in either direction would turn up about 1.2% of the time, so it's significant at 5%. The plausible range for the true lift runs from about 0.5 to 4.5 points.

In the editor, write pooled_rate and half_width, two rows of the table, and check them against its values.

The confidence level describes the method, not one interval

The worked example's 95% interval runs from 0.54 to 4.46 points. To see what its 95% promises, run the experiment again and again.

import random

rng = random.Random(5)
true_gap = 0.125 - 0.10
covered = 0
for _ in range(10_000):
    conv_a = rng.binomialvariate(2000, 0.10)
    conv_b = rng.binomialvariate(2000, 0.125)
    low, high = two_proportion_test(conv_a, 2000, conv_b, 2000)["ci"]
    covered += low <= true_gap <= high
print(f"{covered / 10_000:.1%} of the intervals hold the true gap")
Predict

10,000 experiments, a 95% interval each. What share of them hold the true gap?

Pick one to see what it prints.
Pick an answer above to see the rest
Predict

You've built one 95% interval. Is there a 95% chance the true gap is inside it?

Pick an answer above to see the rest
Part 4 done
Part 5 of 6about 14 min
The call

Say the lift in points and as a percent

A launch call starts with how big the lift is, and there are two ways to say it.

Predict

Conversion goes from 10% to 12.5%. What's the relative lift?

Pick an answer above to see the rest

The relative lift needs its own interval

The relative lift needs an interval too, and the quick way to get one is wrong.

Predict

Can you get the relative lift's interval by dividing the points interval by the control rate?

Pick an answer above to see the rest

Significant is not the same as worth shipping

With enough users, even a tiny lift comes out significant.

Predict

10 million users per group, 10.00% against 10.05%, p = 0.0002. Ship it?

Pick an answer above to see the rest

Read the interval against zero and against a practical bar

Since significance alone can't make the call, fix a practical bar before the test starts: the smallest lift worth what the change costs to build, ship and maintain. Then read the interval against both zero and the bar:

Predict

The interval runs 0.5 to 4.5 points, and your practical bar is 1 point. What's the call?

Pick an answer above to see the rest

A lift that looks too good deserves a hunt for the bug

One more check before any launch call: is the lift believable at all?

Predict

A change lifts conversion 25% on a mature product. What's your first move?

Pick an answer above to see the rest
Part 5 done
Part 6 of 6about 22 min
Follow-ups

What interviewers ask next

The practice problem lists the follow-ups. Each one is a way a correctly computed test still gives a wrong answer.

Peeking: every extra look at a fixed test is another chance for a false positive

Looks over the testFalse positive rate
1, at the end5%
28%
514%
14, daily for two weeks22%
10037%
1,00054%

That's how often a test with no real effect gets called significant when you stop at the first p below 0.05, with the looks spread evenly over the test, in simulation.

A fixed-sample test is built for one look. Netflix's experimentation team puts it plainly: "If you apply a fixed-n test more than once, then you forfeit the Type-I error or false positive guarantee" (1 source). Every extra look is another chance for noise to cross 1.96.

Microsoft's pitfall list says the same, and adds the mirror image: "In our experience, stopping early or extending the experiment are both very common mistakes experiment owners make." Running a flat test longer until it crosses 0.05 is the same error.

Three ways to look early and stay honest

You can look early, as long as you plan the looks before the test starts.

Predict

Under an O'Brien-Fleming plan for 14 daily looks, day 2 needs |z| above 5.57. Day 2's p = 0.04 is |z| = 2.05. Can you stop for a win?

Pick an answer above to see the rest

Many metrics and variants compound the false positive chance

Peeking gives one metric many chances. Tracking many metrics does the same thing another way.

Predict

You test 20 independent metrics on a change that does nothing. What's the chance at least one comes out significant at 0.05?

Pick an answer above to see the rest

Novelty and primacy: users can react to the change itself

Even one metric, read once at the planned end, can mislead when the effect changes over the test.

Novelty and primacy, the shapes (not data)
-1010714daytreatment effect
novelty, big at first, then fades primacy, worse at first, then wins

Users can react to change itself. A new design can draw clicks because it's new and then fade as people get used to it. That's novelty. Or it can lose at first because people have to relearn it, and win later. That's primacy. Either way, a short test measures the wrong thing.

In one Microsoft experiment, a coach mark on Edge's new tab page lifted clicks on top sites by 2.07%. But splitting by visit showed "the treatment effect did not last beyond the first visit."

Predict

How can you tell whether a lift is novelty?

Pick an answer above to see the rest

Guardrail metrics say what the change cost

The primary metric says whether the change worked. Guardrails say what it cost.

Page load, treatment minus control (an example)
0+50: the tolerance
small test reaches past the tolerance
big test stays under it
-40-20020406080
ms

Microsoft's experimentation team describes guardrails as metrics "which are not clearly indicative of success of the feature being tested, but which we do not want to significantly harm when making a ship decision."

Page load time, crash and error rates, unsubscribes, support contacts and revenue are typical. Small slips can be acceptable. In their words, "Large degradations, however, are generally not allowed."

  • Set each tolerance before the test. Page load may rise by up to 50 ms is a rule. It looks fine isn't.
  • Read the interval, not the p-value. No significant drop on an underpowered guardrail isn't evidence of no drop. Check that the interval's worst end stays inside the tolerance.
Predict

A guardrail shows no significant slowdown, but its interval reaches past your 50 ms tolerance. Is it safe?

Pick an answer above to see the rest

Revenue's heavy tail needs more users, a cap or equal groups

Every test so far counted conversions, a 0 or a 1 for each user. Revenue per user is different: most users spend nothing and a few spend a lot.

20 users' revenue in one week (an example)14 usersThe other 6Mean
raw$0 each$4, 6, 9, 12, 25, 480$26.80
capped at $10$0 each$4, 6, 9, 10, 10, 10$2.45

One user holds 90% of all the revenue.

So the test changes shape. Compare means, with each group's own sample variance s2s^2. That's Welch's test:

SE=sA2nA+sB2nB\text{SE} = \sqrt{\frac{s_A^2}{n_A} + \frac{s_B^2}{n_B}}

In words: each group's sample variance over its users, added, under one square root. There's no pooled-rate step, because a mean doesn't fix the variance the way p(1−p)p(1 - p) does.

The tail is the real problem. A few big spenders dominate the variance, so the test is noisy, and the average needs far more users before it's close to normal.

Predict

Revenue per user has a skewness of 18. A rule of thumb asks for at least 355 × skewness² users per variant. About how many is that?

Pick an answer above to see the rest

The practice problem, start to finish

That's every piece of the practice problem, and every follow-up it lists. The simulation asks for the whole function under a timer, so rehearse the order once.

Check yourself
5 questions
  1. 1.Your function returns p = 0.0062 for 200/2,000 against 250/2,000, and the practice test expects 0.0124. Two identical groups give p = 0.5. What's wrong?

  2. 2.At alpha = 0.05 your interval for the worked example is (0.0086, 0.0414). The reference gives (0.0054, 0.0446). How often does yours cover the true difference?

  3. 3.Why does the z statistic use the pooled rate while the interval uses each group's own rate?

  4. 4.Your z uses the unpooled standard error, so it's 2.5039 on the worked example instead of 2.5020. When does that bug actually hurt?

  5. 5.A PM checks a 14-day test every day and stops it the first time p < 0.05. If the treatment does nothing, about how often does the test end on a significant result?

Where this shows up

The reports behind this lesson, each with its source.

Same L5 DS report, take-home prompt: define success metrics and decide whether a launch succeeded.

Candidate report·Aced, formerly Exponent (verified candidate report)Source

Same L5 DS report, stats question: explain a p-value.

Candidate report·Aced, formerly Exponent (verified candidate report)Source

DS technical screen (posted 2025-10-13): design an experiment and recommend whether to launch.

Prep site·PracHub (prep site question bank)·2025-10-13Source

DS technical screen (posted 2026-02-21): design and then analyze an experiment for a luggage locker feature.

Prep site·PracHub (prep site question bank)·2026-02-21Source

Data scientist candidate (interviewed Aug 2026): the hiring manager screen dwelt on the candidate's experiments.

Candidate report·PracHub (first-person report, curated and edited by the site)·2026-08-25Source

Sequential testing (Feb 2024): looking at a fixed-n test more than once loses its false positive guarantee.

“If you apply a fixed-n test more than once, then you forfeit the Type-I error or false positive guarantee.”
Company source·Netflix Tech Blog, post 'Sequential A/B Testing Keeps the World Streaming Netflix Part 1: Continuous Data' (full text read from the blog's Medium RSS feed; the post page itself returns 403)·2024-02-13Source

Before deploying a model update, OpenAI runs an A/B test with a small number of users.

“an A/B test with a small number of our users.”
Company source·OpenAI blog·2025-05-02Source

After the sycophancy incident, OpenAI said proxy measurements or qualitative signals could block launches.

“blocking launches based on proxy measurements or qualitative signals.”
Company source·OpenAI blog·2025-05-02Source

Practice

Sources (6)
  1. Diagnosing Sample Ratio Mismatch in Online Controlled Experiments: A Taxonomy and Rules of Thumb for Practitioners · KDD 2019, authors' version · Aug 4, 2019
    “Sample Ratio Mismatch in most cases completely invalidates experiment results.”
  2. A Dirty Dozen: Twelve Common Metric Interpretation Pitfalls in Online Controlled Experiments · KDD 2017 · Aug 13, 2017
    “In addition to OEC metrics, we have found that there is a set of metrics which are not clearly indicative of success of the feature being tested, but which we do not want to significantly harm when making a ship decision.”
  3. Seven Rules of Thumb for Web Site Experimenters · KDD 2014, authors' version · Aug 24, 2014
    “When a metric has a large skewness, it is sometimes possible to transform the metric or cap the values to reduce the skewness so that the average converges to normality faster.”
  4. Always Valid Inference: Bringing Sequential Analysis to A/B Testing · arXiv 1512.04922 · Dec 15, 2015
    “A/B tests are typically analyzed via frequentist p-values and confidence intervals; but these inferences are wholly unreliable if users endogenously choose samples sizes by *continuously monitoring* their tests.”
  5. statistics.NormalDist.cdf · Python 3.12 documentation · Oct 26, 2026
    “Using a cumulative distribution function (cdf), compute the probability that a random variable X will be less than or equal to x.”
  6. statistics.NormalDist.inv_cdf · Python 3.12 documentation · Oct 26, 2026
    “Compute the inverse cumulative distribution function, also known as the quantile function or the percent-point function.”