A/B Testing Auction Revenue with Heavy Tails and Zeros
Statistics & ExperimentsModel answerLast updated
Design a defensible inference plan for comparing mean revenue between two arms when data is zero-heavy, extremely skewed and contaminated by spikes, including outlier handling and multiple-testing control.
Context
A marketplace is testing a new auction bid-pricing algorithm (the treatment) against the current one (the control). The key metric is revenue per user. Its distribution has three unpleasant features:
- A large mass of exact zeros (users who never transact).
- A long right tail created by a small number of very high-value "whale" users.
- Occasional extreme values caused by infrastructure latency glitches.
You have two samples, control and treatment, with n = 10,000 users each. You need to decide whether the difference in mean revenue per user between arms is statistically significant.
Constraints
- The big values are not always data errors. Many are real, rare, high-value auction wins, and the business wants them reflected in the answer.
- This experiment is one of many metrics and comparisons in a larger suite, so the false discovery rate (FDR) has to be controlled.
What to answer
- Explain why a plain two-sample t-test is a poor choice here. Discuss both false-positive rate and statistical power.
- Propose a robust estimator of the difference in means and describe how to build a 95% confidence interval for it.
- Decide how to treat the whale values: trim, winsorize, or transform. Explain how each option changes what you are estimating and how sensitive the test is.
- If you use a transformation such as log or Box-Cox, explain the bias you get when mapping results back to the original scale and how to correct it.
- Say how you would control FDR across the full set of tests.
Hints
Hint 1
Check whether n = 10,000 is really enough for the central limit theorem when skewness is in the tens. Think about which tail of the t-statistic misbehaves and what a single huge value does to the variance estimate.
Hint 2
Every robust method silently redefines the quantity you are estimating. Decide the estimand first (for example, mean of capped revenue), fix the cap before unblinding, and keep an uncapped analysis as a guardrail.
Hint 3
For back-transformation, think of Jensen's inequality: the exponential of the mean of logs is a geometric mean, not an arithmetic mean. Look at a distribution-free correction (smearing) computed per group, and at bootstrap intervals that are skew-aware such as BCa.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model answer
1. Why the t-test struggles
- The CLT is slow under heavy skew. The error of the normal approximation shrinks roughly like skewness divided by √n. Revenue per user commonly has skewness in the tens. A rule of thumb suggests needing on the order of hundreds of times skewness squared in observations, which can be hundreds of thousands of users. So 10,000 per group may not be enough.
- Type I error is lopsided. The t-statistic inherits the skew, so one tail rejects too often and the other too rarely. A nominal two-sided 5% test may look fine overall while one-sided or directional decisions are wrong.
- Power is lost. The variance estimate is dominated by a few extreme users. One latency spike inflates the standard error and hides real effects. It can also flip the sign of the observed difference.
- Variance may not exist. If the tail is Pareto-like with tail index below 2, the classical CLT does not apply.
- Zeros alone are not the problem. They add a point mass and extra skew that a Gaussian model ignores.
2. Robust estimator and CI
State the estimand first. The business wants mean revenue, and any robust method changes the target. Be explicit about that trade-off.
Primary analysis (recommended):
- Winsorized mean difference. Cap revenue at a high quantile (for example the 99.9th), computed on pooled or pre-period data and pre-registered. The estimand becomes mean capped revenue: influence is bounded and whales still contribute in the right direction.
- CUPED variance reduction. Adjust with pre-experiment revenue: Ŷ = Y − θ(X − X̄), θ = Cov(X, Y)/Var(X). For revenue this often removes 30–60% of the variance.
- Bootstrap CI. Resample users independently within each arm (B ≥ 10,000), re-run the whole pipeline each time (cap, CUPED, difference), and use BCa or bootstrap-t intervals. Plain percentile intervals under-cover with skewed statistics.
Alternative: Huber M-estimator. Solve Σψ((yᵢ − μ)/s) = 0 with clipping constant k ≈ 1.345 and scale s = MAD/0.6745. Standard errors come from the sandwich formula or the bootstrap. With asymmetric data it estimates a location parameter rather than the mean, so use it as a diagnostic, not as the headline revenue metric.
Hurdle decomposition. Write E[Y] = p · μ₊ with p = P(Y > 0) and μ₊ = E[Y | Y > 0]. Test conversion and conditional spend separately and combine with the delta method. This shows where an effect comes from.
import numpy as np
def capped_diff_ci(control, treatment, q=0.999, B=10000, alpha=0.05, seed=0):
rng = np.random.default_rng(seed)
c, t = np.asarray(control, float), np.asarray(treatment, float)
cap = np.quantile(np.concatenate([c, t]), q) # pooled, fixed threshold
cw, tw = np.minimum(c, cap), np.minimum(t, cap)
est = tw.mean() - cw.mean()
boots = np.empty(B)
for b in range(B):
boots[b] = (rng.choice(tw, tw.size).mean()
- rng.choice(cw, cw.size).mean())
lo, hi = np.quantile(boots, [alpha / 2, 1 - alpha / 2])
return est, (lo, hi) # use BCa in production
The sketch fixes the cap instead of re-estimating it in each resample. Complexity is O(B·n).
3. Trim, winsorize or transform
| Option | What it estimates | Sensitivity |
|---|---|---|
| Trim | Drops real high-value wins, biasing the mean down | Blind to effects living in the tail; trimming per arm adds bias |
| Winsorize | Mean of capped revenue; everyone still counts | Big variance reduction, good power; shrinks tail-concentrated effects |
| Transform (log1p, Box-Cox) | Multiplicative or geometric-mean shift | Strong power for broad shifts; can be significant while the arithmetic mean moves the other way |
Recommendation: winsorize as the primary analysis, since the whales are legitimate. Set the cap before seeing results, on pooled or historical data. A cap tuned after unblinding is a forking-paths problem. Report the uncapped difference with a bootstrap CI as a guardrail, and investigate if the signs disagree. Latency spikes are a data-quality problem: find them in system logs and fix or flag them upstream rather than hiding them with statistics.
4. Back-transformation bias
By Jensen's inequality, E[log Y] ≤ log E[Y], so exp(mean of logs) is the geometric mean and underestimates the arithmetic mean.
- If log Y ~ N(μ, σ²), then E[Y] = exp(μ + σ²/2). This is fragile when residuals are not normal.
- Duan smearing is distribution-free: Ê[Y] = exp(μ̂) · (1/n) Σ exp(eᵢ), with eᵢ = log yᵢ − μ̂. For log1p use (1/n) Σ exp(μ̂ + eᵢ) − 1.
- Compute the smearing factor per arm. A pooled factor reintroduces bias if treatment changes the residual variance.
- Get a CI for the back-transformed difference by bootstrapping the whole fit-and-smear procedure.
5. FDR control
- Apply Benjamini–Hochberg across metrics and arms. It is valid under independence or positive dependence (PRDS). Use Benjamini–Yekutieli under arbitrary dependence.
- Resampling p-values need enough resolution: with m = 50 tests the smallest BH threshold is α/m = 0.001, so use on the order of 10⁴–10⁵ resamples.
Common mistakes
- Assuming n = 10,000 guarantees the CLT without checking skewness.
- Quietly switching the estimand (median, log-mean, Huber) and calling it "revenue lift".
- Picking the cap after seeing results, or separately per arm.
- Reporting exp(difference of mean logs) as a revenue difference.
- Using percentile bootstrap intervals for highly skewed statistics.
Follow-ups
- Unequal variances between arms: never pool variances. Use Welch-style standard errors, resample within each arm, and compute smearing factors per arm. An unstudentized permutation test is not valid for means when variances differ.
- Power without closed forms: simulate. Resample users from pre-period data to create synthetic arms, inject realistic effects (multiplicative lift, conversion lift, whale-only lift, since power differs sharply between them), run the entire pipeline including cap, CUPED, bootstrap and BH, and take the rejection rate as power.