1.4 Expected value and variance
“Average” and “spread” — the same average does not mean the same safety
What you will learn
- Calculate the expected value as “an average weighted by probability”
- Express “how spread out” something is with the variance and standard deviation
- Explain why the same average can mean different safety when the spread differs
Build intuition
Two automated vehicles, A and B, were each tested six times on stopping before a stop line. The stopping positions (how many metres before the line) were as follows. A negative value means the vehicle crossed the line.
| Run 1 | Run 2 | Run 3 | Run 4 | Run 5 | Run 6 | Mean | |
|---|---|---|---|---|---|---|---|
| Vehicle A | 1.1 | 0.9 | 1.0 | 1.0 | 1.1 | 0.9 | 1.0 m |
| Vehicle B | 1.8 | 0.2 | 1.5 | −0.3 | 1.2 | 1.6 | 1.0 m |
Looking only at the average, A and B have the same result: “1.0 m before the stop line”. Yet B crossed the line in one run out of six. To talk about safety, we need to express the spread in numbers as well as the average.
Check with math
① Expected value: an average weighted by probability
The “average value” of a quantity \(X\) that follows a probability distribution (1.3) is called its expected value, \(E[X]\). You multiply each possible value by its probability and add everything up.
Example: if the number of driver interventions \(X\) on a certain route is 0 (50%), 1 (30%) or 2 (20%), then
The data average \(\bar{x}\) (0.2) is an estimate of this expected value from data. The 1.0 m averages in the table above follow the same idea.
② Variance and standard deviation: the size of the spread
Spread is measured as “deviation from the mean”. But positive and negative deviations cancel out, so we square them before averaging. The result is the variance. Because the variance is in squared units (m²), we take its square root to return to the original units; this is the standard deviation \(\sigma\).
Here \(\mu = E[X]\) (the mean). Let us calculate with the data in the table. A’s deviations are 0.1, −0.1, 0, 0, 0.1 and −0.1, so
B’s deviations are 0.8, −0.8, 0.5, −1.3, 0.2 and 0.6, so
B’s spread is about ten times A’s. Note that when estimating the “true” spread from sample data, we sometimes divide by 6 − 1 = 5 instead of 6. The reason is covered in 1.6.
③ Expected value and variance of the distributions in 1.3
| Distribution | Expected value | Variance | In the 1.3 examples |
|---|---|---|---|
| Binomial (n, p) | \(np\) | \(np(1-p)\) | n = 10, p = 0.9 → expected 9, σ ≈ 0.95 |
| Poisson (m) | \(m\) | \(m\) | m = 2 → expected 2, σ ≈ 1.41 |
| Normal (μ, σ) | \(\mu\) | \(\sigma^2\) | μ and σ are directly the mean and spread |
④ Setting a margin that accounts for the spread
If we assume the stopping positions follow a normal distribution, we can use the rule of thumb from 1.3 (about 99.7% within the mean ± 3σ).
- Vehicle A: mean − 3σ = 1.0 − 3 × 0.08 ≈ 0.76 m. It almost certainly stops before the line
- Vehicle B: mean − 3σ = 1.0 − 3 × 0.78 ≈ −1.3 m. The probability of crossing the line is estimated at about 10%
To bring B’s probability of crossing the line down to 0.1% or less, you would need to aim for a mean at least 3.1σ ≈ 2.4 m before the line — or reduce the spread σ itself. In safety design, this calculation is how you compare the two options: increase the margin or reduce the spread. That said, six runs are really too few to pin down σ; how reliable such estimates are is covered in 1.6.
Advanced: weighting per-condition rates by exposure
The expected value in ① was a sum of “value × probability”. The same form appears again and again in safety estimates. When the accident rate differs by condition (weather, road type, time of day and so on), the rate over the whole ODD is the expected value of the per-condition rates \(\lambda_i\), weighted by the share of driving spent in each condition, \(w_i\) (the exposure).
Example: 90% of driving is in clear weather and 10% in rain, and the accident rate in rain is 10 times that in clear weather. Taking the clear-weather rate as 1 (a relative value), the overall rate is 0.9 × 1 + 0.1 × 10 = 1.9 — about twice what you would measure in clear weather alone. Moreover, more than half of all accidents (1.0 ÷ 1.9 ≈ 53%) happen in rain, which is only a tenth of the driving. If the share of rain rises to 20% the rate becomes 2.8; if rain is excluded from the ODD (the function is not used in rain) it returns to 1.
The formula teaches three things. (1) An average over everything is dragged by a few harsh conditions. (2) If the mix of test conditions differs from the real exposure (testing only on clear days), the estimate is off. (3) Both the per-condition rates \(\lambda_i\) and the exposures \(w_i\) have to be measured. Tabulating the ODD conditions to check test coverage (5.6, 5.9) and adding up the estimates of unknown hazards condition by condition (5.2) are both calculations of this form. How the ODD is defined is covered in 4.1.
Connection to automated driving
- Describe performance as “mean ± spread”: detection range, stopping position, reaction time — automated-driving performance is evaluated with the standard deviation, not the mean alone. Even with a good average, a large spread means a certain share of cases will fall on the dangerous side.
- It justifies safety margins: margins are set to account for spread, as in “still on the safe side at mean − 3σ”. But if the real distribution has heavier tails than a normal distribution, even 3σ may not be enough. → 1.9
- Expected value alone is not enough: “minor accidents now and then” and “a severe accident very rarely” may have the same expected harm, yet they are perceived very differently. Hazard evaluation in ISO 26262 and SOTIF therefore assesses factors such as severity, frequency (exposure) and controllability separately. → 5.4
- Look at the spread under each condition: if the spread of stopping positions differs between dry and rainy weather, a σ computed from all the data together dilutes the danger on rainy days. It is important to evaluate each ODD condition separately. → 4.1, 5.6
Summary
- The expected value is the sum of “value × probability”; the data average is an estimate of it
- The variance is “the average of the squared deviations from the mean”, and the standard deviation is its square root (back in the original units)
- Even with the same average, a large spread makes it easier to fall on the dangerous side. Safety margins are set with σ in mind
Quick quiz
Q1. If the number of interventions is 0 (60%), 1 (30%) or 3 (10%), what is the expected value?
0.6. 0 × 0.6 + 1 × 0.3 + 3 × 0.1 = 0.6.
Q2. What are the variance and standard deviation of the data 2, 4, 6? (Divide by the count, 3.)
Variance about 2.67, standard deviation about 1.63. The mean is 4 and the deviations are −2, 0 and 2, so the average of the squares is (4 + 0 + 4) ÷ 3 ≈ 2.67; its square root is about 1.63.
Q3. If the stopping position averages 2.0 m before the line with a standard deviation of 1.0 m (assume a normal distribution), roughly what is the probability of crossing the line?
About 2.5% (more precisely about 2.3%). The stop line lies 2σ below the mean. About 5% falls outside ±2σ, and only half of that is on the crossing side, so about 2.5%.
Further reading
- Next lesson: 1.5 Law of large numbers and the central limit theorem
- Related: 1.3 Probability distributions, 1.6 Estimation and confidence intervals (why we divide by n − 1), 1.9 Extreme values and heavy tails
- Video lecture: YouTube (about 4 minutes) (the key points explained with slides and narration; the Japanese article has a Japanese video)