Geometric Sessions, A/B Sizing, and Bootstrap on Skewed Engagement
Statistics & ExperimentsModel answerLast updated
Four linked statistics questions: geometric session probabilities, two-proportion sample sizing, why a t-test and bootstrap CI disagree on skewed data, and a ship/no-ship recommendation.
Context
You own the analysis of an A/B test on a new ranking model for a content-discovery feed. The test ran for 14 days. Two metrics matter:
repins_per_user: the average number of saves per user (a count metric).user_save_rate: the share of users who save at least one item (a proportion).
Answer the four connected parts below.
Part 1: Session dynamics
Within a session, a user sees items one at a time. Impressions are independent, and each is saved with probability p = 0.08. The session ends right after the first save.
- What is the probability that a user views more than 10 items in a session?
- A user has already viewed 8 items with no save. What is the probability that they view more than 12 items in total?
Part 2: Sizing the experiment
You plan a two-sided, two-sample test on user_save_rate with control rate p0 = 0.25. You want to detect a 2% relative lift (p1 = 0.255) with 80% power at alpha = 0.05.
- Write the per-variant sample size
nusing the normal approximation, and evaluate it. - Explain how the required
nchanges if you instead size for the continuous metricrepins_per_userand assume variance is 4 times the mean (sigma^2 = 4 * mu), compared with a Poisson assumption (sigma^2 = mu).
Part 3: Bootstrap on a heavy-tailed metric
The test ended with N = 100,000 users per arm. For repins_per_user, more than 70% of users have zero repins, and the top 1% of users produce 45% of all repins.
- A two-sample t-test on the difference in means gives
p = 0.038favoring treatment. - A 10,000-resample percentile bootstrap gives a 95% CI for
mu_treatment - mu_controlof[-0.004, 0.052].
Explain mathematically why these two results disagree, and say which one you trust more and why.
Part 4: The launch decision
A product manager wants to ship immediately because "p < 0.05". State your recommendation, explain how you would respond to that argument, and list the extra analyses you would run before a final decision (for example transformations, trimming, or a stratified bootstrap).
Hints
Hint 1
In Part 1, 'more than k items' means the first k impressions were all non-saves. Think about what independence implies once 8 non-saves have already happened.
Hint 2
For Part 2, the sample size depends on the variance under the null and under the alternative. Check whether the planned 100,000 per arm actually meets the requirement before analyzing results. For the count metric, remember n scales linearly with variance.
Hint 3
For Part 3, compare the standard error implied by p = 0.038 with the one implied by the bootstrap interval width. Then think about skewness, how fast the CLT kicks in, and whether the analysis unit was really the user.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Session dynamics
Let X be the number of items viewed up to and including the first save. Then X is Geometric(p = 0.08) on {1, 2, ...}, and viewing more than k items means the first k impressions were all non-saves:
P(X > k) = 0.92^k
More than 10: 0.92^10 ≈ 0.434.
More than 12 given 8 already seen without a save: the geometric distribution is memoryless, so
P(X > 12 | X > 8) = 0.92^12 / 0.92^8 = 0.92^4 ≈ 0.716.
Only the 4 additional non-saves matter, because earlier impressions are independent of later ones.
Common mistakes: answering 0.92^12 (ignoring the conditioning), off-by-one exponents (9 or 11), and confusing "more than 10" with "first save occurs on item 10".
2. Sample size
Proportions
With p̄ = (p0 + p1)/2 = 0.2525 and δ = p1 − p0 = 0.005:
n = [ z₁₋α/₂ · √(2p̄(1−p̄)) + z₁₋β · √(p0(1−p0) + p1(1−p1)) ]² / δ²
- z₀.₉₇₅ = 1.96, z₀.₈₀ = 0.8416.
- Alpha term: 1.96 × 0.6144 ≈ 1.204.
- Power term: 0.8416 × 0.6144 ≈ 0.517.
- n ≈ (1.721)² / 0.000025 ≈ 118,500 per arm.
The simpler form n ≈ (z₁₋α/₂ + z₁₋β)² [p0q0 + p1q1] / δ² gives nearly the same value, because the null and alternative variances are almost identical for such a small lift.
The planned 100,000 per arm gives only about 73% power for this effect. The save-rate test was therefore underpowered, and that should be stated up front.
Continuous count metric
For a difference in means with equal variances and absolute effect δ:
n = 2(z₁₋α/₂ + z₁₋β)² σ² / δ²
n is linear in σ². Under Poisson, σ² = μ. With σ² = 4μ, the requirement is 4 times larger for the same absolute δ. For a relative lift r (δ = rμ), n = 2(z₁₋α/₂ + z₁₋β)² σ² / (r²μ²), which becomes 8(z₁₋α/₂ + z₁₋β)² / (r²μ) when σ² = 4μ. Sizing with a Poisson assumption would leave the test badly underpowered, and real engagement counts are often overdispersed by much more than 4×.
3. Why the t-test and bootstrap disagree
Quantify the gap
p = 0.038 corresponds to |t| ≈ 2.07. If the point estimate is near the middle of the bootstrap interval (~0.024), the t-test SE is about 0.024 / 2.07 ≈ 0.0116, giving a Wald interval of roughly [0.001, 0.047]. The bootstrap interval has half-width 0.028, which implies an effective SE near 0.014. The bootstrap sees both more spread and an asymmetric distribution.
Reasons
- Slow CLT convergence under skew. The Edgeworth expansion of the t-statistic is P(T ≤ x) = Φ(x) + n^(−1/2) γ q(x) φ(x) + O(n⁻¹), where γ is the skewness. With 70% zeros and a top 1% holding 45% of the mass, γ is very large, so the correction term is not negligible even at N = 100,000. In effect, the mean is driven by roughly 1,000 heavy users per arm, not 100,000.
- Mean and variance are coupled. In right-skewed data, a sample with an extra heavy user raises both the mean and the sample SD. The studentized statistic is therefore skewed rather than t-distributed, and the symmetric normal approximation understates upper-tail uncertainty.
- The bootstrap reproduces tail luck. Resampling captures how many extreme users happen to land in each arm, which produces a wider, asymmetric distribution of the difference.
- Unit of analysis. If the t-test was run on user-days or sessions rather than users, within-user correlation is ignored and the SE shrinks. Pooled-variance t-tests also understate SE if the treatment arm has more heavy users.
Which to trust
Neither is exact. The percentile bootstrap is only first-order accurate and can be biased under skew. Still, it is more trustworthy here, because it makes no symmetry assumption and reflects sensitivity to a few users. The honest conclusion is that the evidence is fragile, not that the effect is established.
4. Decision
Recommendation: do not ship on this evidence alone. Call it promising but unproven.
Responding to the PM:
- p = 0.038 is borderline and rests on an approximation that is strained for this distribution. A resampling method contradicts it.
- If several metrics were examined, a multiplicity correction applies.
- The primary conversion metric (save rate) was underpowered, so a non-result there is not evidence of no effect. It also means the main pre-specified metric cannot confirm the win.
- A ranking change whose gain may come from a few dozen heavy users is expensive to reverse. Frame this as risk management, not obstruction.
Checks before deciding:
- Validity: sample-ratio-mismatch test, confirm the analysis unit is the user, use Welch's test, and plot the daily effect to detect novelty decay.
- Robust estimators: winsorize at the 99th and 99.9th percentiles, analyze log(1 + repins), and run a leave-top-k-out sensitivity check (does the effect survive dropping the top 0.1% of users?).
- Variance reduction: CUPED with pre-period repins, which often cuts variance substantially when user activity is persistent.
- Better intervals: a bootstrap stratified by pre-period activity tier (zero, light, heavy), using BCa, which corrects for bias and skew via a jackknife-estimated acceleration and has O(n⁻¹) coverage error. A studentized bootstrap is also second-order accurate but needs a stable per-resample SE, which heavy users make erratic.
- Decomposition: a hurdle view that separates participation, P(repins > 0), from intensity given participation. Add a rank-based check (Mann–Whitney) or upper-quantile effects.
import numpy as np
def boot_diff(t, c, B=10000, seed=0):
rng = np.random.default_rng(seed)
d = [rng.choice(t, len(t)).mean() - rng.choice(c, len(c)).mean()
for _ in range(B)]
return np.percentile(d, [2.5, 97.5])
Decision rule: ship if robust estimators agree in sign and are significant, and guardrail metrics hold. Otherwise extend the test or rerun it at the properly sized N (about 118,500 per arm for the save rate, and considerably more for a count metric with variance 4μ).