Salta al contenuto
Note per Studenti Variance Report

Variance

In questa pagina 4

The variance of a r.v. is the second most important parameter that summarises its behaviour. It is an index of how much the values of the r.v. are spread around its expected value.

Motivation

Consider the grades of two students, Giovanni and Paolo, modelled as r.v.'s: X∼U({18,24,30}) (Giovanni),Y∼U({23,24,25}) (Paolo).X \sim \mathcal{U}(\{18, 24, 30\}) \ \text{(Giovanni)}, \qquad Y\sim\mathcal{U}(\{23, 24, 25\}) \ \text{(Paolo)}. It is immediate to compute E(X)=13 18+13 24+13 30=24,E(Y)=13 23+13 24+13 25=24.E(X) = \tfrac13\,18 + \tfrac13\,24 + \tfrac13\,30 = 24, \qquad E(Y) = \tfrac13\,23 + \tfrac13\,24 + \tfrac13\,25 = 24. The expected values of XX and YY are identical and yet the behaviour of the two r.v.'s is very different: Giovanni's grades are disordered and genius, Paolo's are predictable and steady. (See Expected ValueThe expected value E(X) is the sum of the values of a discrete random variable weighted by their probabilities; it is linear, lies between the smallest and the largest value, and equals the barycenter of the density.Expected Value →.)

Possible indexes of variability

  • ∑xk(xk−E(X))\sum_{x_k}\big(x_k - E(X)\big): no, it does not take into account pX(xk)p_X(x_k).
  • ∑xk(xk−E(X))pX(xk)\sum_{x_k}\big(x_k - E(X)\big)p_X(x_k): no, it is always equal to 00 (this is the barycenter condition of the mechanical interpretation).
  • ∑xk∣xk−E(X)∣pX(xk)\sum_{x_k}\big|x_k - E(X)\big|p_X(x_k): this could be OK because it takes into account pX(xk)p_X(x_k) and the variations of both signs ++ and −- with respect to E(X)E(X), but it is difficult to work with because of the absolute value.
  • ∑xk(xk−E(X))2pX(xk)\sum_{x_k}\big(x_k - E(X)\big)^2p_X(x_k): this is it!

Definition. Let X∼pX(xk)X \sim p_X(x_k), xk∈Xx_k\in\mathcal{X}. The variance of XX, denoted var⁡(X)\operatorname{var}(X), is defined as var⁡(X)=∑xk∈X(xk−E(X))2 pX(xk).\operatorname{var}(X) = \sum_{x_k\in\mathcal{X}}\big(x_k - E(X)\big)^2\,p_X(x_k).

Example. X∼b(p)X \sim b(p), then E(X)=pE(X) = p and var⁡(X)=∑xk(xk−E(X))2pX(xk)=(0−p)2(1−p)+(1−p)2p=p(1−p).\operatorname{var}(X) = \sum_{x_k}(x_k - E(X))^2p_X(x_k) = (0-p)^2(1-p) + (1-p)^2p = p(1-p).

Example. X=cX = c (degenerate): var⁡(X)=0\operatorname{var}(X) = 0 (to be checked: the only term is (c−c)2⋅1=0(c-c)^2\cdot1 = 0).

Applied to the motivation (computed here from the definition, not on the page): var⁡(X)=13(36+0+36)=24\operatorname{var}(X) = \frac13(36 + 0 + 36) = 24 for Giovanni, var⁡(Y)=13(1+0+1)=23\operatorname{var}(Y) = \frac13(1+0+1) = \frac23 for Paolo.

For the geometric r.v. G(p)G(p), var⁡(X)=1−pp2\operatorname{var}(X) = \frac{1-p}{p^2} (see Geometric Random VariableThe geometric random variable counts the trial at which the first success occurs in independent binary trials; it has infinite alphabet, density (1-p)^(k-1) p, mean 1/p and the memoryless property.Geometric Random Variable →).

Properties of the variance

1. var⁡(X)=E((X−E(X))2)\operatorname{var}(X) = E\big((X - E(X))^2\big). Proof. Recalling the LOTUS (Functions of Random Variables and LOTUSA function g(X) of a discrete random variable is again a discrete random variable whose density is obtained by summing p_X over the preimage, and the LOTUS computes E(g(X)) directly from p_X without finding the density of g(X).Functions of Random Variables and LOTUS →), it is apparent that the definition of the variance coincides with the computation of the expected value of the function of random variable Y=(X−E(X))2Y = (X - E(X))^2.

2. var⁡(X)≥0\operatorname{var}(X)\ge0, and var⁡(X)=0\operatorname{var}(X) = 0 iff XX is degenerate. Proof. The function (xk−E(X))2≥0(x_k - E(X))^2 \ge 0 for all xk∈Xx_k\in\mathcal{X}, therefore ∑xk(xk−E(X))2pX(xk)≥0\sum_{x_k}(x_k-E(X))^2p_X(x_k)\ge0 for all pX(⋅)p_X(\cdot). If var⁡(X)=0\operatorname{var}(X)=0 then for all xkx_k with pX(xk)>0p_X(x_k)>0 it is (xk−E(X))2=0(x_k - E(X))^2 = 0, i.e. xk=E(X)x_k = E(X); this means that there exists a unique value xk∈Xx_k\in\mathcal{X} with positive probability, which is exactly the case of a degenerate r.v. Vice versa, if X=cX = c is a degenerate r.v. then trivially var⁡(X)=0\operatorname{var}(X) = 0. □\square

3. var⁡(aX)=a2var⁡(X)\operatorname{var}(aX) = a^2\operatorname{var}(X). Special case: var⁡(−X)=var⁡(X)\operatorname{var}(-X) = \operatorname{var}(X). Proof. E(aX)=aE(X)E(aX) = aE(X), therefore var⁡(aX)=E((aX−E(aX))2)=E((aX−aE(X))2)=E(a2(X−E(X))2)=a2var⁡(X).□\operatorname{var}(aX) = E\big((aX - E(aX))^2\big) = E\big((aX - aE(X))^2\big) = E\big(a^2(X-E(X))^2\big) = a^2\operatorname{var}(X). \quad\square

4. var⁡(X+c)=var⁡(X)\operatorname{var}(X + c) = \operatorname{var}(X). Proof. E(X+c)=E(X)+cE(X+c) = E(X)+c, therefore var⁡(X+c)=E((X+c−E(X+c))2)=E((X+c−E(X)−c)2)=var⁡(X)\operatorname{var}(X+c) = E\big((X + c - E(X+c))^2\big) = E\big((X + c - E(X) - c)^2\big) = \operatorname{var}(X). □\square

5. var⁡(X)=E(X2)−[E(X)]2\operatorname{var}(X) = E(X^2) - [E(X)]^2. Proof. var⁡(X)=E((X−E(X))2)=E(X2−2E(X)X+[E(X)]2)=E(X2)−2E(X)E(X)+[E(X)]2=E(X2)−[E(X)]2.□\operatorname{var}(X) = E\big((X-E(X))^2\big) = E\big(X^2 - 2E(X)X + [E(X)]^2\big) = E(X^2) - 2E(X)E(X) + [E(X)]^2 = E(X^2) - [E(X)]^2. \quad\square (Linearity of EE is used, with E(X)E(X) treated as a constant; E(X2)E(X^2) is computed with the LOTUS.)

Corollary. E(X2)≥[E(X)]2E(X^2)\ge[E(X)]^2, with equality iff XX is degenerate (since var⁡(X)≥0\operatorname{var}(X)\ge0 with equality iff degenerate).

Worked example

Example 1. Let XX be a r.v. with alphabet and density X={1,2,3,4,5},pX(1)=0.2, pX(2)=α, pX(3)=0.2, pX(4)=β, pX(5)=0.1,\mathcal{X} = \{1,2,3,4,5\}, \quad p_X(1) = 0.2,\ p_X(2) = \alpha,\ p_X(3) = 0.2,\ p_X(4) = \beta,\ p_X(5) = 0.1, and moreover E(X)=2.7E(X) = 2.7. Find (a) P(2<X≤4)P(2 < X \le 4) (as stated on the page; see the note below), (b) E(5−4X)E(5 - 4X), (c) var⁡(X)\operatorname{var}(X), (d) var⁡(7−3X)\operatorname{var}(7-3X).

Solution. (b) and (d) follow immediately from the properties: E(5−4X)=5−4E(X)=5−4⋅2.7  (=−5.8),E(5 - 4X) = 5 - 4E(X) = 5 - 4\cdot2.7 \;(= -5.8), var⁡(7−3X)=var⁡(−3X)=var⁡(3X)=9var⁡(X),\operatorname{var}(7 - 3X) = \operatorname{var}(-3X) = \operatorname{var}(3X) = 9\operatorname{var}(X), (property 4 removes the shift 77, property 3 gives (−3)2=9(-3)^2 = 9) therefore to solve (d) it is necessary to solve (c).

To solve (a) and (c) it is necessary to find α,β\alpha, \beta. The constraints are ∑xkpX(xk)=1\sum_{x_k}p_X(x_k) = 1 and E(X)=2.7E(X) = 2.7, i.e. {0.2+α+0.2+β+0.1=11⋅0.2+2α+3⋅0.2+4β+5⋅0.1=2.7 ⟹ {α+β=0.52α+4β=1.4 ⟹ {α=0.5−β2(0.5−β)+4β=1.4 ⟹ {α=0.3β=0.2.\begin{cases}0.2 + \alpha + 0.2 + \beta + 0.1 = 1\\ 1\cdot0.2 + 2\alpha + 3\cdot0.2 + 4\beta + 5\cdot0.1 = 2.7\end{cases}\ \Longrightarrow\ \begin{cases}\alpha+\beta = 0.5\\ 2\alpha + 4\beta = 1.4\end{cases}\ \Longrightarrow\ \begin{cases}\alpha = 0.5 - \beta\\ 2(0.5-\beta) + 4\beta = 1.4\end{cases}\ \Longrightarrow\ \begin{cases}\alpha = 0.3\\ \beta = 0.2.\end{cases} The answer to (a) on the page is written as P(2<X≤5)=pX(3)+pX(4)+pX(5)=0.2+0.2+0.1=0.5P(2 < X \le 5) = p_X(3) + p_X(4) + p_X(5) = 0.2 + 0.2 + 0.1 = 0.5.

Note on the page: the statement on the previous page reads P(2<X≤4)P(2 < X \le 4) (upper bound 4) while the computation sums pX(3),pX(4),pX(5)p_X(3), p_X(4), p_X(5), which corresponds to an upper bound of 5. With the upper bound 4 the result would be 0.2+0.2=0.40.2+0.2 = 0.4. The handwriting of the bound is ambiguous; this is flagged rather than guessed.

As for (c), first compute E(X2)E(X^2) with the LOTUS: E(X2)=12⋅0.2+22⋅0.3+32⋅0.2+42⋅0.2+52⋅0.1E(X^2) = 1^2\cdot0.2 + 2^2\cdot0.3 + 3^2\cdot0.2 + 4^2\cdot0.2 + 5^2\cdot0.1 (the page writes the exponent of the third term as 333^3, apparently a slip for 323^2), then var⁡(X)=E(X2)−[E(X)]2\operatorname{var}(X) = E(X^2) - [E(X)]^2. The page stops here; completing the computation: E(X2)=0.2+1.2+1.8+3.2+2.5=8.9E(X^2) = 0.2 + 1.2 + 1.8 + 3.2 + 2.5 = 8.9, so var⁡(X)=8.9−2.72=8.9−7.29=1.61,var⁡(7−3X)=9×1.61=14.49.\operatorname{var}(X) = 8.9 - 2.7^2 = 8.9 - 7.29 = 1.61, \qquad \operatorname{var}(7-3X) = 9\times1.61 = 14.49.

Versione ripasso

Definition. var⁡(X)=∑xk∈X(xk−E(X))2pX(xk)\operatorname{var}(X)=\sum_{x_k\in\mathcal{X}}\big(x_k-E(X)\big)^2p_X(x_k): the spread around E(X)E(X). (The signed deviations sum to 00 and the absolute value is hard to handle, so the square is used.)

Examples: b(p)b(p): var⁡=(0−p)2(1−p)+(1−p)2p=p(1−p)\operatorname{var}=(0-p)^2(1-p)+(1-p)^2p=p(1-p); degenerate: 00; G(p)G(p): 1−pp2\frac{1-p}{p^2}. Two r.v.'s with the same mean (U{18,24,30}\mathcal{U}\{18,24,30\} vs U{23,24,25}\mathcal{U}\{23,24,25\}, both 2424) can have very different variance.

Properties.

  1. var⁡(X)=E((X−E(X))2)\operatorname{var}(X)=E\big((X-E(X))^2\big) (LOTUS).
  2. var⁡(X)≥0\operatorname{var}(X)\ge0; =0=0 iff XX degenerate.
  3. var⁡(aX)=a2var⁡(X)\operatorname{var}(aX)=a^2\operatorname{var}(X); var⁡(−X)=var⁡(X)\operatorname{var}(-X)=\operatorname{var}(X).
  4. var⁡(X+c)=var⁡(X)\operatorname{var}(X+c)=\operatorname{var}(X).
  5. var⁡(X)=E(X2)−[E(X)]2\operatorname{var}(X)=E(X^2)-[E(X)]^2 (expand the square, use linearity).
  • Corollary: E(X2)≥[E(X)]2E(X^2)\ge[E(X)]^2, equality iff degenerate.

Worked example. X={1,…,5}\mathcal{X}=\{1,\dots,5\}, p=(0.2,α,0.2,β,0.1)p=(0.2,\alpha,0.2,\beta,0.1), E(X)=2.7E(X)=2.7: normalisation α+β=0.5\alpha+\beta=0.5 and mean 2α+4β=1.42\alpha+4\beta=1.4 give α=0.3\alpha=0.3, β=0.2\beta=0.2. E(5−4X)=5−4⋅2.7E(5-4X)=5-4\cdot2.7; E(X2)=8.9E(X^2)=8.9, var⁡(X)=8.9−7.29=1.61\operatorname{var}(X)=8.9-7.29=1.61; var⁡(7−3X)=9⋅1.61=14.49\operatorname{var}(7-3X)=9\cdot1.61=14.49. Flag: statement reads P(2<X≤4)P(2<X\le4) but the page sums pX(3)+pX(4)+pX(5)=0.5p_X(3)+p_X(4)+p_X(5)=0.5.

Typical mistakes: forgetting to square the multiplier in var⁡(aX)\operatorname{var}(aX); adding the shift cc to the variance; using E(X2)=[E(X)]2E(X^2)=[E(X)]^2.

Teoria collegata