Sub topic 13
Reading small-sample results and confidence intervals
This chapter assumes you have already written pre-set thresholds (the previous chapters) and can read short Python. It covers how to turn a smoke-test result into a decision when you only have a few hundred visitors.
Why the raw rate misleads
Suppose 18 of 400 qualified visitors click "Start paid trial" and enter card details. The observed rate is 4.5%. That figure is only one sample from the true rate. Another 400 visitors might give 3% or 6%. A confidence interval is a range of true rates that are plausible given what you saw.
Two common errors follow from ignoring this:
- Treating 4.5% as exact, and building because it "beat 2%".
- Treating 1 buyer in 20 visitors (5%) as proof, when the interval is very wide.
Computing the interval
For conversion rates, use the Wilson interval. The simple "p plus or minus" formula breaks down with small counts or rates near 0%.
import math
def wilson_interval(successes, trials, z=1.96):
"""95% Wilson score interval for a conversion rate."""
if trials <= 0:
raise ValueError("trials must be positive")
if not 0 <= successes <= trials:
raise ValueError("successes must be between 0 and trials")
p = successes / trials
denom = 1 + z**2 / trials
centre = (p + z**2 / (2 * trials)) / denom
margin = z * math.sqrt(p * (1 - p) / trials + z**2 / (4 * trials**2)) / denom
return centre - margin, centre + margin
low, high = wilson_interval(successes=18, trials=400)
print(f"Observed rate: {18 / 400:.1%}")
print(f"95% interval: {low:.1%} to {high:.1%}")The output is an observed rate of 4.5% and an interval of about 2.9% to 7.0%.
Compare the interval to your thresholds
Use the plan you wrote before launching: build if the lower bound is at least 2%, stop if the upper bound is below 1%.
In the example, the lower bound is 2.9%, which is above 2%, so the rule says build. Notice that the point estimate alone (4.5%) would have hidden how close the interval's low end can be to your threshold.
Making the interval narrower
The interval shrinks roughly with the square root of the sample size. Quadrupling traffic about halves the width. This is why a plan fixes a minimum sample (here 300 qualified visitors) and why the traffic and budget check matters before launch.
What the interval does not cover
- Bias in who arrived. The interval only describes sampling noise. If your ads reached the wrong audience, a tight interval is still wrong.
- Stated versus real behavior. A card-entry rate is stronger evidence than a click, but it is still not a completed purchase.
- Several tests at once. If you test many variants and pick the best, its interval is too optimistic.
Exercise
A smoke test gets 4 buyers from 300 qualified visitors. The Wilson interval is about 0.5% to 3.4%. Using the thresholds "build if the lower bound is at least 2%, stop if the upper bound is below 1%", what do you do, and why?
Show answer
The result is inconclusive. The lower bound (0.5%) is below 2%, so you cannot build. The upper bound (3.4%) is above 1%, so you cannot stop either. Following the plan, change the offer or the audience and rerun the test. Do not relabel the thresholds after seeing the data.