Expected value and variance: mean and spread

31 min · 5 drills

In the textbook: Ch. 5.3 Erwartungswert und Varianz

Many quantities are unknown in advance: a day's takings, a year's harvest, the return on an investment. The expected value says how much such a quantity gives on average. The variance says how strongly it fluctuates around that average.

A tutor gives 0 to 3 lessons on Saturdays, depending on how many students sign up. From the last few months he knows:

  • 0 lessons happen with probability 0.1;
  • 1 lesson with 0.3;
  • 2 lessons with 0.4;
  • 3 lessons with 0.2.

He gets 25 € per lesson, and the trip into town costs 12 € every Saturday.

How much does he earn on a Saturday on average, and how strongly do the earnings vary from week to week?

The plain average of 0, 1, 2 and 3, that is 1.5, does not work here: two lessons happen four times as often as none.

Each number of lessons counts with its probability: 0⋅0.1+1⋅0.3+2⋅0.4+3⋅0.2=1.7 lessons on average. So on average he earns 25⋅1.7−12=30.5 € per Saturday. From week to week the earnings typically move about 22.50 € away from that average. This number is called the standard deviation. How it is worked out from the variance is shown below.

Check yourself. A task at exam level: a kiosk by the lake sells 300 ice creams on a sunny day and 100 on a rainy day. Sun comes with probability 0.6. How many ice creams does the kiosk sell per day on average?

Random variable and its distribution

The number of lessons on a Saturday is not known in advance; it depends on chance. Such a number is called a random variable (German “Zufallsgröße”) and is written with a capital letter, here X. To fix it you need two things: which values it can take and with what probability each. That is its distribution (German “Verteilung”), usually written as a table, where the row P(X=x) is the probability that X takes the value x:

Distribution of the number of lessons X: values 0, 1, 2, 3 and their probabilities 0.1, 0.3, 0.4, 0.2lessons xP(X = x)01230.10.30.40.2

The probabilities in the lower row add up to 1: some number of lessons happens on every Saturday. If one probability in the table is missing, it is 1 minus the others; that is the first method of the article “Probability as a share: how many cases fit”.

Expected value and variance: centre and spread

The table of the distribution of lessons in the previous section says what can happen on a Saturday, but not how many lessons there usually are. To answer the tutor, two numbers are needed: the centre and the spread. Picture 10 Saturdays:

  • on about 1 of them there is no lesson;
  • on 3 there is one lesson each;
  • on 4 two each;
  • on 2 three each.

In total that is 1⋅0+3⋅1+4⋅2+2⋅3=17 lessons, on average 17/10=1.7 per Saturday. The division by 10 can be done term by term: 3 Saturdays out of 10 is the probability 0.3, 4 out of 10 is 0.4. So the same 1.7 comes out if you multiply each possible value x1,x2,… by its probability p1,p2,… and add up. This gives the expected value (German “Erwartungswert”), written E(X) or μ (“mu”):

E(X)=x1⋅p1+x2⋅p2+…E(X)=0⋅0.1+1⋅0.3+2⋅0.4+3⋅0.2=1.7

It is the average over many repetitions, not a value that must occur: no Saturday has 1.7 lessons.

The spread. How far do the values lie from the centre 1.7? Here are the deviations x−μ and their squares:

lessons x0123
deviation x−μ−1.7−0.70.31.3
square2.890.490.091.69

The weighted average of the deviations themselves is always 0: pluses and minuses cancel. So you first square the deviations, a square is always positive, and only then average. The result is written V(X):

V(X)=E(X−μ)2=0.1⋅2.89+0.3⋅0.49+0.4⋅0.09+0.2⋅1.69=0.81

This is the variance (German “Varianz”). Its unit is lessons squared, so take the square root: the standard deviation (German “Standardabweichung”) σ=0.81=0.9 lessons, the typical distance from the mean.

A short way to the variance. Expanding the square gives a second formula, usually faster:

V(X)=E(X2)−μ2
  1. E(X2) is computed like E(X), only with the values squared: 0⋅0.1+1⋅0.3+4⋅0.4+9⋅0.2=3.7.
  2. Subtract the square of the mean: V(X)=3.7−1.72=3.7−2.89=0.81, the same number.

Converting to money: Y = aX + b

The earnings of a Saturday are Y=25X−12: 25 € per lesson minus 12 € for the trip. Over 10 Saturdays he receives 25⋅17 and pays 10⋅12, on average 25⋅1.7−12=30.5 €. The mean is converted with the same formula as the quantity itself.

The spread is different. Subtracting 12 € shifts all values equally; the distance to the mean does not change. The factor 25 stretches every deviation 25 times, and the squared deviation 252=625 times. Hence, with the factor a (here 25) and the shift b (here −12):

  • E(aX+b)=a⋅E(X)+b: here 25⋅1.7−12=30.5 €;
  • V(aX+b)=a2⋅V(X): here 625⋅0.81=506.25; the number b does not enter the variance;
  • σ(aX+b)=∣a∣⋅σ(X): here 25⋅0.9=22.5 €.

The answer to the question from the start: 30.5 € per Saturday on average, with a typical deviation of 22.5 €.

Your turn1 of 5

E(X)=5, V(X)=4 and Y=3X−2. What is V(Y)?

On the formula sheet: E(X)=a1p1+…, V(X)=E(X−μ)2, V(X)=E(X2)−μ2 and V(aX+b)=a2V(X).

The harvest rises or falls by a given percentage: the variance of two scenarios

For the tutor the values stood ready in the table, and there were four of them. In the first exam task there are two values, and they first have to be worked out from percentages. In the exam, amounts are written in GE, “Geldeinheiten”, monetary units: just money.

This is how the task looks in the exam:

Exam-style task

Eine Imkerei schleudert in einem normalen Sommer 500 kg Honig. Für diesen Sommer gilt: Mit der Wahrscheinlichkeit 0.7 blüht die Linde lange, und der Ertrag steigt um 6 %; sonst fällt er wegen der Trockenheit um 10 %. Berechnen Sie die Varianz der Honigmenge (in kg²).

  1. a)1146
  2. b)1098
  3. c)1344
  4. d)192
  5. e)37

The text has two scenarios (“with probability … otherwise …”) and percentages of the normal value. This is a distribution with two values: the same table as the tutor's, only with two columns. First you get the values themselves from the percentages, then you compute as above.

yield after a rise 530, after a drought 450

Two scenarios of the honey yield: value, probability, deviation from the mean and contribution to the variancehoney x, kgpx − μp · (x − μ)²long bloomdroughttotal5300.7??4500.3????
Step 1 of 4Two values

A rise of 6 % is 500⋅1.06=530 kg, a fall of 10 % is 500⋅0.9=450 kg. Drought comes with probability 1−0.7=0.3.

Why is the deviation of “drought” larger in size than that of “long bloom”, although 10 and 6 percent are close? Hint: where does the mean 506 lie, and which scenario is more likely.

A short way for two values. If the values x1 and x2 occur with probabilities p and 1−p, then

V(X)=p⋅(1−p)⋅(x1−x2)2

For the honey: 0.7⋅0.3⋅802=0.21⋅6400=1344. This line is not on the formula sheet, but you can easily check it with the table in the honey example above.

A farm harvests 800 kg of olives in a normal year. With probability 0.6 the harvest rises by 5 %; otherwise it falls by 15 %.

Find the expected value and the variance of the harvest.

800⋅1.05=840 kg and 800⋅0.85=680 kg, probabilities 0.6 and 0.4.

0.6⋅840+0.4⋅680=504+272=776 kg.

0.6⋅0.4⋅(840−680)2=0.24⋅25600=6144 kg².

Here the probability itself is unknown: a shop takes 420 € on a good day, 300 € on a bad day, and 348 € on average.

With what probability is a day good?

A good day with probability p, a bad one with 1−p: 420p+300(1−p)=348.

300+120p=348, so 120p=48 and p=0.4.

Have a go: variance of the price. A share costs 50 €. Within a year it rises by 10 % with probability 0.6 and falls by 5 % with probability 0.4. The two values of the price: 50⋅1.10=55 and 50⋅0.95=47.5, the expected value 0.6⋅55+0.4⋅47.5=52 €. Find the variance the short way.

Your turn2 of 5

A shop's revenue is normally 2000 GE a week. With probability 0.25 it rises by 20 %; otherwise it falls by 4 %. What is the variance of the weekly revenue (in GE²)?

Traps. The wrong options of the exam task and of tasks of this kind:

  • Standard deviation instead of variance, option (e), 37: this is 1344=36.66. The variance is asked, in kg², no square root.
  • Only one probability: 0.7⋅802 instead of 0.7⋅0.3⋅802. The short way has both probabilities.
  • Percentages swapped: the 6 % rise is assigned to the drought. Check: reread which scenario the probability 0.7 belongs to.
  • Wrong probability: a different number is taken instead of 1−0.7, for example 0.7 again. The two scenario probabilities add up to 1.
  • Difference not squared: p⋅(1−p)⋅(x1−x2) without the square. The variance always has the unit squared.

On the formula sheet: E(X)=a1p1+… and V(X)=E(X−μ)2. The short way p(1−p)(x1−x2)2 is not on the sheet.

Expected costs with X² when μ and σ are given

In the honey task the distribution was given in full, as two scenarios. In the next one it is missing altogether: of the quantity X only μ and σ are known, and the costs depend on X2:

Exam-style task

Der Energieverbrauch X (in kWh) einer Werkhalle hat den Erwartungswert 104 und die Standardabweichung 21. Die Stromkosten betragen K(X)=1200+18X+0.83X2 (in GE). Wie hoch sind die erwarteten Stromkosten E(K)?

  1. a)12049.28
  2. b)12415.31
  3. c)16040.75
  4. d)10863.40
  5. e)12713.28

The costs depend on X2, and for X only the expected value and the standard deviation are given, with no distribution table. We saw that E(aX+b)=aE(X)+b: a sum may be averaged piece by piece. Then E(K)=1200+18E(X)+0.83E(X2), and only E(X2) is unknown. It comes from the short way to the variance, read backwards: V(X)=E(X2)−μ2, so E(X2)=V(X)+μ2.

mean of the sum: each term on its own

Expected costs by term: 1200, 18 times E(X) and 0.83 times E(X²)termGEfixedlinear partquadratic parttotal1200?18 · E(X)?0.83 · E(X²)?E(K)?
Step 1 of 4Split the costs

The mean of a sum is the sum of the means, and a fixed factor comes out: E(K)=1200+18⋅E(X)+0.83⋅E(X2).

Suppose the use is 100 or 108, equally often: mean 104, standard deviation 4. Why is E(X)=104 enough for the linear part but not for the quadratic one? Hint: what is the average of 1002 and 1082, and what is 1042.

Without a story, just numbers: E(X)=−2, V(X)=3 and Y=−4X+1. Find E(Y2).

E(Y)=−4⋅(−2)+1=9, V(Y)=(−4)2⋅3=48.

E(Y2)=V(Y)+E(Y)2=48+81=129.

The material use X has E(X)=20 and σ=3, the costs are K(X)=100+5X+0.5X2 €. Find the expected costs. First E(X2)=V(X)+E(X)2=32+202=409. Substituting into E(K)=100+5⋅E(X)+0.5⋅E(X2) gives 100+5⋅20+0.5⋅409=100+100+204.5=404.5 €. 400 is K(20): the costs at the mean use, without the variance.

Your turn3 of 5

The raw material use X has E(X)=10 and σ=3; the costs are K(X)=100+5X+2X2. What are the expected costs E(K)?

Traps. The wrong options of the exam task and of tasks of this kind:

  • Variance ignored, option (a), 12049.28: this is K(104), the cost at the mean use. E(X2) is larger than μ2 by exactly the variance.
  • Square of the sum, option (c), 16040.75: (μ+σ)2=1252 is taken instead of μ2+σ2. That is the cost at the use μ+σ, not a mean.
  • σ not squared: E(X2)=21+1042. The formula needs the variance, σ2.
  • μ2 forgotten: E(X2)=441. That is only the spread without the centre.
  • Fixed costs forgotten: without the 1200 GE. The mean of a constant is the constant itself.
  • Factor only on the mean: 0.83⋅μ2+σ2. The factor 0.83 stands before the whole E(X2).
  • For E(Y2): forgetting to square E(Y), or taking V(Y) without a2.

On the formula sheet: V(X)=E(X2)−μ2, V(aX+b)=a2V(X) and E(aX+bY). The formula E(X2)=V(X)+μ2 comes from the first line by rearranging.

Portfolio of independent parts: E(R) and σ(R)

The costs depended on a single random variable. In the third task there are three, the routes of a truck fleet, and the spread of the whole sum is built from the spreads of the parts:

Exam-style task

Der Disponent einer Spedition fragt, wie stark der Gewinn je eingesetzter GE für die ganze Flotte schwankt. Die Lkw fahren zu verschiedenen Anteilen auf drei Routen A, B und C, und die Rendite jeder Route schwankt unabhängig von den anderen:

ABCAnteil25 %25 %50 %Erwartete Rendite0.050.130.12Standardabweichung0.040.040.04

Berechnen Sie die Standardabweichung σ(R) der Portfoliorendite. Runden Sie auf vier Nachkommastellen.

  1. a)0.0231
  2. b)0.0006
  3. c)0.0198
  4. d)0.0208
  5. e)0.0245

The shares (weights) of the parts and the word “independently” are given, and the standard deviation of the whole portfolio is asked. A portfolio is an investment split into several parts (in detail in the article “Portfolio: return and risk”). The return is the growth of the investment over a year as a share, for example 0.06; it is not known in advance, so it is a random variable.

In the task the investment is a fleet: trucks run on three routes in different shares. The return of the fleet is R=0.25RA+0.25RB+0.5RC, a weighted sum; here RA, RB and RC are the returns of routes A, B and C. The expected returns do not affect the spread, which takes two rules:

  • for each part V(aX)=a2V(X), as with the tutor;
  • for independent parts the variances add, V(X+Y)=V(X)+V(Y), as with the tutor's two Saturdays in the box “The sum of two variables and independence”.

expected return 0.105, no effect on σ

Contributions of the routes to the portfolio variance: share, standard deviation and share squared times varianceshare areturn μσa² · σ²ABCportfolio0.250.050.04?0.250.130.04?0.50.120.04???
Step 1 of 3Expected value

E(R)=0.25⋅0.05+0.25⋅0.13+0.5⋅0.12=0.105. The task does not ask for the expected return, and it does not enter σ(R).

Why does the portfolio fluctuate less than any single route (0.0245 against 0.04)? Hint: when one route slumps, do the others slump in the same year.

A portfolio holds two independent securities with the shares 0.6 and 0.4, their standard deviations are 0.2 and 0.1. Find the standard deviation of the portfolio. The shares are squared: V=0.62⋅0.22+0.42⋅0.12=0.0144+0.0016=0.016, σ=0.016=0.1265. This is less than 0.6⋅0.2+0.4⋅0.1=0.16: with independent securities the spreads partly cancel.

Your turn4 of 5

A portfolio consists of 40 %, 40 % and 20 % of three independent securities, each with a return standard deviation of 0.1. What is the standard deviation of the portfolio return?

Traps. The wrong options of the exam task and of tasks of this kind:

  • Variance instead of standard deviation, option (b), 0.0006: the square root is missing. Check: σ of the portfolio is of the same order as the σ of the parts.
  • Without weights, option (a), 0.0231: all shares taken as one third. The weights from the table in the task enter squared.
  • Weights not squared: 0.25⋅0.0016+…. V(aX)=a2V(X), not aV(X).
  • Standard deviations added linearly: 0.25⋅0.04+0.25⋅0.04+0.5⋅0.04=0.04. The variances of independent parts add, not the standard deviations.
  • Wrong figure: the expected returns are put into the spread calculation. They are needed only for E(R).

Variance of the mean σ²/n: the smallest number of measurements

The same calculation tells you how many measurements you need for an accurate mean. Let each measurement Xi fluctuate with variance σ2, the measurements be independent, and the mean be Xˉ=(X1+⋯+Xn)/n:

  1. Variance of the sum of n independent measurements: nσ2.
  2. Dividing by n is a factor a=1/n, and it enters squared: nσ2/n2.
  3. Result: V(Xˉ)=σ2n and σ(Xˉ)=σn.

The assembly time of a workpiece in a workshop fluctuates with standard deviation 6 minutes.

How many workpieces must be timed for the standard deviation of the mean to be at most 0.7 minutes?

The standard deviation of the mean is bounded: 6n≤0.7.

n≥6/0.7=8.571, so n≥8.5712=73.47.

n=74: with 73 workpieces the deviation is still slightly above 0.7.

Your turn5 of 5

A measurement fluctuates with standard deviation 9. How many independent measurements are needed for the variance of their mean to be at most 2.5?

Trap. Reading the bound on the variance as a bound on the standard deviation, that is not squaring σ, or taking n one larger than needed.

On the formula sheet: V(aX+b)=a2V(X), V(X+Y)=V(X)+V(Y) for independent variables and V(Xˉ)=σ2n.

At a glance: centre, spread and three methods

The topic in a minute

  • Expected value: E(X)=x1⋅p1+x2⋅p2+…, the average over many repetitions. Trap: the plain average of the values without probabilities.
  • Variance: V(X)=E(X−μ)2=E(X2)−μ2, σ=V. Trap: giving σ when V is asked, and vice versa.
  • Conversion: E(aX+b)=aE(X)+b, V(aX+b)=a2V(X).
  • Sum of independent variables: the variances add, the weights enter squared; V(Xˉ)=σ2/n.
  • Two values with percentages

    Two scenarios “with probability … otherwise …” and a change in percent of the normal value.
    V(X)=p(1−p)(x1−x2)2

    Trap: giving the standard deviation instead of the variance.

  • Expected quadratic costs and E(X²)

    Costs or a quantity with X2, given μ and σ without a table.
    E(X2)=V(X)+μ2

    Trap: putting μ into the costs and forgetting the variance.

  • Variance of a sum: portfolio and sample

    Shares of independent parts or the mean of n independent measurements, with a question about the spread.
    V(a1X1+a2X2+…)=a12σ12+a22σ22+…

    Trap: adding standard deviations or forgetting the square root.

A day's revenue takes separate values, while a time or a mass can take any. For such quantities the probability is an area under a curve, and the curve the exam uses most, the normal distribution, is the next article.

Cards to memorise

Tap a card to see the formula. All topic cards

Formula

E(a+bX+cX2)= ?

Formula

Portfolio of independent securities with shares ai and standard deviations σi: what is V(R)?

Now practise it

Expected value and variance: mean and spread

Trainer · Probability

Practise
Next: Normal distribution: probability as area
0/5

Was this article helpful?