Learning objective
Given a probability table, joint distribution, or two-stage product scenario, define the unit and support; compute and interpret E[X], Var(X), covariance, and conditional expectation; and connect the result to the decision quantity that actually matters.
Prediction sandbox
Same average, different risk
Two daily-load plans have the same expected number of tickets. Before any numbers appear, predict which one is riskier for a team with capacity for 12 tickets.
1 · Predict before reveal
Which plan has the greater variance and exceeds 12 tickets more often?
2 · Change the probability model
Every control changes a labeled quantity. The explanation below the visual tells you why.
Probability mass for one day
The stable plan keeps probability near its mean; no displayed outcome exceeds capacity 12.
What to notice
- Squared-distance check
- 0.25(4) + 0.50(0) + 0.25(4) = 2
- Nonlinear transform
- E[T²] = 102; E[T]² = 100
- Report for an SLA
- A quantile or exceedance probability, not the mean alone.
Means add; covariance changes spread
Imagine two queues with mean 5 and variance 4 each. Choose whether a shared incident links them.
4 + 4 + 2(0) = 8
Conditioning changes the question
Across all days, the mixture mean is 19.25 tickets: 0.95(15) + 0.05(100).
E[T] = 0.95E[T | normal] + 0.05E[T | outage]
The outage variance is not specified here, so do not invent a full tail estimate from the mean alone.
The interview-ready order: “I will define one draw and its support, write the probability model, calculate the weighted mean, keep variance in squared units or take its square root, and check covariance before calling a sum independent. Then I will ask whether the decision needs an average, a typical case, or a tail guarantee.”
1. A random variable turns an uncertain outcome into a number
An outcome is one element of a sample space: one die roll, one user-day, or one product day. A random variable is a numerical function that maps each possible outcome to the quantity you care about. The uncertainty is in which outcome occurs; once the outcome is observed, the random variable has a fixed value.
For a die, the outcome space is {1, 2, 3, 4, 5, 6}. If X(ω)=ω, then X is the face value. On the same roll, define I = 1 when the face is six and I = 0 otherwise. Or define revenue R = 5I. One experiment supports several random variables because the business question chooses the mapping.
The support is the set of values a variable can take. A discrete variable has a probability mass function (PMF), written p(x)=P(X=x), with nonnegative probabilities that sum to one. A continuous variable uses a density f(x); probabilities are areas under the density and a single exact value usually has probability zero. The interview pattern is the same: define the quantity, identify its distribution, then integrate or sum.
Discrete: E[X] = Σ x p(x), when the expectation exists.
Continuous analogue: E[X] = ∫ x f(x) dx, when the integral exists.
Indicator identity: if IA is 1 for event A, then E[IA] = P(A).
That last identity is useful because an expected count can be built one indicator at a time. If T = Σ Ii counts conversions, then E[T] = ΣP(Ii=1). This does not require the users to be independent. Independence becomes relevant when you want a product of probabilities or want to remove covariance from a variance calculation.
2. Expectation is a weighted average, not “most likely”
For a discrete variable, expectation weights each support value by how often it occurs in the probability model. It describes the long-run average over repeated draws when the model is appropriate. It is not necessarily a support value, a mode, or a median. A fair die has E[X] = (1+2+3+4+5+6)/6 = 3.5; one roll cannot be 3.5, but many rolls can average near it.
Expectation is linear:
E[aX + bY + c] = aE[X] + bE[Y] + c
The rule holds even when X and Y are dependent. The algebra distributes over addition before any joint probability is needed. For example, expected daily tickets from ten users is the sum of their individual ticket probabilities, even if a shared incident makes their outcomes move together.
Do not extend linearity to arbitrary transformations. In general, E[g(X)] ≠ g(E[X]). For the square function, the gap is exactly the variance:
E[X2] = Var(X) + E[X]2
So averaging first and then squaring loses the spread term. This is a frequent interview trap because the tempting shortcut feels like ordinary arithmetic. It is valid for linear functions, not for squaring, thresholds, ratios, or most other nonlinear operations.
3. Variance measures squared distance from the mean
Let μ = E[X]. Signed deviations X−μ average to zero, so they cannot measure spread without cancellation. Variance squares them:
Var(X) = E[(X−μ)2] = E[X2] − μ2
Expanding the square explains the shortcut: E[X2 − 2μX + μ2] = E[X2] − 2μE[X] + μ2 = E[X2] − μ2. Variance is always nonnegative and is measured in squared units. Standard deviation, SD(X)=√Var(X), returns to the units of the variable, which is generally easier to explain to a product or operations partner.
Squaring also makes variance sensitive to outliers. That is useful when a rare large miss is operationally expensive, but it can make variance a poor description of a heavily skewed or heavy-tailed process. A mean absolute deviation, median, quantile, or explicit expected-loss calculation may better match the decision. Do not call variance “the average distance”; it is the average squared distance.
4. Worked calculation: support escalations
Question. In a randomly selected day, let X be the number of urgent support escalations. The PMF is:
| x escalations | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| P(X=x) | 0.40 | 0.30 | 0.20 | 0.10 |
The probabilities sum to 1.00, so this is a complete discrete model.
Step 1 — expectation.
E[X] = 0(0.40) + 1(0.30) + 2(0.20) + 3(0.10) = 1.00
The expected count is 1 escalation per day. It does not mean every day has exactly one escalation.
Step 2 — second moment.
E[X2] = 02(0.40) + 12(0.30) + 22(0.20) + 32(0.10) = 2.00
Step 3 — variance and standard deviation.
Var(X) = 2.00 − 1.002 = 1.00; SD(X) = √1.00 = 1.00 escalation
Variance is 1.00 squared escalations; standard deviation returns to escalations. Saying “the daily spread is about one escalation” is more intelligible than saying “the variability is one escalation squared,” while the variance remains useful for algebra.
Step 4 — transform the units. Suppose each escalation uses 20 specialist minutes and a fixed triage meeting uses 30 minutes. Let M=30+20X. Then:
E[M] = 30 + 20(1) = 50 minutes; Var(M) = 202(1) = 400 minutes2
The fixed 30 shifts the average but adds no uncertainty. Multiplying the random part by 20 multiplies standard deviation by 20 and variance by 202.
5. Sums: means add cleanly; spread needs covariance
For two variables, write the mean and variance rules separately:
E[X+Y] = E[X] + E[Y]
Var(X+Y) = Var(X) + Var(Y) + 2Cov(X,Y)
To see the second formula, center the sum and expand: X+Y−E[X+Y] = (X−E[X])+(Y−E[Y]). Squaring produces two cross-products. Their expected value is twice the covariance. Independence with finite second moments implies Cov(X,Y)=0, but zero covariance does not generally imply independence.
Covariance is signed and scale-dependent:
Cov(X,Y) = E[(X−E[X])(Y−E[Y])] = E[XY] − E[X]E[Y]
Positive covariance makes a total more volatile; negative covariance can cancel risk. Correlation divides covariance by the two standard deviations, producing a unitless number when both standard deviations are positive. Neither covariance nor correlation establishes causality. If two support queues share outages, the shared event is a data-generating explanation to investigate, not a causal story proven by a covariance estimate.
In the escalation example, if another team has variance 4 and covariance with X is 0.5, then Var(X+Y)=1+4+2(0.5)=6 and the combined standard deviation is √6≈2.45. Dropping the covariance would report variance 5 and understate the combined spread.
6. Conditional expectation is a question about information
E[Y|X=x] is the expected value of Y among outcomes where the observed variable equals a specified x. For a finite joint PMF, first marginalize:
P(Y=y|X=x) = P(X=x,Y=y) ÷ P(X=x)
Then use that conditional PMF as the weights: E[Y|X=x] = Σy yP(Y=y|X=x). The denominator is the row or column total named by the condition; do not silently swap P(Y|X) with P(X|Y).
As x varies, the conditional means form a function. That function, evaluated at the random observed X, is written E[Y|X]. It is a random variable, not one universal constant. The tower property says:
E[E[Y|X]] = E[Y]
In plain language, average the segment-specific means using the segment probabilities and you recover the overall mean. The same mixture logic yields the law of total variance:
Var(Y) = E[Var(Y|X)] + Var(E[Y|X])
The first term is average within-group volatility. The second is between-group variation in the group means. A single overall average can hide a low-risk normal segment and a high-risk incident segment.
7. Worked product scenario: expected load is not a capacity guarantee
Question. A learning platform has 1,000 active accounts. On a normal day, each account creates an urgent ticket with probability 0.015. A shared-outage day occurs with probability 0.05 and has an expected 100 urgent tickets. The launch team asks, “Can we staff for 25 tickets per day?”
Step 1 — name the state and variable. Let D be the day state, with D=N for normal and D=O for outage. Let T be the total urgent-ticket count. Given a normal day, T|D=N is modeled as Binomial(1000,0.015), so:
E[T|N] = 1000(0.015) = 15; Var(T|N) = 1000(0.015)(0.985) = 14.775
We only know E[T|O]=100. The outage variance is not supplied, so a complete unconditional variance or tail probability cannot be honestly computed yet.
Step 2 — total expectation. Weight each state’s conditional mean by how often that state occurs:
E[T] = 0.95(15) + 0.05(100) = 14.25 + 5 = 19.25 tickets per day
Capacity 25 is above the unconditional expected load, but that does not establish that it handles 95% of days or meets an SLA. The question “what is the probability T>25?” needs the state-specific distributions, not just the mixture mean.
Step 3 — expose the between-state risk. The total-variance identity separates two sources:
Var(T) = E[Var(T|D)] + Var(E[T|D])
The between-state term alone is:
Var(E[T|D]) = 0.95(15−19.25)2 + 0.05(100−19.25)2 ≈ 343.19
That is large before adding normal-day ticket noise or any outage-day noise. Treating all accounts as independent with a single marginal probability of 0.01925 would erase the common-outage structure and understate risk.
Step 4 — make a bounded decision. For an SLA, estimate the normal and outage distributions from incident logs, choose a target such as the 95th percentile or expected overflow cost, and report baseline staffing plus an outage escalation path. The mean supports long-run resource planning near 19 tickets; it does not choose the final capacity. The state means are descriptive. They do not establish that a feature launch caused the difference without a design that supports that causal claim.
8. Assumptions, failure modes, and nearest alternatives
These calculations are exact conditional on the stated probability model. In an interview, name the assumption at the point where you use it.
- Wrong unit or support: mixing user-level and day-level observations changes the random variable and can double-count exposure.
- Independence assumed by habit: separate columns or separate teams can still share outages, campaigns, holidays, or users. Check the joint process before dropping covariance.
- Heavy tail or missing moment: an expectation may fail to exist, and variance requires a finite second moment. A few quiet observations do not prove a stable tail.
- Mean used for a threshold: a 19.25-ticket expectation does not answer whether capacity 25 is exceeded. Use a quantile, exceedance probability, or expected cost.
- Conditional mean called causal: E[Y|X=x] describes the observed conditional distribution. Conditioning alone does not identify what changing X would do.
- Population and sample silently mixed: distinguish the model’s E[X] and Var(X) from a sample mean and sample variance, including the denominator and estimand.
The nearest alternative depends on the decision:
| Question | Prefer | Boundary |
|---|---|---|
| Long-run workload or average payoff | Expectation | Useful when repeated trials and approximately linear utility make averages meaningful. |
| Typical skewed case | Median or quantile | More resistant to outliers, but does not add linearly across components. |
| SLA or capacity threshold | Quantile or exceedance probability | The mean alone contains no tail guarantee. |
| Algebraic uncertainty propagation | Variance and covariance | Keep covariance terms; communicate SD when returning to original units. |
| Segment-specific prediction | Conditional expectation | State the conditioning information; do not turn association into an intervention claim. |
Common interview trap
Weak answer: “The expected load is 19.25, so capacity 25 is safe. And the variance of two queues is just the sum of their variances.”
Why it fails: it treats a mean as a high-percentile guarantee, hides the outage mixture, and drops the covariance term without an independence argument. It also gives no unit, tail target, or missing-data check.
Corrected answer: “I would define the ticket count and day state first. Total expectation gives 19.25 tickets, but capacity is a tail question, so I need state-specific distributions and an SLA or overflow-cost target. For two queues I would write Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y) and inspect shared outages before setting covariance to zero. I would recommend baseline capacity plus a contingency path while measuring the outage distribution.”
Interview practice bank
1. What is a random variable, and how is it different from an outcome?
Strong answer: An outcome is one element of the sample space; a random variable maps outcomes to a numerical quantity. The same experiment can define a die face, a six-indicator, or revenue. Before observation the value is uncertain; after observation it is fixed. Follow-up: Can two variables share one sample space? Signal: defines the estimand before calculating.
2. A conversion indicator has probability 0.08. What are its expectation and variance?
Strong answer: For I~Bernoulli(0.08), E[I]=0.08 and Var(I)=p(1−p)=0.08(0.92)=0.0736. The expected value is a rate for one eligible unit, not a guarantee. Follow-up: What is the expected count for 1,000 users, and what changes under dependence? Signal: indicator fluency and units.
3. Why can an expected value be a number that never occurs?
Strong answer: It is a probability-weighted long-run average, not necessarily a support value. A fair die’s expectation is 3.5 even though one roll is an integer. Interpret it in the unit of repeated draws or aggregate planning. Follow-up: Which quantity describes a typical skewed delivery time? Signal: separates mean, mode, median, and realized outcome.
4. Derive the variance of aX+b.
Strong answer: Center the transformed variable: aX+b−(aE[X]+b)=a(X−E[X]). Square and take expectations, giving Var(aX+b)=a²Var(X). The shift changes location; standard deviation becomes |a|SD(X). Follow-up: What if a is negative? Signal: shows the derivation rather than reciting it.
5. A team adds two ticket variances. What do you check?
Strong answer: Write Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y). Ask about shared outages, seasonality, users, and common queues; estimate covariance or use a joint state model. Independence is a substantive assumption. Follow-up: Does zero covariance prove independence? Signal: diagnoses the data-generating process.
6. When would you report standard deviation, variance, or a quantile?
Strong answer: Use SD for same-unit spread, variance for algebra and decomposition, and a quantile or exceedance probability for an SLA or capacity threshold. For asymmetric losses, show the distribution or expected cost. Follow-up: Why not always use the median? Signal: chooses the statistic from the decision.
7. Explain E[Y|X=x] versus E[Y|X].
Strong answer: The first is a scalar for a specified observed value x; as x varies, those values form a function. E[Y|X] is that function evaluated at the random observed X. Averaging it recovers E[Y]. Follow-up: Does conditioning prove causality? Signal: has notation and causal restraint.
8. A new feature raises average support load only during rare incidents. How do you advise staffing?
Strong answer: Define ticket count, horizon, incident state, and target SLA. Use total expectation for the average, total variance for within- and between-state risk, and inspect common shocks. Choose a quantile or overflow-cost target, then recommend baseline staffing plus escalation while measuring the incident distribution. Follow-up: What if rollout went only to high-volume customers? Signal: converts formulas into a bounded operational recommendation.
Timed synthesis · eight minutes
A product has 10,000 eligible users. Each has an estimated 2% chance of an urgent ticket, but a documented outage state occurs on 1% of days and creates a correlated spike. Estimate the expected load, describe how you would compute uncertainty, and recommend what the on-call team should monitor before launch.
Incomplete: computes 10,000(0.02)=200 and stops, or assumes independent users despite the outage clue.
Competent: defines the count, uses linearity for the mean, conditions on outage state, includes covariance or a common-shock model, and asks for a capacity or SLA target.
Strong: writes total expectation and total variance, separates within-state and between-state uncertainty, checks population and rollout changes, proposes a quantile or overflow-cost report, and gives a bounded staffing plus escalation recommendation with a validation plan.
Three quick checks
Why does E[X+Y] need no independence assumption?
Expectation distributes over addition by algebra: E[X+Y]=E[X]+E[Y]. Dependence matters for products and for variance because the cross-product becomes a covariance term.
What is the difference between variance and standard deviation?
Variance is expected squared distance from the mean and has squared units. Standard deviation is its square root and returns to the units of the original variable, making it easier to communicate spread.
What could make a mean-based capacity recommendation unsafe?
A rare high-load state, positive dependence, an unmodeled mixture, a heavy tail, or an SLA that asks for a quantile rather than an average. Ask for state-specific distributions, exceedance probabilities, and the cost of overflow.
Interview-ready recap
- Define first: name one draw, the unit, the support, and the probability model.
- Expectation: E[X]=Σxp(x); explain the units and do not call it most likely.
- Variance: Var(X)=E[X²]−E[X]²; SD returns to original units.
- Transform carefully: E[g(X)] is not usually g(E[X]).
- Sums: means add; variance adds covariance terms unless independence is justified.
- Conditioning: E[Y|X=x] is a scalar; E[Y|X] is a random function.
- Mixtures: use total expectation and total variance to expose state and segment risk.
- Decision: use mean for average planning, SD for same-unit spread, and a quantile or tail probability for an SLA.
Technical definitions and identities follow Penn State STAT 414 on mathematical expectation, joint discrete variables, covariance and correlation, conditional distributions, and several independent random variables. The conditional-expectation framing is cross-checked against Berkeley lecture notes; covariance-matrix context uses the NIST/SEMATECH handbook. Interview emphasis is calibrated with the Chan Zuckerberg Initiative 2025 guide, one employer source rather than a universal loop. This lesson intentionally defers measure theory, sampling distributions and the CLT, full decision theory, and causal identification.