CTR Confidence Intervals and Variance Decomposition
Statistics & ExperimentsModel answerLast updated
Derive a pooled click-through rate estimator, compare Wald vs. exact binomial confidence intervals, and separate real day-to-day volatility from sampling noise.
Background
You are a data scientist reviewing the daily performance of a newly launched social feature. For each of the past 7 days you have three numbers:
- $n_i$: impressions served on day $i$
- $k_i$: clicks recorded on day $i$
- $p_i = k_i / n_i$: the observed click-through rate (CTR) on day $i$
Your job is to move beyond reading raw percentages and build statistically sound estimates of the overall rate and its uncertainty.
What you need to work through
Part 1 — Overall CTR estimate
Derive the pooled CTR estimator $\hat{p}$ across all 7 days and derive its variance from first principles. Why is this preferable to simply averaging the seven daily rates? What assumptions are you making, and when do they break?
Part 2 — Confidence interval methods
Explain the structural difference between the Wald interval and the Clopper–Pearson interval for a binomial proportion. Describe at least three conditions under which the Wald interval produces unreliable results, and what you would use instead.
Part 3 — Variance of the daily CTRs
You want to quantify how much the true CTR fluctuates from day to day. Explain why sample variance $s^2$ (dividing by $n-1$) should be used instead of population variance $\sigma^2$ (dividing by $n$) for this purpose. Then describe how you would isolate genuine day-to-day variation from pure binomial sampling noise.
Concrete starting point
Day 1 has $n = 1{,}000$ impressions and $k = 50$ clicks, so $p_1 = 0.05$.
- $SE = \sqrt{p(1-p)/n} = \sqrt{0.05 \cdot 0.95 / 1000} \approx 0.00689$
- Wald 95% CI: $0.05 \pm 1.96 \times 0.00689 \approx [0.037,\ 0.064]$
Use this as a reference point as you work through the tasks.
What a complete answer looks like
A strong response will: state assumptions explicitly, show the algebraic steps for the variance derivation, compare the two interval methods with enough detail to justify choosing one over the other in a product analytics context, and explain the $n-1$ correction in terms of degrees of freedom rather than just citing "Bessel's correction."
Hints
Hint 1
For Part 1, think of each day's click count as a Binomial random variable. To find the variance of $\hat{p} = K/N$, first find the variance of $K = \sum k_i$ using the independence of days, then apply the scaling rule $\text{Var}(aX) = a^2\text{Var}(X)$.
Hint 2
For Part 2, ask yourself what happens to the Wald formula when $k = 0$ or $k = n$. What does the standard error equal? What does the resulting interval claim about uncertainty? That's the clearest way to see where the normal approximation breaks down.
Hint 3
For Part 3, each observed $p_i$ is a noisy measurement: it mixes a true underlying rate with binomial sampling error. Write $\text{E}[s^2]$ as a sum of real variance and noise variance, then solve for the real variance term.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What this question is really testing
Interviewers use this kind of question to check three things: whether you can derive a result rather than just recall a formula, whether you know where textbook assumptions quietly fail in product data, and whether you can communicate statistical reasoning clearly to a non-specialist audience. State your assumptions out loud and revisit them — that's what separates a strong answer from a mediocre one.
Part 1: Pooled estimator and its variance
Setup. Let $N = \sum_{i=1}^{7} n_i$ and $K = \sum_{i=1}^{7} k_i$. Assume every impression is an independent Bernoulli trial with the same true rate $p$ on all days.
The estimator.
$$\hat{p} = \frac{K}{N} = \frac{\sum k_i}{\sum n_i}$$
This is an impression-weighted average of the daily rates and is also the maximum likelihood estimator, because the full likelihood $\prod_i p^{k_i}(1-p)^{n_i - k_i}$ depends on the data only through $K$ and $N$.
Variance derivation from first principles.
Each day contributes $k_i \sim \text{Bin}(n_i, p)$, so $\text{Var}(k_i) = n_i p(1-p)$. Since the days are independent:
$$\text{Var}(K) = \sum_{i=1}^{7} n_i p(1-p) = N p(1-p)$$
Dividing $K$ by the constant $N$:
$$\text{Var}(\hat{p}) = \frac{\text{Var}(K)}{N^2} = \frac{p(1-p)}{N}, \qquad \widehat{SE} = \sqrt{\frac{\hat{p}(1-\hat{p})}{N}}$$
Why not just average the seven $p_i$? The unweighted mean $\bar{p} = \frac{1}{7}\sum p_i$ is also unbiased, but its variance is $\frac{p(1-p)}{49}\sum_i \frac{1}{n_i}$. The AM–HM inequality guarantees this is at least as large as $p(1-p)/N$, with equality only when all $n_i$ are identical. $\hat{p}$ is the more efficient estimator. More importantly, the two answer different questions: $\hat{p}$ is "CTR per impression" and $\bar{p}$ is "average CTR per day." Clarify which one the business wants before proceeding.
Assumptions to flag immediately:
- Independence. Impressions served to the same user are not independent — clicks cluster within users. The formula $p(1-p)/N$ then understates the true variance. The fix is to treat the user as the unit of analysis and apply the delta method to the ratio $\sum \text{clicks}_u / \sum \text{impressions}_u$, or bootstrap over users.
- Constant true rate. If $p$ genuinely differs across days (weekday vs. weekend effects, feature rollouts), then the binomial variance misses the between-day component. That's what Part 3 addresses.
Part 2: Wald vs. Clopper–Pearson
| Wald | Clopper–Pearson | |
|---|---|---|
| How it's built | $\hat{p} \pm z \cdot \sqrt{\hat{p}(1-\hat{p})/n}$ — the CLT with plug-in SE | Inverts two exact one-sided binomial tests. Contains every $p$ a level-$\alpha/2$ test would not reject. |
| Closed form | Yes | Beta quantiles: $L = B(\alpha/2;\ k,\ n-k+1)$, $U = B(1-\alpha/2;\ k+1,\ n-k)$ |
| Coverage guarantee | Approximate, often below nominal | Guaranteed $\geq 1-\alpha$, so conservative |
| Shape | Symmetric, can exit $[0,1]$ | Asymmetric, always within $[0,1]$ |
The core distinction: Wald approximates the sampling distribution of $\hat{p}$ with a normal centered at $\hat{p}$. Clopper–Pearson uses the exact binomial distribution and makes no normality assumption.
Three concrete failure modes for Wald:
-
$p$ near 0 or 1, or small $n$. The binomial is skewed; a symmetric normal is a poor fit. The standard rule of thumb requires $n\hat{p} \geq 10$ and $n(1-\hat{p}) \geq 10$. CTRs of 1–3% are routine in product features, making this failure mode common.
-
$k = 0$ or $k = n$. The estimated SE becomes 0, so the interval collapses to a single point. This claims perfect certainty from limited data — the opposite of what you want.
-
Bounds outside $[0,1]$. With $k = 2$, $n = 100$, the lower bound goes negative. A probability below zero is nonsensical.
For low-CTR product features, Clopper–Pearson is the safer default. The Wilson interval is another good choice — it has better empirical coverage than Wald while being less conservative than Clopper–Pearson.
Part 3: Sample variance and separating real volatility from noise
Why $n-1$, not $n$. The true mean $\mu$ is unknown, so we substitute the sample mean $\bar{p}$. Deviations around a fitted mean are systematically smaller than deviations around the true mean, because $\bar{p}$ is by construction the value that minimizes the sum of squared deviations. Formally:
$$E\left[\sum_{i=1}^{7}(p_i - \bar{p})^2\right] = \sum E[(p_i - \mu)^2] - 7 \cdot E[(\bar{p} - \mu)^2] = 7\sigma^2 - \sigma^2 = 6\sigma^2$$
Dividing by 6 (that is, $n-1$) recovers an unbiased estimate. With only 7 days, the difference is not trivial: dividing by 7 instead of 6 underestimates variance by about 14%, making the metric appear more stable than it actually is.
Separating real variation from sampling noise. Each observed $p_i$ has two sources of variance: genuine day-to-day shifts in the true rate (call this $\tau^2$), and binomial sampling noise within each day. The expected value of $s^2$ reflects both:
$$E[s^2] \approx \tau^2 + \frac{1}{7}\sum_{i=1}^{7} \frac{p_i(1-p_i)}{n_i}$$
Solving for the real between-day variance:
$$\hat{\tau}^2 = \max!\left(0,\ s^2 - \frac{1}{7}\sum_{i=1}^{7} \frac{\hat{p}_i(1-\hat{p}_i)}{n_i}\right)$$
$\hat{\tau}^2$ is the right answer to "how volatile is this metric." Using raw $s^2$ overstates stability risks when $n_i$ is large (sampling noise is negligible) and understates them when $n_i$ is small (noise inflates $s^2$ even if the true rate is flat). The max-zero floor handles the case where measured variance is less than the expected noise floor, which can happen with small samples.
Common mistakes
- Using $p(1-p)/N$ as the variance of the unweighted mean $\bar{p}$. That formula belongs to the pooled estimator only.
- Treating impressions as the unit of analysis when randomization is at the user level.
- Applying Wald when $k = 0$ and reporting $[0, 0]$ as a valid interval.
- Dividing by $n$ for $s^2$ with 7 observations and then drawing conclusions about weekly stability.
- Reporting raw $s^2$ as the volatility signal without subtracting the known noise floor.
Likely follow-ups
Several days have zero clicks. Wald is completely unusable. Switch to Clopper–Pearson (upper bound when $k=0$ is $1-(0.025)^{1/n}$) or the Jeffreys interval using a Beta$(k+\tfrac{1}{2},\ n-k+\tfrac{1}{2})$ posterior. Consider pooling days if you believe a constant underlying rate is reasonable — but first rule out a logging or tracking bug. Multiple consecutive zero-click days on a live feature is a strong signal something is broken upstream.
Testing whether day-to-day variation is real or noise. Under the null of a constant $p$, the dispersion statistic $X^2 = \sum_i (k_i - n_i\hat{p})^2 / (n_i\hat{p}(1-\hat{p}))$ follows a $\chi^2_6$ distribution. A value well above 6 indicates overdispersion — real variation beyond chance. From there, investigate day-of-week effects, platform mix, traffic source, or recent releases by segmenting the data or fitting a logistic regression.