Approach (brief):- Compute per-user revenue, group by variant, estimate incremental revenue per user = mean(revenue_treatment) - mean(revenue_control). Use both a parametric t-test (if revenue roughly normal after transform or large N) and bootstrap (non-parametric, robust to skewed revenue). Report point estimate, 95% CI, and p-value.Python (bootstrap + t-test pseudocode):python
import pandas as pd
import numpy as np
from scipy import stats
df = pd.read_csv("experiments.csv")
control = df[df.variant=='control']['revenue'].values
treat = df[df.variant=='treatment']['revenue'].values
# point estimate
delta = treat.mean() - control.mean()
# parametric t-test (Welch)
tstat, pval = stats.ttest_ind(treat, control, equal_var=False)
# bootstrap CI
def bootstrap_diff(a,b,iterations=10000):
diffs = []
for _ in range(iterations):
s1 = np.random.choice(a, size=len(a), replace=True)
s2 = np.random.choice(b, size=len(b), replace=True)
diffs.append(s2.mean()-s1.mean())
return np.percentile(diffs, [2.5,97.5]), np.mean(diffs)
ci, boot_mean = bootstrap_diff(control, treat)
SQL (per-user aggregated; then compute means):sql
WITH per_user AS (
SELECT user_id, variant, SUM(revenue) AS revenue
FROM events
GROUP BY user_id, variant
)
SELECT
AVG(CASE WHEN variant='treatment' THEN revenue END) AS mean_treat,
AVG(CASE WHEN variant='control' THEN revenue END) AS mean_control,
(AVG(CASE WHEN variant='treatment' THEN revenue END) -
AVG(CASE WHEN variant='control' THEN revenue END)) AS incremental_per_user
FROM per_user;
Choices & reasoning:- Per-user vs aggregated: use per-user (not per-event) to avoid inflation by heavy users and to match randomization unit.- Parametric t-test: fast, gives p-value; relies on CLT (OK if large sample). Revenue often skewed → consider log-transform (with zeros handled) or use non-parametric.- Bootstrap: recommended for skewed revenue/heteroskedasticity; directly yields CIs for the incremental mean.Presentation to stakeholders:- One slide with: point estimate (incremental $ per user), 95% CI (e.g., $0.12 to $0.35), p-value, and business interpretation (e.g., "At our sample size, treatment increases revenue by $0.24 per user — if rolled out to 1M users, expected +$240k/month"). Show simple visuals: two side-by-side bar of means with error bars and a bootstrap distribution histogram. State assumptions and recommended next steps (more data, segment analyses, or lift-testing for high-value cohorts).