The interview problem
You observe 1,000 users sampled independently from the same population. Each contributes an outcome total X and an exposure total Y. The sample means are 10 and 5; the sample variances across users are 36 and 4, and their sample covariance is 9. Estimate the population outcome per exposure, E[X]/E[Y], and its approximate standard error and 95% confidence interval. Explain the covariance term and identify cases where the approximation fails.
Original fundamentals practice, not a reported company interview. Values are hypothetical. Interview date not applicable; technical sources retrieved September 27, 2026.
1. Specify the estimand before calculating uncertainty
The target is a ratio of population means. Its plug-in estimate is the ratio of the sample means, which also equals the ratio of totals when both totals use the same users. It is generally different from the mean of the individual ratios.
For example, two users with X values (10, 0) and Y values (1, 9) give a ratio of totals of 10/10 = 1, but a mean individual ratio of (10/1 + 0/9)/2 = 5. These answer different questions. Choosing a formula for standard error cannot repair an incorrect target.
Define the measurement window, population and independent sampling unit. If sessions repeat within users, one million session rows do not automatically provide one million independent observations. Users with zero exposure also need an explicit measurement policy: silently dropping them changes the population and may change the target.
2. Propagate uncertainty through a local approximation
The delta method approximates a smooth transformation by its tangent near the true parameter. If an estimator is sufficiently concentrated there, the linear part describes its leading uncertainty. Let θ̂ estimate a vector θ, and suppose:
√n (θ̂ − θ) → Normal(0, Σ) g(θ̂) − g(θ) ≈ ∇g(θ)ᵀ (θ̂ − θ) Var[g(θ̂)] ≈ ∇g(θ)ᵀ Σ ∇g(θ) / n
Use an estimated parameter and covariance in practice. If V already estimates the covariance of θ̂, the calculation is ∇g(θ̂)ᵀ V ∇g(θ̂), with no additional division by n. Confusing individual-observation covariance with estimator covariance produces a factor-of-n error.
This is an asymptotic approximation, not a guarantee of exact normality, unbiasedness or finite-sample coverage. A positive quadratic form ∇g(θ)ᵀΣ∇g(θ) gives a nondegenerate first-order limit. A nonzero gradient alone is insufficient when Σ is singular; a zero gradient can require a different scaling and higher-order analysis. Smoothness alone is insufficient if the estimator has not concentrated in a region where the linear approximation is useful.
3. Derive the ratio formula
Write a = X̄, b = Ȳ and r = a/b. For g(a, b) = a/b, the gradient is (1/b, −a/b²). With paired observations from n independent users:
Var(r) ≈ [sX²/b² + a² sY²/b⁴ − 2a sXY/b³] / n
Here sX² and sY² are sample variances across individual users, and sXY is their sample covariance, all using the same n−1 convention. The off-diagonal term matters because the same users contribute both totals. For positive a and b, the gradient components have opposite signs, so positive covariance reduces this first-order ratio variance. The effect of covariance depends on the transformation; it does not always reduce uncertainty.
An equivalent implementation uses residuals Zi = Xi − rYi, with r held at its observed value:
estimated Var(r) = sample_variance(X − rY) / (n × Ȳ²)
The sample residual mean is zero by construction. This identity is a useful arithmetic check and expresses the variation that remains after the numerator tracks the denominator. It does not turn the approximation into an exact variance formula for the random ratio.
4. Work through the numbers
The point estimate is 10/5 = 2. The gradient is (0.2, −0.4), so the calculation is:
individual-scale quadratic form = (0.2)² × 36 + (−0.4)² × 4 + 2 × 0.2 × (−0.4) × 9 = 1.44 + 0.64 − 1.44 = 0.64 estimated variance = 0.64 / 1,000 = 0.00064 standard error = √0.00064 ≈ 0.0252982 approximate 95% Wald interval = 2 ± 1.96 × 0.0252982 ≈ [1.95042, 2.04958]
The residual check gives 36 + 2² × 4 − 2 × 2 × 9 = 16, and 16/(1,000 × 5²) = 0.00064. Both paths agree.
| Calculation | Estimated variance | Standard error |
|---|---|---|
| Uses paired covariance | 0.00064 | 0.02530 |
| Incorrectly sets covariance to zero | 0.00208 | 0.04561 |
Ignoring covariance makes the standard error about 1.803 times larger in this example. That is not a generally conservative shortcut: different covariance or derivative signs can make the error go in the opposite direction.
The interval is an approximate fixed-sample frequentist confidence interval under the stated assumptions. It does not mean there is a 95% frequentist probability that this fixed population ratio lies in these particular endpoints.
5. Consider the transformation scale
When both population means and their estimates are positive and safely away from zero, a log-ratio can give an interval that respects positivity. For h(a,b) = log(a) − log(b), use the gradient (1/a, −1/b).
SE[log(r)] ≈ SE(r) / r
≈ 0.0126491
interval = exp[log(2) ± 1.96 × 0.0126491]
≈ [1.95103, 2.05020]This differs slightly from the symmetric interval because the transformation is nonlinear. It does not solve an unstable denominator, biased measurement or invalid independence assumption. The log transformation also requires a meaningful positive target; it is not a universal repair for ratios involving signed quantities.
6. Build the calculation around the sampling design
define population, ratio and independent unit
↓
aggregate paired X and Y over the fixed window
↓
estimate means and their joint covariance
↓
evaluate gradient and covariance quadratic form
↓
check assumptions, report estimate and intervalFor independently randomized treatment and control arms, the variance of a difference of ratio estimates is the sum of their estimated variances. Paired or shared-user designs need the cross-arm covariance as well. Relative lift is another nonlinear transformation, with another denominator that may become unstable.
Clustered assignment or dependence requires a suitable covariance estimate at the cluster level or a justified robust estimator. The delta method propagates that covariance; it does not create independence. With few independent clusters, normal critical values can be unreliable even when there are many event rows.
For streaming computation, preserve paired counts, means, variances and covariance with numerically stable mergeable aggregation. Large raw sums followed by subtracting nearly equal numbers can lose precision. Check the covariance matrix and the residual-form calculation rather than clipping a materially negative computed variance to zero and hiding the problem.
7. Recognize when first-order inference breaks
A denominator near zero. The derivatives 1/b and −a/b² grow large, and plausible denominator values may cross zero. The ratio distribution can be highly asymmetric or unstable. A narrow-looking finite interval returned by software is not evidence that local linearization is appropriate. Consider a justified ratio-specific inference method or revisit the target and data collection. Ordinary bootstrap intervals are not automatically reliable here either.
A vanishing derivative. Let Xi be independent standard normal observations, and estimate θ² at θ = 0 using X̄². The derivative of g(θ) = θ² is zero at zero, so the first-order asymptotic variance is zero. Yet the estimate is random:
√n X̄ ~ Normal(0, 1) n X̄² ~ chi-square with 1 degree of freedom
The second statement is exact in this normal example. The estimator fluctuates on the 1/n scale rather than the usual 1/√n scale. A degenerate first-order limit does not mean there is no uncertainty.
Wrong covariance or target. Dividing by n twice, using session-level independence for repeated users, or substituting a mean of individual ratios changes the answer for reasons unrelated to Taylor approximation.
Selection, missingness or heavy tails. The standard finite-variance central-limit argument needs appropriate assumptions. A larger sample does not automatically remove selection bias or restore finite moments. A small calculated standard error can coexist with a badly biased estimate.
Repeated inspection. A fixed-horizon interval is not a sequential monitoring procedure. Repeatedly checking until an interval excludes a threshold changes error rates and requires a suitable design.
8. Trade-offs and follow-up questions
The analytic method is fast and exposes how each covariance term affects uncertainty. Bootstrap resampling can help assess finite-sample behavior when the resampling unit and regularity assumptions are appropriate, but costs more computation and is not a universal fix. Simulation under plausible data-generating processes can reveal coverage failures without proving that the real process follows those assumptions.
- What if the denominator is fixed by design? Use the actual estimator covariance; a truly nonrandom denominator contributes no sampling variance. An observed random denominator should not be treated as fixed merely because it is known after collection.
- What if X equals twice Y for every user? The ratio is exactly 2 whenever the total denominator is nonzero. The residual variance is zero, matching the absence of ratio variation in that special case.
- Can automatic differentiation do the work? It can calculate a gradient, but cannot choose the estimand, independent unit or correct covariance matrix for you.
- Why not report only the ratio? Point estimates hide sampling uncertainty; uncertainty estimates must still disclose their assumptions and measurement limitations.
- What changes for a vector of metrics? Use a Jacobian and propagate the full joint covariance, then address any simultaneous-inference requirement separately.
Self-review rubric
A strong answer states the ratio target and independent sampling unit, derives the gradient, retains paired covariance and divides by n exactly once. It reproduces the residual check and distinguishes the Wald interval from a transformed interval. An excellent answer recognizes denominator instability, vanishing derivatives, clustered designs and the difference between small variance and small bias.
Sources and attribution
- Stata: Explanation of the delta method — Alan H. Feiveson's explanation of Taylor-based covariance propagation and its local-approximation condition; publication date unstated.
- MIT 18.655: Asymptotics II, Lecture 17 — Dr. Kempthorne's Spring 2016 course material on multivariate asymptotics; exact publication date unstated.
Retrieved September 27, 2026. The prompt, ratio dataset, arithmetic and failure examples are original teaching material. These references validate the method; they are not evidence that a company recently asked this question.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.