Statistical Inference and Hypothesis Testing Questions
Reasoning about uncertainty in data and drawing formal conclusions from samples. Covers probability rules and common distributions, the Central Limit Theorem, sampling, standard error, confidence intervals, and Bayesian reasoning, together with the significance-testing framework: null and alternative hypotheses, p-values, statistical power, Type I and Type II errors, effect sizes, and choosing the right test (t-test, chi-square, non-parametric). Emphasizes correctly interpreting statistical results and avoiding common misreadings of significance in business and product contexts rather than memorizing formulas.
Revenue has increased for two quarters while retention and NPS have declined. Produce a structured analysis plan to reconcile these conflicting signals: the hypotheses you would test, the metrics and cohorts you would analyze, the statistical tests you would run, and the decisions that might follow.
Sample Answer
Direct answer
Revenue up while retention and NPS decline for two quarters is a classic sign that the business is winning short-term monetization at the expense of long-term health, most often through mix shift (different, sometimes lower-fit users or a different pricing structure) rather than the product genuinely improving. The investigation should treat "revenue growth" and "retention/NPS decline" as two outcomes potentially driven by a shared, upstream cause (pricing, acquisition mix, or a product change), not evaluate them independently.
Structured elaboration
Hypotheses to test, roughly in order of how commonly they explain this exact pattern
- Pricing or monetization change increased ARPU but also increased friction or perceived value mismatch, driving both the revenue bump and dissatisfaction.
- Acquisition mix shifted toward higher-paying but lower-fit users (e.g. a paid channel or enterprise push brought in users who convert to revenue quickly but churn or complain more).
- A specific feature or experiment increased short-term monetization while degrading the core experience for a subset of users.
- One-time or concentrated revenue events (large enterprise deals, a promotion) inflate aggregate revenue while the core, ongoing user base's underlying health is actually flat or declining.
- Measurement or attribution issue: revenue recognition change or duplicate counting inflating the topline number without a real behavioral change at all.
Metrics and cohorts to analyze
| Area | What to pull |
|---|---|
| Revenue composition | MRR/ARR vs. one-time bookings, ARPU by cohort, revenue concentration (top-N accounts share of total) |
| Retention | Day 1/7/30 retention and full cohort retention curves, split pre- vs. post-change |
| Satisfaction | NPS trend by cohort and segment, support ticket volume and category, refund rate |
| Acquisition | Channel mix over the two quarters, cost per acquisition, early engagement by channel |
| Engagement | DAU/MAU, core feature usage, session depth, for revenue-contributing vs. non-contributing users |
Statistical tests and analyses to run
- Cohort retention heatmap crossed with ARPU decile: is the revenue growth concentrated in cohorts whose retention is also declining, or in a separate, healthy cohort?
- Difference-in-differences comparing cohorts before and after the suspected driver (e.g. a pricing change), against a comparable unaffected baseline, to isolate its effect on both revenue and retention.
- Regression of retention on covariates including acquisition channel and revenue tier, to test whether channel or tier explains the retention decline once controlled for, versus it being broad-based across the whole user base.
- Trend significance test on the NPS and retention time series themselves (e.g. comparing quarter-over-quarter means with appropriate variance estimates) to confirm the decline isn't within normal seasonal noise before treating it as a real signal worth acting on.
Decisions that might follow
| Finding | Likely action |
|---|---|
| Revenue growth concentrated in a mix shift toward lower-fit users | Reconsider acquisition targeting; the revenue may not be sustainable |
| Pricing change is driving both effects | Evaluate whether the near-term revenue gain is worth the retention cost; consider a more gradual or segmented pricing approach |
| Decline broad-based, not explained by mix or pricing | Deeper product investigation needed; revenue growth may be masking a real product regression |
| Decline concentrated in one specific feature/experiment | Roll back or fix that specific change, independent of the broader revenue trend |
Worked example
Suppose a cohort retention heatmap crossed with ARPU decile shows that the top 20% of ARPU users (by revenue) have 30-day retention of 38%, versus 61% for the bottom 80%. Splitting further by acquisition channel shows the top-ARPU decile is 70% sourced from a single paid channel launched two quarters ago, versus that channel being only 15% of the broader user base. This pattern (a new, concentrated acquisition channel simultaneously driving the ARPU decile up and dragging blended retention down) points toward hypothesis 2: the revenue growth and the retention/NPS decline share a common cause in acquisition mix, rather than the product itself degrading for its existing base. That reframes the fix as a channel-quality and targeting problem, not a product-quality problem, though the team should still verify NPS specifically within that channel's cohort to rule out a genuine experience gap for those users too.
Trade-offs & pitfalls
- Don't average away the story. A blended, company-wide retention number can look like a modest decline while masking a severe drop in one segment offset by stability elsewhere; always cross revenue and retention cuts by the same cohort dimensions.
- Correlation between the revenue and retention trends is not proof of a shared cause. Test the specific hypothesized mechanism (e.g. via difference-in-differences around the suspected driver) rather than asserting a link because two lines moved in opposite directions in the same period.
- NPS is a noisy, low-response-rate metric. A shift in who responds to the survey (not just how they feel) can produce an apparent decline; check response rate and respondent composition alongside the score itself.
- A quarter or two of concentrated enterprise deals is easy to over-interpret as "the business is healthy." Report revenue concentration (e.g. share from the top 10 accounts) alongside the headline number so a one-time deal isn't mistaken for durable growth.
- Acting on hypothesis 1 (pricing) versus hypothesis 2 (acquisition mix) implies very different fixes, so resist moving to remediation before the cohort-level analysis actually distinguishes between them; treating a mix-shift problem as a product or pricing problem wastes a cycle and doesn't fix the underlying issue.
State the Central Limit Theorem (CLT) precisely for IID random variables with finite variance. Explain its implications for sample means and sampling distributions in practice. Give a recommended rule-of-thumb for when the CLT can be used, and sketch a short simulation plan (pseudocode) that demonstrates CLT convergence for a highly skewed distribution.
Sample Answer
For independent, identically distributed random variables with finite variance, the Central Limit Theorem says the (properly scaled) sample mean converges in distribution to a normal distribution as the sample size grows, regardless of the shape of the original distribution. In practice this means confidence intervals and z/t-based tests built on a sample mean are approximately valid once n is "large enough," even when the underlying data itself is skewed or non-normal.
Structured elaboration
Precise statement
Let X1, X2, ..., Xn be IID with mean mu and finite variance sigma^2 less than infinity. Let X_bar_n be the sample mean. Then as n approaches infinity:
n(Xˉn−μ)dN(0,σ2)
Equivalently, for large n:
Xˉn≈N(μ,nσ2)
so the standard error of the mean is sigma divided by the square root of n, shrinking as n grows regardless of the shape of the original distribution X.
Implications for practice
- The sampling distribution of a mean becomes approximately bell-shaped even when individual observations are heavily skewed (latency, revenue, task time).
- This is what licenses z-intervals, t-tests, and z-tests on averages and proportions, even for non-normal raw data.
- Convergence is not instantaneous or uniform: the more skewed or heavy-tailed the underlying distribution, the larger n needs to be before the normal approximation is trustworthy.
Rule of thumb
- Roughly symmetric, light-tailed data: n of 30 or more is often enough.
- Noticeably skewed data: n of 50 to 100.
- Heavy-tailed or extremely skewed data (or when tail behavior itself matters): treat the CLT-based interval with caution regardless of n, and prefer bootstrap or robust methods.
Worked example
Simulate the sampling distribution of the mean of an Exponential(1) distribution (population skewness = 2, a strongly right-skewed case) for growing n, and track how quickly its skewness and standard error approach the CLT prediction:
import random, math
random.seed(11)
def sample_exp(rate=1.0):
u = random.random()
return -math.log(1 - u) / rate
def skewness(xs):
n = len(xs)
m = sum(xs) / n
m2 = sum((x - m) ** 2 for x in xs) / n
m3 = sum((x - m) ** 3 for x in xs) / n
return m3 / (m2 ** 1.5)
R = 5000
for n in [5, 10, 30, 100, 500]:
means = [sum(sample_exp() for _ in range(n)) / n for _ in range(R)]
mean_of_means = sum(means) / R
sd_of_means = math.sqrt(sum((x - mean_of_means) ** 2 for x in means) / R)
print(n, sd_of_means, skewness(means))
Running this (seed 11, R = 5,000 replicates per n) gives:
| n | empirical SE of the mean | theory: sigma / sqrt(n) | empirical skewness of the means | theory: 2 / sqrt(n) |
|---|---|---|---|---|
| 5 | 0.450 | 0.447 | 0.889 | 0.894 |
| 10 | 0.320 | 0.316 | 0.602 | 0.632 |
| 30 | 0.185 | 0.183 | 0.323 | 0.365 |
| 100 | 0.099 | 0.100 | 0.237 | 0.200 |
| 500 | 0.044 | 0.045 | 0.109 | 0.089 |
Both the standard error and the skewness of the sample-mean distribution shrink toward the CLT prediction as n grows, even starting from a distribution with skewness 2. By n = 500 the skewness of the sampling distribution of the mean (about 0.11) is far closer to a normal distribution's skewness of 0 than the original Exponential's skewness of 2.
Trade-offs & pitfalls
- The CLT describes the sampling distribution of the mean, not the distribution of individual observations; individual data points from a skewed distribution stay skewed no matter how large n gets.
- "n of 30 or more" is a rough convention, not a law; a heavily skewed or heavy-tailed distribution (or ratio metrics, or rare-event counts) can need a much larger n before the normal approximation is trustworthy.
- Sums also converge under the CLT, not just means, but variance-based reasoning must use the right scaling (variance of a sum grows with n; variance of a mean shrinks with n).
- CLT-based intervals are approximate. When in doubt, especially for skewed metrics with a business-critical decision riding on the interval, a bootstrap confidence interval is a useful cross-check.
Contrast Bayesian and frequentist approaches to A/B testing at a conceptual level. Discuss interpretation differences between credible intervals and confidence intervals, the role and influence of priors, computational trade-offs, and provide one practical scenario in product experimentation where Bayesian methods would be preferable.
Sample Answer
Direct answer
Frequentist A/B testing treats the true conversion rates as fixed unknowns and describes uncertainty through the long-run behavior of a procedure (p-values, confidence intervals) over repeated sampling. Bayesian A/B testing treats the parameters themselves as random, combines a prior belief with the observed data via Bayes' rule, and produces a posterior distribution you can make direct probability statements about. The practical trade-off is interpretability and sequential flexibility (Bayesian) versus simplicity, cheap computation, and no dependence on a prior (frequentist).
Structured elaboration
Credible interval vs. confidence interval
| Credible interval (Bayesian) | Confidence interval (frequentist) | |
|---|---|---|
| What it says | "Given the model and prior, there is a 95% probability the true parameter lies in this interval." | "This interval was produced by a procedure that covers the true parameter in 95% of repeated experiments." |
| Direct probability statement about the parameter? | Yes | No, not without additional assumptions |
| Depends on | The prior and the likelihood | Only the likelihood (sampling model) |
Role of the prior
Priors encode existing knowledge or act as regularization. An informative prior (built from historical baselines) can stabilize estimates when data are sparse, but a badly misspecified prior can bias the posterior, especially with a small sample; a weakly informative or hierarchical prior is the usual compromise, letting data dominate once there's enough of it while still borrowing strength when there isn't. Frequentist methods have no explicit prior, though penalization or shrinkage techniques play an analogous stabilizing role.
Computational trade-offs
- Frequentist tests (z-test, t-test) are closed-form and essentially free to compute at any scale, which is why they're the default for real-time dashboards across many simultaneous experiments.
- Bayesian inference can require Markov Chain Monte Carlo (MCMC) sampling for complex models, but for the common case of a Beta-Binomial conjugate model (Beta prior, Binomial likelihood for a conversion rate), the posterior is closed-form and just as cheap as the frequentist calculation.
- Bayesian sequential updating (recomputing the posterior as new data streams in) does not by itself protect against inflated error rates from repeated peeking; the peeking problem still needs a stopping rule that accounts for it (e.g. a pre-specified decision rule on the posterior, not "stop whenever it looks good").
Worked example
A team runs many small, sequential experiments on low-traffic feature variants with sparse conversion events, and wants to say "there's a 95% probability variant A beats variant B" to a product manager, plus borrow strength across related past experiments on similar features.
Using a Beta-Binomial model: Beta(α0,β0) prior on each variant's conversion rate, updated with observed successes/failures to a Beta posterior. Concretely, suppose variant A converts 22 of 50 visitors and variant B converts 14 of 50, with a weakly informative Beta(1,1) (uniform) prior on each arm:
pA∣data∼Beta(1+22, 1+50−22)=Beta(23,29) pB∣data∼Beta(1+14, 1+50−14)=Beta(15,37)import numpy as np
rng = np.random.default_rng(42)
a_A, b_A = 23, 29
a_B, b_B = 15, 37
samples = 1_000_000
pA = rng.beta(a_A, b_A, samples)
pB = rng.beta(a_B, b_B, samples)
p_a_beats_b = (pA > pB).mean() # 0.9503
Both posteriors are closed-form Betas, so sampling is just the simplest way to compare two distributions; an exact numerical integral would give the same answer. With these two posteriors, the direct statement "P(pA>pB∣data)=0.95" answers exactly the question the PM is asking, which the frequentist p-value does not, and now it traces back to real counts (22 conversions of 50 for A, 14 of 50 for B) instead of being asserted.
Trade-offs & pitfalls
- Bayesian output is easier to explain to a non-technical stakeholder ("95% probability A is better") than a p-value or a frequentist confidence interval, but that ease of interpretation depends on the audience trusting the prior, which is a modeling choice, not a fact.
- An informative prior chosen after seeing early results (rather than from genuinely prior information) quietly reintroduces the same p-hacking risk Bayesian methods are sometimes assumed to avoid.
- Reaching for full MCMC when a conjugate model would do adds compute cost and diagnostic burden (convergence checks, effective sample size) with no benefit; match the model complexity to the actual question.
- Neither framework is immune to multiple-comparisons risk when running "many small, sequential" experiments and reporting only the ones that look good; that discipline (pre-specification, correction, or hierarchical pooling) is needed regardless of which paradigm you use.
Given sample revenue per user values [50, 55, 60, 5000], describe two statistical methods to detect outliers and apply them to flag which values are outliers using the IQR rule and a Z-score threshold of 3. Explain how flagged outliers would affect mean and median reporting and one remediation strategy.
Sample Answer
On the sample [50, 55, 60, 5000], neither the IQR rule (1.5 times IQR beyond Q1/Q3) nor a Z-score threshold of 3 actually flags 5000 as an outlier, which is a useful lesson on its own: both rules can miss an obvious outlier when the sample is this small, because a single extreme value distorts the very statistics (IQR, mean, standard deviation) used to detect it. The bigger practical point is that the mean (1291.25) is not a trustworthy summary of this data, while the median (57.5) is.
Structured elaboration
Method 1: IQR rule
Sort the data, split into halves, and take the median of each half as Q1 and Q3:
IQR=Q3−Q1
outlier if x<Q1−1.5IQR or x>Q3+1.5IQR
Method 2: Z-score
z=sx−xˉ
flag any point with the absolute value of z at least 3 (using the sample or population standard deviation; both are shown below, and they agree on the conclusion here).
Worked example
Data sorted: [50, 55, 60, 5000].
IQR rule:
- Q1 = median(50, 55) = 52.5
- Q3 = median(60, 5000) = 2530
- IQR = 2530 - 52.5 = 2477.5
- Bounds: [52.5 - 1.5(2477.5), 2530 + 1.5(2477.5)] = [-3663.75, 6246.25]
- 5000 is inside [-3663.75, 6246.25], so the IQR rule does not flag it.
Z-score rule:
- Mean = (50+55+60+5000)/4 = 1291.25
- Population standard deviation is about 2141.25 (sample standard deviation is about 2472.50)
- z(5000) = (5000 - 1291.25) / 2141.25, which is about 1.73 with the population standard deviation, or about 1.50 with the sample standard deviation
- Neither exceeds the threshold of 3, so the Z-score rule with threshold 3 also does not flag it.
(all values verified with python3's statistics module: mean 1291.25, population standard deviation 2141.25, sample standard deviation 2472.50, z(5000) with population standard deviation is 1.732)
Both rules fail here because n = 4 is far too small for either method's underlying assumptions. Q3 itself is contaminated by the outlier since it is the median of {60, 5000}, and the mean and standard deviation are both dragged upward by the same point that inflates them, making the z-score understate its own extremity.
Impact on mean vs median, and remediation
- Mean (1291.25) is wildly unrepresentative: it is more than 20 times any of the other three values.
- Median (57.5) reflects the typical value well and is unaffected by 5000's magnitude, only its rank.
- Remediation: investigate 5000 first (a data entry error versus a genuinely high-value customer). If it is legitimate but unrepresentative for a "typical revenue per user" metric, report the median or a trimmed mean alongside the full mean, or winsorize (cap) extreme values above a chosen percentile, and call out large accounts separately rather than letting them silently dominate an average.
Trade-offs & pitfalls
- Both rules are much less reliable at small n; with only 4 points, one extreme value can shift Q3 or the standard deviation enough to mask itself. Neither rule "failing" here means the value is not actually anomalous. It means the tools were not built for n = 4.
- The IQR rule is robust to the outlier's magnitude (it depends on ranks) but not to a small sample where the quartiles themselves are computed from very few points.
- The Z-score rule is directly vulnerable to the outlier: the outlier itself inflates the standard deviation used to judge it, which can hide even large true outliers (masking).
- Silently dropping a flagged, or even an unflagged but suspicious, value without investigating whether it is a data error or a real, important case risks deleting real signal (a legitimate enterprise customer) rather than noise.
In a linear regression model predicting revenue per user, explain the difference between a confidence interval for the mean response at a particular x* and a prediction interval for a new observation at x*. Provide formulas (assuming homoscedastic Gaussian errors) and describe how interval widths change with sample size and residual variance.
Sample Answer
Direct answer
A confidence interval at x∗ captures uncertainty about the average outcome for that x value (a population quantity); a prediction interval at x∗ captures uncertainty about one new individual observation at that x value. The prediction interval is always wider because it has to account for both the uncertainty in estimating the regression line and the irreducible noise around that line, while the confidence interval only accounts for the first source.
Structured elaboration
Setup. Simple linear regression y=β0+β1x+ε, ε∼N(0,σ2) i.i.d. (homoscedastic Gaussian errors). Let y^(x∗)=β^0+β^1x∗, s2=RSS/(n−2), and Sxx=∑i(xi−xˉ)2.
Confidence interval for the mean response E[y∣x∗]:
y^(x∗)±tn−2,α/2sn1+Sxx(x∗−xˉ)2This only reflects how precisely you've pinned down the regression line itself, since E[y∣x∗] is a fixed number, not a random draw.
Prediction interval for a new observation ynew at x∗:
y^(x∗)±tn−2,α/2s1+n1+Sxx(x∗−xˉ)2The extra "1" inside the square root is exactly σ2 worth of individual-observation noise that a single future draw carries and that never goes away, regardless of how much data you have.
How the widths change:
| Factor | Confidence interval | Prediction interval |
|---|---|---|
| Sample size n→∞ | Width →0 | Width → a floor set by 2zα/2σ (never zero) |
| Residual variance s2 up | Wider (linear in s) | Wider, and dominates once 1≫1/n |
| x∗ far from xˉ | Wider (via (x∗−xˉ)2/Sxx) | Wider, but the effect is proportionally smaller since the "1" term dominates |
The practical takeaway: growing the sample only tightens the CI meaningfully; it barely tightens the PI, because the PI's floor is set by σ itself, not by how well you know β0,β1.
Worked example
Simulated revenue-per-user regression (pinned seed, n=40):
import numpy as np
from scipy import stats
rng = np.random.default_rng(7)
n = 40
x = rng.uniform(1, 10, n)
y = 5.0 + 3.0 * x + rng.normal(0, 4.0, n) # true b0=5, b1=3, sigma=4
xbar, Sxx = x.mean(), np.sum((x - x.mean())**2)
b1 = np.sum((x - xbar) * (y - y.mean())) / Sxx
b0 = y.mean() - b1 * xbar
resid = y - (b0 + b1 * x)
s = np.sqrt(np.sum(resid**2) / (n - 2))
xstar = 8.0
yhat = b0 + b1 * xstar
tcrit = stats.t.ppf(0.975, n - 2)
se_mean = s * np.sqrt(1/n + (xstar - xbar)**2 / Sxx)
se_pred = s * np.sqrt(1 + 1/n + (xstar - xbar)**2 / Sxx)
print(f"fitted: b0={b0:.3f}, b1={b1:.3f}, s={s:.3f} (xbar={xbar:.3f}, Sxx={Sxx:.2f})")
print(f"yhat(x*=8.0) = {yhat:.3f}, t_crit(df={n-2}, .975) = {tcrit:.3f}")
print(f"95% CI for mean response: [{yhat-tcrit*se_mean:.3f}, {yhat+tcrit*se_mean:.3f}] half-width = {tcrit*se_mean:.3f}")
print(f"95% PI for new observation: [{yhat-tcrit*se_pred:.3f}, {yhat+tcrit*se_pred:.3f}] half-width = {tcrit*se_pred:.3f}")
Output:
fitted: b0=2.027, b1=3.569, s=3.218 (xbar=5.238, Sxx=282.42)
yhat(x*=8.0) = 30.577, t_crit(df=38, .975) = 2.024
95% CI for mean response: [29.091, 32.063] half-width = 1.486
95% PI for new observation: [23.895, 37.259] half-width = 6.682
The prediction interval is about 4.5 times wider than the confidence interval at the same x∗, entirely because of the extra "1" term, since both intervals use the same y^(x∗), s, tn−2, n, and (x∗−xˉ)2/Sxx.
Trade-offs & pitfalls
The most common mistake in practice is reporting a confidence interval when the actual question is about a single future user (e.g. "what revenue should we expect from a new customer with these attributes") - that calls for a prediction interval, and using the CI there systematically understates risk. The reverse mistake, reporting a PI when summarizing the average effect across a segment, needlessly widens the story and can make a real, precisely-estimated average look uncertain. Both formulas also assume homoscedastic Gaussian errors; if the residual spread grows with x (heteroscedasticity) or is skewed, these closed-form intervals are wrong in both center and width, and a weighted-least-squares model or a bootstrap-based interval that estimates residual spread locally is the more defensible choice.
Unlock Full Question Bank
Get access to all Statistical Inference and Hypothesis Testing interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.