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.
You track "revenue per user" as a primary metric. Explain the pitfalls of ratio metrics, and propose robust alternatives or preprocessing plus how you would analyze and communicate them in experiment results.
Sample Answer
Direct answer
Ratio metrics like revenue per user are dangerous because they collapse two moving parts (a numerator and a denominator) into one number, and because revenue-like numerators are almost always heavy-tailed: a handful of large purchases can dominate the mean and make an experiment look like a clear win or loss when the typical user didn't change at all. The fix is to report a robust summary alongside the mean (median, trimmed mean, or a capped/winsorized version), define the denominator precisely and consistently across arms, and segment before concluding "the metric moved."
Structured elaboration
Pitfalls of ratio metrics
| Pitfall | Mechanism |
|---|---|
| Denominator drift | If "users" is defined differently between control and treatment (e.g. active users vs. all assigned users), the ratio changes mechanically, not because behavior changed |
| Heavy tails / whales | A small number of large-spend users can move the mean revenue-per-user substantially while the median user is unaffected |
| Simpson's paradox | If treatment shifts the mix of users (e.g. more new, low-spend users enter the treatment arm), the aggregate ratio can move in a direction opposite to every individual segment's true effect |
| Zero-inflation | Many products have a large mass of $0 users; the ratio's distribution is a mixture of "never pays" and "pays something," which a single mean glosses over |
Robust alternatives and preprocessing
- Median or other percentiles (P50, P90): insensitive to a handful of extreme values, at the cost of ignoring exactly how much the tail moved.
- Trimmed or winsorized mean: cap or remove the top X% before averaging; keeps more information than the median while limiting whale influence.
- Log-transform (e.g. log(1+revenue)): compresses the tail and stabilizes variance for a mean-based test; interpret results multiplicatively (geometric-mean-like) rather than additively.
- Fixed, pre-registered denominator: define "user" identically in both arms (e.g. "assigned at randomization," not "active during the window") so the denominator can't drift with treatment-induced behavior.
Analyzing and communicating results
- Pre-specify the primary metric and its exact numerator/denominator/transform before the experiment runs.
- Report mean, median, and a capped/winsorized mean together, plus a bootstrap CI for each (since ratio-metric sampling distributions are rarely well approximated by a simple closed-form CI).
- Check whether the treatment changed the user mix (e.g. share of new vs. returning users); if so, present both the raw aggregate and a mix-adjusted (segment-weighted) comparison.
- In the writeup, lead with whichever statistic best reflects the decision at hand, but always show all of them side by side so a stakeholder can see whether a "win" is broad-based or driven by a few large accounts.
Worked example
Simulated per-user revenue in a control arm (mostly small or zero purchases), and a treatment arm identical except for one added large ("whale") purchase, pinned seed:
import numpy as np
rng = np.random.default_rng(seed=99)
n = 1000
control = rng.choice([0, 0, 0, 5, 10, 20], size=n,
p=[0.5, 0.2, 0.1, 0.1, 0.06, 0.04]).astype(float)
treatment = control.copy()
rng.shuffle(treatment)
treatment[0] += 5000 # one large purchase added
mean_c, median_c = control.mean(), np.median(control) # 2.195, 0.0
mean_t, median_t = treatment.mean(), np.median(treatment) # 7.195, 0.0
lift_mean = (mean_t - mean_c) / mean_c * 100 # 227.8%
cap = np.percentile(control, 99) # 20.0
treat_wins = np.clip(treatment, None, cap)
lift_winsorized = (treat_wins.mean() - mean_c) / mean_c * 100 # 0.7%
The mean shows a 227.8% lift in revenue per user (from 2.195 to 7.195), which looks like a spectacular win. The median lift is 0%: the typical user's behavior is completely unchanged. Winsorizing at the control arm's 99th percentile (capping treatment at 20) brings the "lift" down to 0.7%, essentially nothing. All three numbers come from the exact same underlying data; the only difference is one added $5,000 purchase in a sample of 1,000 users. Reporting the mean alone would tell a story about broad-based product improvement that the data doesn't actually support.
Trade-offs & pitfalls
- Don't pick whichever statistic tells the story you want. Report mean, median, and a robust variant together as standard practice, not as a reaction to a surprising result.
- Winsorizing/trimming thresholds should be set from a pre-specified rule (e.g. control-arm percentile), not tuned after seeing the treatment data, or you've reintroduced exactly the kind of post-hoc flexibility that inflates false positives.
- Log-transforms complicate interpretation for stakeholders; a "12% lift in log-revenue" needs translation into a business-meaningful statement (roughly a 12% multiplicative lift in revenue, not an additive one), and zero values break a plain log transform (hence log(1+x)).
- If most of a real lift genuinely comes from a small number of high-value users, that's not automatically a false positive. It changes what to do next: consider whether that's the intended (e.g. a premium-tier feature) or unintended (e.g. one enterprise account skewing an SMB experiment) outcome, rather than assuming the whale should always be excluded.
- Segment-level Simpson's paradox checks matter as much as the tail-robustness fixes. A metric can be tail-robust and still misleading if the treatment changed who's in the denominator.
Define the null hypothesis and the alternative hypothesis in your own words, then explain the difference between a one-tailed and a two-tailed test. Using a concrete example, such as testing whether a change increases a metric versus testing whether it simply changes the metric in either direction, state both hypotheses and explain which test direction you would choose and why.
Sample Answer
Direct answer
The null hypothesis (H0) is the "nothing changed" default you assume true until the data gives strong enough evidence to reject it. The alternative hypothesis (H1, or Ha) is the specific claim you're trying to find evidence for. A two-tailed test's alternative allows the effect to go either direction, so an increase or a decrease both count as evidence against H0. A one-tailed test's alternative commits in advance to only one direction, and only evidence in that direction can ever reject H0, however extreme the result is in the other direction, a one-tailed test treats it as not significant.
Structured elaboration
Defining the two hypotheses
- H0: the status-quo claim, typically "no difference" or "no effect," for example mu_new equals mu_old, or p_new equals p_old. It's what you'd believe by default absent evidence otherwise.
- H1 (or Ha): the claim there is reason to suspect and want the data to support. Hypothesis testing is structured to make H0 the thing you disprove, not the thing you prove; you never "accept H0," you either reject it or fail to reject it.
One-tailed versus two-tailed
A two-sided alternative is symmetric: H1 says the parameter is simply not equal to the null value, so evidence in either direction, higher or lower, counts against H0. A one-sided alternative picks a direction in advance, for example H1 says the new value is greater than the old one, and the entire significance level (say 5%) is allocated to that one tail of the distribution. That gives more power to detect an effect in that specific direction for the same sample size, at the cost of being structurally blind to an effect in the other direction.
Worked example
Testing whether a new checkout flow changes conversion rate, where p_old is the current rate and p_new is the new flow's rate:
Testing whether it changes the metric in either direction, appropriate when you'd act on either a lift or a drop, for example rolling back a regression just as readily as shipping an improvement:
H0:pnew=pold,H1:pnew=poldTesting whether it increases the metric, appropriate only when a decrease and "no effect" would be handled identically, for example neither would ship:
H0:pnew≤pold,H1:pnew>poldWhich to choose, and why
Choose the two-sided test whenever a result in either direction would change the decision, which is the common case in product work: a checkout redesign that decreases conversion is just as actionable, roll it back, as one that increases it, so a one-sided test built only to detect increases could let a real, harmful regression show up as "not significant" simply because the test structurally can't reject in that direction. Choose a one-sided test only when a result in the "wrong" direction is genuinely not actionable, and that decision was made before seeing the data. For example, a pure cost-reduction change to backend infrastructure where the only actions are "doesn't hurt the metric" versus "measurably hurts it," never "significantly helped," might reasonably justify a directional test. That's a narrow case, though, and switching to one-sided after peeking at a result that's "almost significant" two-sided is a form of p-hacking, not a legitimate use of the one-sided test.
Trade-offs and pitfalls
- One-sided tests have more power for a fixed alpha and sample size, but that power gain exactly matches giving up the ability to detect the opposite effect. It isn't a free lunch, it's a bet on direction made in advance.
- Choosing the tail after seeing which direction the data leans is a common way to quietly gain extra apparent significance without disclosing it. Always fix the direction, or commit to two-sided, before collecting data, ideally in writing.
- Default to two-sided unless there is a specific, pre-committed, defensible reason not to. When a one-sided test is used, say so explicitly in the write-up along with the pre-registered direction and rationale, so a reader can judge whether the choice was made honestly.
Explain the difference between user-level, session-level, and event-level units of analysis. Give an example where using event-level aggregation would mislead a product decision, and recommend the correct unit-of-analysis for measuring feature adoption.
Sample Answer
Direct answer
The unit of analysis is the entity you count and average over when computing a metric. Event-level counts every individual action, session-level counts per visit, and user-level counts per unique person. For measuring feature adoption specifically, the correct unit is user-level, because adoption is a question about how many people used a feature, and event-level or session-level aggregation lets a small number of heavy users dominate the number and make adoption look far higher than it really is.
Structured elaboration
- Event-level. Each recorded action is one row (e.g. every
chat_sendevent). Good for measuring volume and throughput, but says nothing about how many distinct people generated that volume. - Session-level. A time-bounded visit is the unit (e.g. actions per session, session duration). Good for engagement intensity within a visit, but a user with 10 sessions counts 10 times.
- User-level. Each unique person, over a defined window, is the unit (e.g. percent of monthly active users who used a feature at least once). Good for adoption, retention, and anything answering "how many people."
The reason event-level aggregation misleads for adoption specifically is a units mismatch: "adoption" is inherently a statement about people, but a raw event count is dominated by whoever generates the most events, which is rarely a representative measure of how widely a feature spread across the user base.
Worked example
Suppose a new chat feature is live for a product with 10,000 monthly active users. In one month, the feature generates 597 chat_send events. If those events came from 300 distinct users sending on average ~2 messages each, an event-level headline of "597 uses this month" and a user-level headline of "300 of 10,000 users adopted the feature (3.0%)" describe the same underlying data very differently. Now suppose most of that volume is concentrated: 3 power users (support agents testing the feature, or a bot account) send 100 messages each (300 events), and the remaining 297 events come from 297 distinct users sending one message each. Event-level volume (597) barely tells you anything about reach. User-level adoption is unambiguous: 300/10,000=3.0% of MAU tried the feature at least once, which is the number a PM deciding whether to invest further in the feature actually needs. Reporting "597 uses" to that PM without the user-level breakdown risks a decision to double down on a feature that only 3% of the base has touched.
Trade-offs & pitfalls
User-level adoption is the right primary metric, but it should be paired with a session- or event-level intensity metric (actions per active user, or per session) to distinguish "many people tried it once" from "many people use it repeatedly," since those imply very different next steps. A common mistake is picking the time window inconsistently with the metric's intent: reporting "monthly adoption" but computing it over a 7-day window inflates apparent adoption relative to the stated period. It is also worth deduplicating bot or internal-test accounts before computing user-level adoption, since a handful of automated accounts generating disproportionate event volume can distort even a correctly-chosen user-level metric if they are not excluded.
Explain in plain terms the difference between correlation and causation. Give a concise, business-relevant example where a naïve correlation would mislead a product decision, and describe one practical analytic approach that increases confidence in a causal claim.
Sample Answer
Correlation means two variables move together in the data; causation means changing one variable actually produces a change in the other. A correlation can arise from genuine causation, reverse causation, a shared underlying cause (a confounder), or simple coincidence, so observing that two things move together is never by itself enough to justify acting on one to change the other.
Structured elaboration
Why correlation can mislead
| Pattern | What it looks like | What's actually happening |
|---|---|---|
| Genuine causation | A moves, then B moves | A really does affect B |
| Reverse causation | A and B move together | B is actually driving A, not the other way around |
| Confounding | A and B move together | A hidden third variable drives both A and B |
| Coincidence | A and B move together, briefly or in a small sample | No real relationship; noise or a short-lived pattern |
A business decision that assumes the first pattern, when the truth is a confounder or reverse causation, can spend money or effort changing the wrong thing.
A concrete failure mode
Suppose product analytics show that users who enable push notifications spend meaningfully more per month than users who do not. The naive read is "notifications drive spend, so force-enable them for everyone." The more likely explanation is a confounder: users who are already more engaged with the product are both more likely to opt into notifications and more likely to spend, because engagement drives both. Forcing notifications on disengaged users would not manufacture the same spend, and could instead increase churn from users who find the notifications unwanted.
Increasing causal confidence
The strongest practical fix is a randomized controlled experiment (an A/B test): randomly assign users to receive the notification prompt versus not, which breaks the link between the confounder (engagement) and treatment assignment, so any difference in downstream spend between arms can be attributed to the notification itself. When randomization is not possible (the change already shipped to everyone, or it is not feasible to withhold from a control group), quasi-experimental methods like propensity-score matching (pairing treated and untreated units that look similar on observed characteristics before comparing them) or difference-in-differences (comparing the change over time in the affected group against the change in an unaffected group) can partially control for observed confounders, at the cost of resting on assumptions (no unobserved confounding, or parallel trends, meaning the two groups would have moved the same way over time if the change had never happened) that a true randomized experiment does not need.
Trade-offs & pitfalls
- A/B tests are the gold standard for causal confidence but are not always feasible: some changes cannot ethically or practically be withheld from a subset of users, and some effects only show up over a longer horizon than a typical test window.
- Quasi-experimental methods (matching, diff-in-diff, instrumental variables) reduce but do not eliminate confounding risk; they are only as good as the confounders the team thought to measure and control for.
- "We increased causal confidence" is not the same as "we proved causation." Even a well-run experiment estimates an average effect for the population tested, under the conditions tested, not a universal law.
- The instinct to act quickly on a compelling correlation is strongest exactly when the stakes are highest, which is also when getting the causal story wrong is most expensive.
A logging bug during an experiment caused the assignment key to be based on session ID instead of user ID, creating imbalance in demographics between control and treatment. Explain how this confounding could bias estimated treatment effects, diagnostics you would run to quantify imbalance, and remediation options including trade-offs.
Sample Answer
Direct answer
Assigning by session instead of by user breaks the core promise of randomization: users with more sessions (often a specific demographic, e.g. more engaged or mobile-heavy users) get more chances to land in whichever arm the assignment happens to favor for them, so the two arms end up systematically different on user characteristics, not just on treatment. That confound means the estimated treatment effect is contaminated by a demographic difference between arms, and no amount of additional data collection under the same buggy assignment will fix it, since the bias doesn't shrink with sample size.
Structured elaboration
Why this biases the estimate
Proper randomization guarantees that, in expectation, treatment and control are balanced on every covariate, observed or not. Session-based assignment breaks this guarantee whenever session behavior correlates with anything that also affects the outcome: for instance, if the same user is more likely to be re-assigned to the same or different arm across sessions in a way that isn't uniform, or if certain user types (heavy, frequent-session users) end up over- or under-represented in one arm because of how the hashing or bucketing interacted with session versus user identity. The result is a mix of the true treatment effect and a demographic difference between arms, and the two are not separable using only the experiment's headline outcome metric.
Diagnostics to quantify imbalance
- Balance tests on pre-treatment covariates. For each key covariate (device type, tenure, geography, prior activity level), compute the standardized mean difference (SMD) between arms:
A common flag threshold is ∣SMD∣>0.1; run this across every covariate you have, not just the one you suspect.
- Predictive check. Train a simple classifier (e.g. logistic regression) to predict treatment assignment from pre-treatment covariates. An AUC (Area Under the ROC Curve, a 0-to-1 score where 0.5 means the classifier does no better than a coin flip and 1.0 means it perfectly separates the two arms) meaningfully above 0.5 is direct evidence that assignment isn't independent of user characteristics, which is exactly what should be true under correct randomization.
- Time and cohort plots. Plot the arm split over time and by device/geography to spot whether the imbalance is a constant offset or grows for higher-session users specifically, which helps confirm the mechanism (session-based hashing) rather than just detect that something is wrong.
Remediation options
| Option | How it works | Trade-off |
|---|---|---|
| Re-run the experiment with correct (user-level) assignment | Cleanest fix, eliminates the confound entirely | Costs time, and any seasonality between the original and re-run window is a new confound to watch for |
| Covariate-adjusted regression (include the imbalanced covariates as controls) | Model the outcome with the imbalanced covariates included, so the treatment coefficient is adjusted for the observed imbalance | Still vulnerable to unobserved confounders correlated with session behavior; depends on correct model specification |
| Inverse-probability weighting (propensity-score reweighting) | Reweight observations so the weighted sample looks balanced on observed covariates | Requires a well-specified propensity model and enough overlap between arms; large weights can blow up variance |
| Stratified analysis (e.g. within device type or within tenure bucket) | Estimate the effect within homogeneous strata where imbalance is smaller, then aggregate | Loses power; still assumes no unobserved confounding within strata |
Worked example
Simulated imbalance where session-based assignment happens to over-represent mobile users in the treatment arm, pinned seed:
import numpy as np
rng = np.random.default_rng(seed=55)
n_ctrl, n_treat = 3000, 3000
mobile_ctrl = rng.binomial(1, 0.45, n_ctrl) # baseline mobile share
mobile_treat = rng.binomial(1, 0.58, n_treat) # imbalance introduced by the bug
p_ctrl, p_treat = mobile_ctrl.mean(), mobile_treat.mean() # 0.451, 0.583
pooled_var = (p_ctrl*(1-p_ctrl) + p_treat*(1-p_treat)) / 2
smd = (p_treat - p_ctrl) / np.sqrt(pooled_var) # 0.268
Here, mobile-user share is 45.1% in control versus 58.3% in treatment, giving SMD=0.268, well above the 0.1 flag threshold. If mobile users also tend to have different baseline conversion rates than desktop users (plausible, and easy to check directly), this single covariate imbalance alone is large enough to meaningfully distort the estimated treatment effect, independent of whatever the treatment itself does. This is the kind of concrete, quantified result that justifies escalating from "we have a bug" to "we cannot trust this experiment's headline number without correction."
Trade-offs & pitfalls
- Adjustment methods only fix observed imbalance. If the same assignment bug correlates with something you didn't measure (e.g. a behavioral trait that also drives session frequency), covariate adjustment and reweighting cannot detect or correct for it; only a clean re-run removes that risk entirely.
- Large propensity weights are a warning sign, not just a nuisance. If the reweighting requires extreme weights to balance the arms, it usually means limited overlap between the imbalanced groups, and the adjusted estimate becomes unstable and hard to trust.
- A quick "re-run it" instinct isn't free. If the feature has since shipped elsewhere, seasonality shifted, or the bug affected historical data used for other decisions, a clean re-run needs its own sanity checks, not just a fresh randomization.
- The diagnostic step matters even if you plan to re-run anyway. Quantifying the imbalance (and whether it's large enough to plausibly explain the observed effect) tells you whether the original result should be treated as "wrong" or merely "less certain," which affects any decisions already made based on it.
- Prevention beats remediation. Once found, the underlying fix is an engineering one: assignment key auditing and unit tests that verify hashing is done on the intended identity field, since this exact class of bug (session vs. user key) recurs across teams that don't have that check.
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.