Skip to content
datarekha
Statistics & Probability Easy Asked at GoogleAsked at MetaAsked at AmazonAsked at Microsoft

Define expected value and variance. What are their key properties?

The short answer

Expected value is the probability-weighted center of a random variable, while variance is the expected squared distance from that center. Expected value is always linear, but variance needs scaling and covariance terms; independence is only required for the familiar variance-addition shortcut.

How to think about it

Expected value is the probability-weighted average outcome of a random variable. Variance is the probability-weighted average of its squared distance from that average. Expectation describes the centre; variance describes the spread, and the important interview distinction is that expectation is linear while variance is not.

Imagine a game that pays £5 forty percent of the time and loses £2 sixty percent of the time. One play can be surprising. A hundred plays are easier to reason about. Expected value tells you the average profit per play over many repetitions. Variance tells you how violently individual results can move around that average.

Expected value: the probability-weighted centre

A random variable is a numerical rule that assigns a number to each possible outcome. If X is a discrete random variable, its expected value is

E[X] = Σ x · P(X = x)

You multiply each possible value by its probability, then add the results. For a continuous random variable with probability density f_X(x), the equivalent expression is

E[X] = ∫ x · f_X(x) dx

The mechanism is simple: outcomes that occur often should influence the average more than outcomes that are rare.

For the game:

E[X] = 5 × 0.4 + (-2) × 0.6
     = 2.0 - 1.2
     = £0.80

Over a very large number of plays, the average profit should approach 80 pence per play, assuming the probabilities stay the same. It does not mean the next play earns 80 pence. There is no 80-pence outcome in the game.

That last point matters. Expected value does not have to be a value the random variable can actually take. A fair six-sided die has expected value 3.5, even though no roll produces 3.5.

The first key property is linearity of expectation:

E[aX + bY + c] = aE[X] + bE[Y] + c

Here, a, b, and c are constants. This property holds whether X and Y are independent, positively correlated, negatively correlated, or completely dependent. No covariance term is needed.

For example, if two game payouts are X₁ and X₂, then

E[X₁ + X₂] = E[X₁] + E[X₂]

even if the two games influence each other. The reason is that expectation distributes over addition before any question about relationships between variables arises.

Two small consequences are worth remembering:

  • E[c] = c for a constant.
  • E[aX] = aE[X].

Variance: how far outcomes wander

Let μ = E[X]. Variance is defined as

Var(X) = E[(X - μ)²]

In words, subtract the mean from each outcome, square the difference, and take the expected value.

The square does two jobs. It makes positive and negative deviations count equally, and it gives unusually large deviations disproportionately more weight. A result ten units from the mean contributes one hundred squared units, not merely ten.

The computational identity is

Var(X) = E[X²] - (E[X])²

It comes from expanding the square:

(X - μ)² = X² - 2μX + μ²

Taking expectations gives E[X²] - 2μE[X] + μ². Since E[X] = μ, the middle terms simplify to -μ², leaving E[X²] - μ².

Variance is always non-negative because it is an average of squared quantities. It is zero only when every possible outcome with nonzero probability is the same value.

Variance also has squared units. If X is measured in pounds, Var(X) is measured in pounds squared. That is mathematically convenient but hard to interpret directly, so practitioners often use the standard deviation, defined as

SD(X) = √Var(X)

Standard deviation returns to the original units. It gives the game’s typical spread in pounds, although “typical” should not be treated as a universal guarantee.

For the game:

E[X²] = 5² × 0.4 + (-2)² × 0.6
      = 25 × 0.4 + 4 × 0.6
      = 12.4

Var(X) = 12.4 - 0.8²
       = 12.4 - 0.64
       = 11.76

SD(X) = √11.76
      ≈ £3.43

The average profit is £0.80, but the standard deviation is £3.43. The reward is positive, yet individual results are much larger than the average. That is the difference between a good long-run mean and a calm experience.

The variance rules interviewers expect

The main rules fit together like this:

QuantityRuleWhat changes
Expected valueE[aX + bY + c] = aE[X] + bE[Y] + cEverything remains additive
ShiftVar(X + c) = Var(X)Moving the centre does not change spread
ScaleVar(aX) = a²Var(X)Stretching outcomes stretches squared spread
SumVar(X + Y) = Var(X) + Var(Y) + 2Cov(X,Y)The relationship between variables matters

The shift rule works because adding c moves both the outcomes and their mean by the same amount. Their deviations from the mean do not change.

The square on the scaling factor is easy to miss. If every payout doubles, every deviation doubles, but every squared deviation becomes four times as large. Therefore Var(2X) = 4Var(X). A negative scale also produces the same variance because (-a)² = a².

The extra term in the sum rule contains covariance, which measures whether two variables tend to move together:

Cov(X,Y) = E[(X - E[X])(Y - E[Y])]

Positive covariance means large values of X tend to arrive with large values of Y, increasing the spread of their sum. Negative covariance means one tends to offset the other.

If X and Y are independent, their covariance is zero, so the familiar shortcut applies:

Var(X + Y) = Var(X) + Var(Y)

Independence is sufficient, but it is stronger than necessary. Zero covariance is enough for this particular variance shortcut. The reverse is not generally true: zero covariance does not prove independence.

The game example under repetition

Suppose X₁ and X₂ are independent copies of the game. The total profit has

E[X₁ + X₂] = 0.80 + 0.80 = £1.60

Var(X₁ + X₂) = 11.76 + 11.76 = 23.52

SD(X₁ + X₂) = √23.52 ≈ £4.85

For the average of 100 independent plays, the expected value is still £0.80 per play, but the standard deviation of the average is

3.43 / √100 = £0.343

That reduction happens because independent positive and negative fluctuations partly cancel. The standard deviation of a sum grows roughly with the square root of the number of observations, while the sum’s expected value grows directly with the number.

Now imagine the accounting system accidentally records the same game outcome twice, so X₂ = X₁. The total is 2X₁, not a sum of independent plays:

Var(X₁ + X₂) = Var(2X₁)
             = 4 × 11.76
             = 47.04

Using the covariance formula gives the same answer:

11.76 + 11.76 + 2 × 11.76 = 47.04

This is why treating correlated observations as independent can make uncertainty look much smaller than it really is.

Common trap. Independence is not needed for adding expected values. It is relevant when simplifying variances. Saying “variance always adds” is wrong unless the covariance terms are zero.

The senior-level nuance

Neither expected value nor variance completely describes risk. Two distributions can have the same expected value and variance but very different tail behaviour. Variance also treats upside and downside symmetrically. A £100 gain and a £100 loss contribute the same squared deviation, even if only the loss threatens the business.

For a risk-neutral decision-maker, expected value may be an appropriate objective: a guaranteed £0.80 and the game above are equally attractive on mean profit alone. A risk-averse decision-maker may prefer the guarantee because it has zero variance. In a production setting, you might also inspect quantiles, probability of loss, or expected shortfall, which focuses on the average outcome in the worst tail.

There is a useful conditional version of both ideas. If Y divides observations into groups, then

E[X] = E[E[X | Y]]

The overall mean is the mean of the group means. The law of total variance says

Var(X) = E[Var(X | Y)] + Var(E[X | Y])

The first term is variation within groups. The second is variation between group means. This decomposition explains why a single overall variance can hide an important pattern, such as stable behaviour within each region but large differences between regions.

Finally, these formulas assume the relevant moments exist. Ordinary dice, game payouts, and most interview examples have finite expectation and variance. Some heavy-tailed distributions do not have a finite mean or variance, so writing down the formulas without checking that assumption can be invalid.

What they’ll ask next

Does independence matter for expected value?

No. Linearity gives E[X + Y] = E[X] + E[Y] regardless of dependence. Independence matters for the common variance shortcut because dependence can create a nonzero covariance term.

Why use standard deviation instead of variance?

Standard deviation is in the same units as the original measurement. A standard deviation of £3.43 is interpretable; a variance of 11.76 pounds squared is mainly useful for algebra, estimation, and optimisation.

Why does sample variance often divide by n - 1?

For observed data, the population mean is usually unknown and replaced by the sample mean. Using n - 1 rather than n corrects the resulting downward bias under the usual independent, identically distributed assumptions. The population variance formula itself does not inherently require n - 1.

Say this in the interview: Expected value is the probability-weighted centre, variance is the expected squared distance from that centre, expectation is always linear, and variance adds cleanly only when covariance terms vanish.

Learn it properly What is probability

Keep practising

All Statistics & Probability questions

Explore further