The interview problem

Practice prompt

An experiment has 1,000 observations from 100 users, ten observations each. Within-user correlation is estimated as 0.4. Explain why treating all rows as independent understates uncertainty. Compare this with unequal-weight and time-series effective sample sizes, and recommend how to report the experiment.

Original ML-fundamentals practice, not a reported company interview. Examples are hypothetical. Primary technical reference retrieved September 27, 2026; interview date not applicable.

Quick answer

Effective sample size compares an estimator’s variance with that from independent, equally weighted observations. The correct formula depends on clustering, autocorrelation or weighting. It is an approximation for a stated estimator and model, not a universal replacement for the actual sample count.

1. Define effective relative to an estimator

Effective sample size, or ESS, compares the variance of a particular estimator with a specified independent-sampling reference. It is not a universal count of useful records. Different outcomes, estimators and dependence structures can produce different ESS values on the same dataset.

For an equally weighted mean of n observations with common variance σ², independence gives variance σ²/n. With dependence, variance is n⁻² times the sum of all pairwise covariances, including the diagonal variances. Matching that variance to σ²/n_eff defines a variance-equivalent sample size. This calculation addresses variance, not selection bias or whether the sample represents the desired population.

2. Derive the repeated-user example

Assume K independent users, m observations per user, common row variance σ² and common correlation ρ between any two distinct observations from the same user. Cross-user covariances are zero. There are Km diagonal terms and K m(m−1) off-diagonal terms. Therefore Var(mean)=σ²/[Km] × [1+(m−1)ρ]. The design effect is 1+(m−1)ρ.

With K=100, m=10 and ρ=0.4, the design effect is 4.6 and n_eff=1,000/4.6≈217.39. The true standard error under this model is √4.6≈2.145 times the independent-row standard error. If σ=1, the naive standard error is 0.03162, whereas the model-based value is approximately 0.06782.

If ρ=1, every user's ten observations are redundant for this mean and ESS is 100. If ρ=0, ESS is 1,000 under the stipulated covariance model. ESS exceeding the number of users does not permit treating 217 observations as independent clusters for degrees of freedom. There are still only 100 independent user clusters.

Unequal cluster sizes, different within-user correlations and informative activity levels invalidate this simple formula. A row-average outcome weights prolific users more heavily than an average of user means. Choose the estimand before collapsing data or claiming that deduplication leaves the scientific question unchanged.

3. Derive the weight-concentration diagnostic

For independent observations of equal variance and fixed nonnegative normalized weights aᵢ summing to one, Var(ΣaᵢXᵢ)=σ²Σaᵢ². Equating this with σ²/n_eff gives n_eff=1/Σaᵢ², or (Σwᵢ)²/Σwᵢ² for unnormalized weights. Equal weights yield n; concentrating all weight on one observation yields one.

Take 100 observations: ten have weight nine and ninety have weight one. Weight sum is 180 and squared-weight sum is 10×81+90=900. The diagnostic ESS is 180²/900=36. Scaling all weights by the same positive constant leaves this unchanged.

Those assumptions are essential to the variance interpretation. Outcome-dependent importance weights, unequal outcome variances and correlated observations require a richer variance calculation. A high weight ESS cannot establish support coverage or absence of bias. This guide uses the diagnostic to contrast sources of information loss; the linked importance-sampling guide treats weighted estimation in detail.

With fixed normalized weights a and covariance matrix Σ, the weighted mean variance is aᵀΣa. Weight concentration and dependence interact through this expression. Dividing weight ESS by an unrelated cluster design effect is not generally justified unless the joint assumptions establish that factorization.

4. Contrast serial dependence

For a stationary scalar sequence with marginal variance σ² and lag correlations ρₖ, Var(mean)=σ²/n × [1+2Σₖ₌₁ⁿ⁻¹(1−k/n)ρₖ]. If correlations are summable and n is large relative to their decay, the bracket is approximately τ=1+2Σₖ≥₁ρₖ, giving n_eff≈n/τ.

For a stationary AR(1) example with correlation parameter φ=0.8, ρₖ=0.8ᵏ and τ=(1+φ)/(1−φ)=9. Thus 900 draws have an asymptotic ESS near 100 for the mean. This is an approximation, not the exact finite-sample value. A nonstationary trend cannot be repaired merely by inserting estimated autocorrelations into the stationary formula.

Negative serial correlation can yield ESS above the raw draw count relative to independent sampling. For φ=−0.5, τ=1/3 and the asymptotic mean ESS is about 3n. This does not create extra observations; anticorrelation reduces mean variance. In contrast, the nonnegative weight-concentration diagnostic cannot exceed n.

Stan's documentation treats effective sample size as a diagnostic alongside convergence assessment and distinguishes bulk and tail behavior. A good ESS for one scalar mean does not prove accurate tail quantiles or exploration of all modes. Do not apply an MCMC diagnostic mechanically to arbitrary user-event data.

5. Match uncertainty to how data was collected

target estimand and outcome
            ↓
independent sampling / randomization unit
            ↓
weights + cluster structure + temporal dependence
            ↓
appropriate variance or resampling procedure
            ↓
raw count + independent units + uncertainty + limitations

For a user-randomized experiment, resample users within treatment arms, preserving each sampled user's assignment and all their observations; retain any additional blocking or stratification required by the design. Estimate the treatment contrast using the intended user- or event-weighting policy. The simple one-arm mean formula is not automatically the variance of a ratio metric or a treatment difference with unequal allocation.

For time-series estimates, use methods that preserve the relevant serial structure, such as a justified block bootstrap or a long-run variance estimator. For weighted independent data, retain the weight-generation process and account for estimated weights when relevant. When only a few independent clusters exist, large-sample cluster intervals can be unreliable; more rows within those clusters do not fix the shortage.

Report raw rows, distinct sampling units, cluster-size distribution, weight concentration, chosen method and uncertainty interval. Treat estimated correlation and ESS as uncertain quantities, not exact properties of the dataset. Validate using simulations matched to plausible dependence, and check sensitivity to clustering and weighting choices.

6. Spend the next data-collection budget wisely

Under the equal-cluster model, 100 users with 20 observations each and ρ=0.4 give ESS=2,000/[1+19×0.4]≈232.56. Doubling observations per existing user increases ESS only from 217.39 to 232.56, about 7%. Instead, 200 independent users with ten observations each give ESS=2,000/4.6≈434.78, twice the original.

This comparison assumes equal cost per observation, unchanged variance/correlation and the same estimand. Recruiting new users may cost more, and repeated observations may answer a longitudinal question that additional users cannot replace. Use the calculation to expose the trade-off rather than prescribing one collection strategy universally.

Duplicating records, oversampling the same examples or generating repeated labels from one shared template does not automatically create independent evidence. Conversely, deleting correlated observations solely to raise an ESS-to-row ratio can discard information. Optimize uncertainty for the relevant cost and target, not a diagnostic ratio.

7. Follow-ups and self-review

Follow-ups: Is ESS a count of independent users? No. Does high ESS remove sampling bias? No. Can serial ESS exceed n? Yes, under variance-reducing dependence. Can nonnegative weight ESS exceed n? No. Can two ESS penalties simply be multiplied? Only with a justified joint model.

Score 0–2 each for variance definition, repeated-user derivation, weighted assumptions, stationary-sequence limits and design-aware reporting. A strong answer keeps the estimand, independent units and uncertainty method aligned.

Spread the same budget across more users

Under an equal-size cluster model with intraclass correlation ρ = 0.4, the design effect is 1 + (m − 1)ρ. A budget of 1,000 observations collected as 100 users × 10 measurements gives a design effect of 4.6 and an approximate ESS of 1,000/4.6 = 217.4.

Collecting 250 users × 4 measurements instead gives a design effect of 2.2 and ESS ≈ 454.5. The nominal observation count is unchanged, but sampling more independent users provides more information under this model. If recruiting another user is expensive, compare the extra recruitment cost against that gain.

The calculation assumes independent users, equal cluster sizes and the same within-user correlation in both designs. A user-level treatment still has only 100 or 250 independent assignment units, respectively. Unequal sizes, informative sampling or a different outcome can invalidate this shortcut; use a design-aware variance estimate for the actual analysis.

Original worked follow-up, reviewed October 7, 2026. Reference: Stan: effective sample size and estimation.

Sources and next steps

The cluster and weight derivations, examples and data-collection comparison are original. Continue with importance-sampling variance for support and heavy-weight failures, or bootstrap reasoning for resampling choices.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.