Core Statistical Inference and Distribution Fundamentals

Medium · Statistics & Math · Data Scientist · Onsite

Prompt

During a timed data science fundamentals screen, you are asked to answer five short probability and statistical inference questions concisely and accurately:

  1. For a random variable X ~ Poisson(λ) with rate parameter λ > 0, what are its expected value E[X] and its variance Var(X)?
  2. Suppose you collect n independent observations from a population whose true standard deviation σ is known. Write the formula for a two-sided 95% confidence interval around the unknown population mean μ.
  3. Under what conditions should you run a two-sample t-test rather than a two-sample z-test when comparing group means?
  4. Give a precise statement of the Central Limit Theorem (CLT) and explain one concrete way it powers everyday analytics or experimentation work.
  5. Suppose a hypothesis test produces p = 0.03. Explain clearly what that number means—and what common misinterpretations it does not support.

Scope & Expectations

  • Exact formulas and conditions: State every mathematical expression, parameter assumption (such as independence, known vs. estimated spread, and finite variance), and tail cutoff cleanly without ambiguity.
  • Intuition and quick sanity checks: Back up each formula or decision rule with brief structural reasoning (such as why t tails are heavier or how standard error scales with n) and concrete numerical examples.
  • Sound statistical interpretation: Distinguish sampling distributions from raw data distributions, separate statistical significance from practical business magnitude, and call out common pitfalls like paired observations or inverse-probability fallacies.

Step-by-step walkthrough

  1. 1. Mean and variance of a Poisson(λ) count variable

    A Poisson(λ) distribution models the number of events X occurring in a fixed window of time or space when events happen independently at a constant average rate λ > 0 per window (for example, customer support tickets per hour or profile lookups per second). Its probability mass function (the formula giving the exact probability of each whole-number count k) is:

    P(X = k) = e^(-λ) * λ^k / k!      for k = 0, 1, 2, ...
    

    Direct answer: Both the expectation and the variance equal λ: - Expectation (mean): E[X] = λ - Variance: Var(X) = λ (so the standard deviation is SD(X) = √λ)

    Why E[X] = λ (zero skipped steps): By definition, E[X] is the weighted average of every possible count k times its probability. Notice that the k = 0 term contributes 0 * P(X = 0) = 0, so we can start the sum at k = 1. For k >= 1, k / k! simplifies to 1 / (k - 1)!, and λ^k = λ * λ^(k - 1). Setting j = k - 1 (so j runs 0, 1, 2, ...) reveals the Taylor series e^λ = Σ (j = 0 to ∞) λ^j / j!:

    E[X] = Σ (k = 0 to ∞) k * e^(-λ) * λ^k / k!
         = Σ (k = 1 to ∞) e^(-λ) * λ * λ^(k - 1) / (k - 1)!
         = λ * e^(-λ) * Σ (j = 0 to ∞) λ^j / j!
         = λ * e^(-λ) * e^λ
         = λ
    

    Why Var(X) = λ: Using the same factorial-cancellation trick on X * (X - 1) knocks out both k = 0 and k = 1, leaving j = k - 2:

    E[X(X - 1)] = Σ (k = 2 to ∞) k(k - 1) * e^(-λ) * λ^k / k!
                = λ^2 * e^(-λ) * Σ (j = 0 to ∞) λ^j / j!
                = λ^2 * e^(-λ) * e^λ
                = λ^2
    
    Since E[X(X - 1)] = E[X^2] - E[X], we get E[X^2] = λ^2 + λ.
    Therefore:
    Var(X) = E[X^2] - (E[X])^2 = (λ^2 + λ) - λ^2 = λ.
    

    Worked numeric example (λ = 4): Suppose a search endpoint receives an average of λ = 4 queries per second. Its mean is 4, its variance is 4, and its standard deviation is √4 = 2. The chance of zero queries in a second is e^(-4) ≈ 0.0183 (1.83%), and the chance of seeing exactly 4 queries is e^(-4) * 4^4 / 4! ≈ 0.1954 (19.54%). In real datasets, if the sample variance is much larger than the sample mean (overdispersion), events are arriving in bursts or rates vary across users, so a Negative Binomial model fits better than plain Poisson.

    import math
    
    lam = 4.0
    # Sum up to k = 59 (tail beyond 59 for lambda = 4 is below 10^-30)
    pmf = [math.exp(-lam) * (lam ** k) / math.factorial(k) for k in range(60)]
    mean = sum(k * p for k, p in enumerate(pmf))
    variance = sum(((k - mean) ** 2) * p for k, p in enumerate(pmf))
    print(round(mean, 6), round(variance, 6))  # 4.0 4.0
    
  2. 2. Known-σ 95% confidence interval for a population mean

    Given a sample of n independent observations with sample mean x̄ and known population standard deviation σ, the two-sided 95% confidence interval for the true population mean μ is:

    x̄ ± z_(0.975) * (σ / √n)   ≈   x̄ ± 1.96 * (σ / √n)
    

    Where each piece comes from: - σ / √n is the standard error (SE) of x̄: while single observations bounce around with spread σ, averaging n independent observations cancels out random highs and lows so the sample mean has variance σ^2 / n and standard deviation σ / √n. - 1.96 is the two-sided 95% normal cutoff (z_(0.975)): to capture the middle 95% of a standard normal N(0, 1) bell curve, we leave 5% total outside the interval—split symmetrically into 2.5% in the left tail and 2.5% in the right tail. Thus the upper cutoff is the 97.5th percentile (1.96), not the 95th percentile (1.645).

              Standard Normal N(0, 1)
                     _.-""""-._
                   .'          '.
                 /    95% area    \
       2.5% tail/                  \2.5% tail
      ─────────┼──────┼────────┼────┼─────────▶ z
             -1.96    0      +1.96
    
    • When is this formula valid? It is exact if the underlying population is Normal, and an accurate approximation for non-normal populations once n is large enough for the Central Limit Theorem to apply.

    Worked numeric example: With n = 100 users, known σ = 10 seconds, and observed x̄ = 50 seconds: - Standard error: SE = 10 / √100 = 10 / 10 = 1.0 - Margin of error: 1.96 * 1.0 = 1.96 - 95% CI: 50 ± 1.96 = [48.04, 51.96]

    Notice the √n scaling law: shrinking the margin of error in half (from ±1.96 to ±0.98) requires 4× as many observations (n = 400). And in frequentist statistics, μ is a fixed unknown constant—so "95% confidence" means 95% of intervals constructed by this recipe across repeated random samples will cover the true μ, not that μ is jumping around inside [48.04, 51.96].

  3. 3. Choosing a two-sample t-test over a z-test

    The core distinction is whether the population standard deviations σ_1, σ_2 are known ahead of time or estimated from the samples as s_1, s_2:

    • Use a two-sample t-test when comparing the means of two independent groups (such as Control vs. Treatment users) and the true population standard deviations σ_1, σ_2 are unknown, so you plug in the sample standard deviations s_1, s_2. Because s_1 and s_2 are themselves noisy estimates, dividing by the estimated standard error produces extra variability—especially at small or moderate sample sizes—giving a Student's t-distribution with heavier tails controlled by the degrees of freedom (df). Since true σ is almost never known in real experiments, Welch's two-sample t-test (which does not assume σ_1 = σ_2) is the standard default.
    • Use a z-test when σ_1, σ_2 are genuinely known, when both sample sizes are very large (say several hundred or more per group, where the t critical value is virtually indistinguishable from 1.96), or in a two-proportion test where a Bernoulli variable's variance p(1 - p) is completely determined by its mean p under the null hypothesis.
    • Watch out for paired data: If the two measurements come from the same users (e.g., latency before vs. after an upgrade on the same 30 accounts), neither a two-sample t-test nor a two-sample z-test is right—compute within-user differences d_i = y_i - x_i and run a paired t-test.

    How much the heavier t tails matter (97.5th percentile t* vs. z* = 1.960):

    Degrees of freedom (df)      9      17      29      99     198    ∞ (z)
    Two-sided 95% cutoff       2.262   2.110   2.045   1.984   1.972   1.960
    

    If you have only 10 users per group and mistakenly use z* = 1.96 instead of t* ≈ 2.11, your rejection threshold is too loose and your false-positive rate rises above the promised 5% (to roughly 6.6%).

    Worked numeric example (Welch's t-test): Group A has x̄_A = 12, s_A = 3, n_A = 10; Group B has x̄_B = 10, s_B = 4, n_B = 10:

    SE = √(s_A^2 / n_A + s_B^2 / n_B) = √(9/10 + 16/10) = √2.5 ≈ 1.581
    t  = (12 - 10) / 1.581 ≈ 1.265
    df ≈ 16.7 (Welch-Satterthwaite)  ->  |t| = 1.265 < 2.11, two-sided p ≈ 0.22 (do not reject H_0)
    
    import math
    
    
    def welch_two_sample_t(mean_a, sd_a, n_a, mean_b, sd_b, n_b):
        var_a = (sd_a ** 2) / n_a
        var_b = (sd_b ** 2) / n_b
        se = math.sqrt(var_a + var_b)
        t_stat = (mean_a - mean_b) / se
        df = ((var_a + var_b) ** 2) / ((var_a ** 2) / (n_a - 1) + (var_b ** 2) / (n_b - 1))
        return t_stat, df
    
    
    t_val, df_val = welch_two_sample_t(12, 3, 10, 10, 4, 10)
    print(round(t_val, 3), round(df_val, 1))  # 1.265 16.7
    
  4. 4. Central Limit Theorem statement and practical impact

    Formal statement: Let X_1, X_2, ..., X_n be independent and identically distributed (i.i.d.) random variables with finite mean E[X_i] = μ and finite, positive variance 0 < Var(X_i) = σ^2 < ∞. As the sample size n -> ∞, the standardized sample mean converges in distribution to a standard normal variable:

    √n * (X̄_n - μ) / σ   ──(in distribution)──▶   N(0, 1)
    

    Equivalently, for large n, the sampling distribution of the sample mean X̄_n is approximately N(μ, σ^2 / n) regardless of the shape of the individual X_i (binary, discrete counts, or skewed), provided the variance is finite. Note what becomes normal: the distribution of the average X̄_n across repeated samples becomes bell-shaped—the raw individual data points X_i keep their original skewed or discrete shape.

    Practical implication in data science: Most business and product metrics—such as revenue per visitor, searches per session, or binary conversion (0 or 1)—are nowhere near Normal at the individual-user level. Thanks to the CLT, online A/B testing platforms can still use normal/t confidence intervals and two-sample t/z tests on the difference in sample means when sample sizes are sufficiently large.

    Worked numeric example & caveat on n: Suppose individual order values follow a heavily right-skewed Exponential distribution with mean μ = $20, standard deviation σ = $20, and skewness 2.0. Across n = 400 independent orders: - The sample mean X̄_400 has mean $20 and standard error $20 / √400 = $1.00. - The skewness of X̄_400 shrinks by 1 / √n to 2.0 / √400 = 0.10—nearly symmetric! - Caveat: the textbook "n >= 30" rule of thumb works for roughly symmetric distributions, while heavily skewed or whale-dominated revenue metrics can require hundreds or thousands of users per arm (or variance-reduction/bootstrap checks) before normal approximations achieve full 95% coverage.

  5. 5. What p = 0.03 means in hypothesis testing

    Exact definition: A p-value of 0.03 means that if the null hypothesis H_0 were true (for example, H_0: μ_treatment = μ_control, no real effect) and all test assumptions held, there would be a 3% probability of observing a test statistic at least as extreme as the one observed in our sample purely from random sampling variation.

    Sampling distribution of test statistic Z assuming H_0 is TRUE:
                     _.-""""-._
                   .'          '.
        1.5% tail /              \ 1.5% tail      Total shaded tail area
      ▒▒▒▒▒▒▒▒▒▒▒┼───────┼────────┼▒▒▒▒▒▒▒▒▒▒▒▶   = 0.015 + 0.015 = 0.03
               -2.17     0      +2.17
    

    How to act on and communicate p = 0.03: 1. Compare against pre-chosen α: At the standard significance level α = 0.05, since 0.03 < 0.05, we reject H_0 (the difference is statistically significant at the 5% level, and the matching two-sided 95% confidence interval excludes 0). At a stricter threshold α = 0.01 (common when testing many metrics), 0.03 > 0.01, so we fail to reject H_0. 2. What it does NOT mean about probability of truth: p = 0.03 is P(data at least this extreme | H_0 is true), not P(H_0 is true | data). Claiming "there is a 3% chance the null is true" or "a 97% chance the feature really works" is a classic logical error; computing the probability that an effect is real requires Bayes' rule and a prior belief about how often tested ideas succeed. 3. What it does NOT mean about business impact: A p-value blends effect size and sample size (z = effect / SE). With 10 million visitors, a tiny +0.02% lift can yield z = 2.17 (p = 0.030) while not being worth engineering maintenance; with 50 visitors, a huge +15% lift might yield p = 0.18 simply due to noise. Always report the estimated effect size and its 95% confidence interval alongside p = 0.03.

    import math
    
    
    def two_sided_p_from_z(z_stat):
        # erfc(|z| / sqrt(2)) equals 2 * (1 - Phi(|z|)) for a standard normal Z
        return math.erfc(abs(z_stat) / math.sqrt(2.0))
    
    
    print(round(two_sided_p_from_z(2.17), 4))  # 0.03
    

Intuition & how it works

Think of these five quiz questions as the complete pipeline of statistical inference from raw events to a product decision: 1. Model raw counts (Poisson(λ)): Count how many independent events happen in a fixed window at average rate λ—remarkably, both the average count and the variance equal λ. 2. Summarize many observations (Central Limit Theorem): Even when single user counts or purchases are lopsided, averaging n independent users smooths out individual quirks so the sample mean X̄ behaves like a bell curve with standard error σ / √n (the standard deviation of the sample mean across repeated samples). 3. Attach error bars when spread is known (95% z-interval): Stretching 1.96 standard errors on each side of x̄ (x̄ ± 1.96 * σ / √n) builds a recipe that traps the true mean μ 95% of the time. 4. Adjust error bars when spread is estimated (two-sample t-test): In real A/B tests we rarely know true σ; plugging in noisy sample standard deviations s_1, s_2 adds extra uncertainty, so we swap the normal z curve for the heavier-tailed Student's t curve. 5. Weigh surprise under "nothing changed" (p = 0.03): A p-value (the probability, assuming the null hypothesis H_0 of zero true effect holds, of seeing a test statistic at least as extreme as ours) measures how surprising our data would be under pure luck.

Relying on quick memorization without this chain leads to classic interview slips: mixing up Poisson variance (λ) with standard deviation (√λ), dividing by n instead of √n, plugging a small-sample s into 1.96, saying the CLT turns raw skewed data normal, or calling p = 0.03 "a 3% chance H_0 is true."

Walk through one concrete mini-example tying the ideas together: suppose baseline users make Poisson(λ = 4) searches per visit (mean = 4, variance = 4, σ = √4 = 2). We test a new layout on n = 100 independent users and observe x̄ = 4.434 searches. If σ = 2 were known, the standard error would be 2 / √100 = 0.20, the 95% confidence interval would be 4.434 ± 1.96 * 0.20 = [4.042, 4.826], and the test statistic against μ_0 = 4 would be z = (4.434 - 4.0) / 0.20 = 2.17, giving a two-sided p-value of 0.03—surprising enough to reject H_0 at α = 0.05.

Key points

  • Poisson(λ) moments: E[X] = λ and Var(X) = λ (so SD(X) = √λ). Checking whether sample variance roughly equals sample mean is a fast diagnostic for overdispersion (variance exceeding the mean because event rates vary across users or bursts occur).
  • 95% confidence interval with known σ: x̄ ± 1.96 * (σ / √n). Because interval width scales with 1 / √n, cutting uncertainty in half requires 4× the sample size. Under frequentist inference, 95% is the long-run hit rate of the interval-building procedure across repeated samples, not a probability distribution over a moving μ.
  • Two-sample t-test vs. z-test: Use a two-sample t-test (specifically Welch's t-test, the version that allows unequal group variances) when comparing means of two independent groups with unknown population standard deviations estimated by s_1, s_2, especially at small or moderate n where limited degrees of freedom (the effective number of independent pieces of information used to estimate variance) make t tails noticeably wider than N(0, 1). Reserve z-tests for known σ, very large samples, or two-proportion tests.
  • Central Limit Theorem (CLT): For i.i.d. (independent and identically distributed—drawn independently from the same distribution) variables with finite mean μ and finite variance σ^2 > 0, √n * (X̄_n - μ) / σ converges in distribution (its cumulative probabilities approach those of the target curve as n -> ∞) to N(0, 1). Practically, this lets data scientists run normal/t inference on averages of skewed product metrics like revenue or session duration once n is large enough.
  • Interpreting p = 0.03: Assuming H_0 is true and every model assumption holds, a test statistic at least as extreme as observed happens 3% of the time by random chance. Reject H_0 at α = 0.05 (fail to reject at α = 0.01), and always pair p with the estimated lift and confidence interval because statistical significance does not measure practical size.

Common mistakes

  • Confusing variance (λ) with standard deviation (√λ) for Poisson(λ): Always state both explicitly in a quiz (E[X] = λ, Var(X) = λ, SD(X) = √λ) so there is zero ambiguity.
  • Writing σ / n instead of σ / √n, or 1.645 instead of 1.96: Variance divides by n (σ^2 / n), so its square root—the standard error—divides by √n; 1.645 leaves 5% in each tail (90% two-sided CI), whereas 1.96 leaves 2.5% in each tail (95% two-sided CI).
  • Using a two-sample test on paired observations: When measuring the same users before and after a change, positive within-user correlation cancels out in a paired t-test on d_i = after_i - before_i; treating them as two independent groups inflates the standard error and wastes statistical power (the probability of detecting a true effect when one exists).
  • Claiming the CLT makes the raw data normal or forgetting finite variance: Histogramming 100,000 exponential session lengths still shows a sharp right skew—only the distribution of sample averages becomes normal. And heavy-tailed distributions with infinite variance (such as the Cauchy or Pareto with tail exponent α <= 2) violate the CLT completely.
  • The inverse-probability ("prosecutor's") fallacy on p-values: Saying "p = 0.03 means a 3% chance H_0 is true" swaps P(data | H_0) for P(H_0 | data). If you test 100 long-shot ideas where only 5% truly work (80% power, α = 0.05), a significant p-value around 0.03–0.05 still has a substantial false-discovery rate!
  • Running many tests and celebrating a single p = 0.03: Across 20 independent true-null metrics tested at α = 0.05, the chance of seeing at least one p < 0.05 by pure luck is 1 - 0.95^20 ≈ 64%. Control false positives with pre-declared primary metrics, Bonferroni, or Benjamini-Hochberg false-discovery-rate adjustments.

Follow-up questions

  • How does the 95% confidence interval formula change when the population standard deviation is unknown? Replace the unknown population σ with the sample standard deviation s = √(Σ(x_i - x̄)^2 / (n - 1)) and replace 1.96 with the 97.5th percentile of Student's t-distribution with n - 1 degrees of freedom: x̄ ± t_(0.975, n-1) * (s / √n). For instance, with n = 10, x̄ = 50, and s = 10, t_(0.975, 9) = 2.262 and s / √10 ≈ 3.162, giving 50 ± 7.15—noticeably wider than the 50 ± 6.20 you would get from 1.96 to account for uncertainty in estimating s.
  • How would you construct a 95% confidence interval for a Poisson rate parameter from observed counts? Suppose you observe C = 40 events over T = 10 hours; the maximum-likelihood estimate (the parameter value making the observed data most probable) is λ̂ = C / T = 4.0 per hour. Because C ~ Poisson(λ * T) has variance λ * T, the standard error of λ̂ is √(λ̂ / T) = √(4.0 / 10) ≈ 0.632, giving a large-count normal interval 4.0 ± 1.96 * 0.632 = [2.76, 5.24]; when total counts C are small (say under 20), use the exact chi-square (Garwood) interval so lower bounds never go negative and tail coverage stays accurate.
  • When is a sample size of 30 insufficient for the Central Limit Theorem in an online experiment? Whenever a metric has extreme skewness or rare high-spend "whales"—for example, if 99% of visitors spend $0 and a handful spend $500, a sample of n = 30 will often contain zero buyers (s = 0), causing nominal 95% t-intervals to severely undercover the true mean. You can diagnose required n via bootstrap resampling or simulation on historical data, and mitigate extreme skew using pre-experiment covariates (CUPED), capping extreme outliers (winsorization), or testing conversion rate and spend-among-buyers separately.

Follow-up questions

Similar questions

More Spokeo interview questions

All 2 Spokeo questions →