Probability Modeling, Expectation, And Variance
Asked of: Data Scientist
Last updated

What's being tested
Interviewers are probing whether you can translate an ambiguous product or experimentation scenario into a probability model, compute expectation or variance correctly, and explain the assumptions behind the math. At Meta, this matters because Data Scientists routinely reason about noisy metrics: click-through rate, conversion, retention, feed engagement, notification opt-outs, ad auction outcomes, and experiment readouts. The interviewer is usually not testing memorized puzzle tricks; they are testing whether you can define random variables, use linearity of expectation, handle dependence, and connect uncertainty to a business decision. Strong answers make the model explicit, quantify uncertainty, and call out where real-world data violates the clean assumptions.
Core knowledge
-
Define the random variable before calculating. For example, if is “number of users who click,” specify whether users are independent Bernoulli trials, whether click probability is constant, and whether repeated impressions from the same user are allowed.
-
Expectation is linear even when variables are dependent:
This is extremely useful for counting collisions, active users, clicks, matches, impressions, or expected retained users without modeling the full joint distribution. -
Variance is not linear under dependence:
A common Meta-relevant edge case is user-level clustering: impressions from the same user are correlated, so treating all impressions as independent underestimates uncertainty. -
Bernoulli and binomial models are the default for binary outcomes. If , then and . If , then and .
-
The sample mean has expectation and variance under independent observations. For binary metrics, . At very small or very large , normal approximations can be poor.
-
Conditional expectation is often the cleanest path:
Use it when the process has stages, such as users receiving notifications, then opening, then clicking. This also helps separate product funnel assumptions. -
Bayes’ rule appears in classification, spam/fraud detection, and diagnostic-style interview questions:
Always account for the base rate; rare-event settings can produce unintuitive posterior probabilities even with accurate signals. -
The law of total variance decomposes uncertainty:
This is useful when user segments have different propensities. Segment heterogeneity increases total variance beyond a single pooled-binomial model. -
For count data, Poisson approximations work when is large, is small, and is moderate: , with . This is common for rare clicks, reports, fraud events, or crashes, but overdispersion often appears in real product data.
-
For occupancy or hashing problems, use indicator variables. If users are assigned uniformly to buckets, the expected number of occupied buckets is
and expected pairwise collisions is . -
Independence assumptions are the main interview pressure point. Random assignment in A/B tests helps independence between treatment and potential outcomes, but outcomes may still be correlated through social graphs, households, shared advertisers, geography, time, or repeated exposure.
-
Simulation is acceptable as a validation tool, not a substitute for modeling. For small state spaces, exact enumeration or dynamic programming may be feasible; for millions of users or complex funnels, Monte Carlo simulation can sanity-check expectation and variance under explicit assumptions.
Worked example
Expected Number of Collisions When Hashing Users Into Buckets
A strong candidate would first clarify the setup: “Are users assigned independently and uniformly at random to buckets? Do we care about pairwise collisions, buckets with at least two users, or the number of users involved in a collision?” Those are different random variables, so the first 30 seconds should be spent defining the target clearly. The answer can be organized around four pillars: define indicators, compute expectation for one indicator, sum using linearity of expectation, then discuss assumptions and edge cases. For pairwise collisions, the natural indicator is if users and land in the same bucket, and under uniform hashing. Then the expected total number of colliding pairs is the sum over all pairs; no independence between indicators is required for expectation.
The candidate should explicitly flag a tradeoff: pairwise collisions are easy to compute, but they are not the same as “number of buckets with collisions” or “number of users affected,” which require different indicators. If the interviewer pushes toward variance, the candidate should note that covariance terms matter because collision indicators sharing a user are not automatically independent in all variants of the problem. A Meta-style business connection would be bucket assignment for experiments, cache keys, ranking shards, or holdout groups, where non-uniform hashing could bias traffic or overload systems. A good close would be: “If I had more time, I’d verify the uniformity assumption empirically by checking bucket counts with a chi-square test and looking for user attributes correlated with bucket assignment.”
A second angle
Variance of a Click-Through Rate Estimate
The same modeling skill applies, but the framing shifts from counting expected events to quantifying uncertainty around a metric. If each user has one impression and click outcome , then the CTR estimate has variance . However, if users receive multiple impressions, treating impressions as independent is often wrong because the same user’s clicks are correlated. A stronger model aggregates at the user level or uses cluster-robust standard errors. The key transfer is the same: define the random variable, state independence assumptions, compute expectation or variance, and explain where the simplified model may break in production data.
Common pitfalls
Analytical mistake: assuming independence when only linearity is needed.
Candidates often say “we can sum these because the events are independent,” even when independence has not been established. For expectation, say “linearity of expectation applies regardless of dependence”; for variance, explicitly check covariance terms instead of silently dropping them.
Communication mistake: solving before defining the random variable.
A tempting but weak answer starts writing formulas immediately: , , or . A better answer first says what measures, what one trial is, what assumptions are being made, and whether the desired output is an expectation, a probability, or a confidence interval.
Depth mistake: giving a toy answer without production caveats.
For a binary metric, “variance is ” is correct only under independent Bernoulli observations. In Meta-scale data, repeated exposure, network effects, bot traffic, segment heterogeneity, logging delays, and experiment interference can dominate the theoretical variance if ignored.
Connections
Interviewers can easily pivot from this topic into A/B testing, confidence intervals, power analysis, sequential testing, or causal inference. They may also connect probability modeling to metric design, ranking evaluation, ads auction modeling, anomaly detection, or Bayesian updating for rare events.
Further reading
- Introduction to Probability Models — Sheldon Ross — Strong reference for expectation, variance, conditioning, Poisson processes, and Markov chains.
- All of Statistics — Larry Wasserman — Concise bridge from probability foundations to inference, confidence intervals, and statistical modeling.
- Trustworthy Online Controlled Experiments — Kohavi, Tang, Xu — Practical treatment of experimentation, metrics, variance, and real-world failure modes at tech companies.