FA17 Lecture 9

From CS2800 wiki

Lecture 9: expectation

  • Reading: [[../handouts/mcs.pdf#page=825|MCS 19.2-19.5]]
  • independent RVs
  • expectation, linearity of expectation, variance
  • review exercises:
    • prove any of the claims in these notes
    • constants are independent of everything
    • no non-constant random variable is independent from itself
    • [math]E(X - E(X)) = 0 [/math]
    • variance of the sum of independent random variables is the sum of the variances

Equivalent definitions of expectation

Last lecture we gave two defintions of expectation.

Definition 1: [math]E(X) := \sum_{s ∈ S} X(s)Pr(\{s\}) [/math]

Definition 2: [math]E(X) := \sum_{x ∈ ℝ} x Pr(X = x) [/math]

Claim: these two definitions are equivalent

Proof: We can group together terms in the first sum having the same value of [math]X [/math]:

[math]\sum_{s ∈ S} X(s) Pr(\{s\}) = \sum_{x ∈ ℝ} \sum_{s \mid X(s) = x} X(s)Pr(\{s\}) [/math]

We then apply the third Kolmogorov axiom, using the fact that the events [math]\{s\} [/math] partition [math](X = x) [/math]:

[math]\cdots = \sum_{x ∈ ℝ} x \sum_{X(s) = x} Pr(\{s\}) = \sum_{x ∈ ℝ} xPr(X = x) [/math]

Aside: the expectation function; function spaces

Note that [math]E [/math] by itself is a function; it takes in random variables and gives back numbers. So the domain of [math]E [/math] is the set of all functions with domain [math]S [/math] and codomain [math]ℝ [/math].

Notation: In general, the set of functions with domain [math]A [/math] and codomain [math]B [/math] is written [math][A → B] [/math].

Therefore, [math]E : [S → ℝ] → ℝ [/math].

Linearity of expectation

Claim: If [math]X [/math], [math]Y [/math] are RVs, then [math]E(X+Y) = E(X) + E(Y) [/math].

Proof: We compute:

[math]\begin{aligned} E(X + Y)

&= \sum_{s} (X+Y)(s)Pr(\{s\}) && \text{by definition of \lt math\gt E
[/math]} \\

&= \sum_{s} (X(s) + Y(s))Pr(\{s\}) && \text{by definition of [math]X+Y
[/math]} \\
&= \sum_{s} X(s)Pr(\{s\}) + \sum_{s} Y(s)Pr(\{s\}) && \text{algebra} \\
&= E(X) + E(Y) && \text{by definition of [math]E
[/math]} \\

\end{aligned} </math>

Fact: If [math]C [/math] is a constant RV with value [math]c [/math] (that is, [math]C(s) = c [/math] for all [math]s [/math]) then [math]E(CX) = cE(X) [/math]

Fact: If [math]C [/math] is a constant RV with value [math]c [/math], then [math]E(C) = c [/math].

Proofs: left as review exercises.

Note: We usually don't make the distinction between the number [math]c [/math] and the random variable [math]C [/math]; so the above are often written [math]E(cX) = cE(X) [/math] and [math]E(c) = c [/math].

Note: The fact that [math]E(X + Y) = E(X)+E(Y) [/math] and [math]E(cX) = cE(X) [/math] are summarized by saying that "expectation is linear".

Independent random variables; expectation of the product.

It is not generally the case that [math]E(XY) = E(X)E(Y) [/math]. For example, imagine a single fair coin flip, and let [math]X [/math] be the indicator variable for the flip being heads. That is, [math]S = \{h,t\} [/math], [math]X(h) = 1 [/math], and [math]X(t) = 0 [/math].

We see [math]E(X) = 1/2 [/math]. Moreover, [math]X\cdot X = X [/math], because [math](X \cdot X)(h) = X(h)X(h) = 1 [/math] and [math](X \cdot X)(t) = X(t)X(t) = 0 [/math].

Thus [math]E(X\cdot X) = E(X) = 1/2 [/math] but [math]E(X)E(X) = 1/4 [/math].

However, we have the following:

Definition: Two random variables [math]X [/math] and [math]Y [/math] are independent if the events [math]X = x [/math] and [math]Y = y [/math] are independent for all [math]x [/math] and [math]y [/math].

Claim: If [math]X [/math] and [math]Y [/math] are independent, then [math]E(XY) = E(X)E(Y) [/math].

Proof: Well,

[math]\begin{aligned} E(X)E(Y)

&= \left(\sum_{x} xPr(X = x)\right)\left(\sum_{y} yPr(Y = y)\right) \\
&= \sum_{x,y} xyPr(X=x)Pr(Y=y) \\
&= \sum_{x,y} xyPr(X=x \cap Y=y) && \text{since \lt math\gt X
[/math] and [math]Y [/math] are independent} \\

&= \sum_{z} \sum_{x,y~with~xy=z} xyPr(X = x \cap Y = y) && \text{grouping terms} \\
&= \sum_{z} z\sum_{x,y~with~xy=z} Pr(X = x \cap Y = y) \\

\end{aligned} </math> Now, the union of the events [math](X = x) \cap (Y = y) [/math] over all [math]x [/math] and [math]y [/math] with [math]xy = z [/math] is just the event [math]XY = z [/math]. Moreover, these are disjoint, so we have [math]\left[\sum_{x,y~with~xy=z} Pr(X = x \cap Y = y)\right] = Pr(XY = z) [/math] Plugging this in gives [math]E(X)E(Y) = \cdots = \sum_z zPr(XY = z) = E(XY) [/math] by defintion.


Variance is a measure of how spread out a distribution is. You might ask "how far are the samples from the mean, on average?". This suggests finding the expectation of the random variable [math]X - E(X) [/math] (this is the RV describing the distance from the expected value). Unfortunately, [math]E(X - E(X)) = 0 [/math] (exercise), because [math]X - E(X) [/math] can be positive or negative. We could imagine taking the absolute value, but it turns out to have nicer properties if we square it instead. This gives the definition of variance:

Definition: For a random variable [math]X [/math], [math]Var(X) = E\left((X - E(X))^2\right) [/math].

If [math]X [/math] is measured in a unit (such as inches) then the variance is measured in units squared (e.g. inches squared). Thus, it is often more useful to work with the square root of the variance, which is called the standard deviation:

Definition: the standard deviation of [math]X [/math] is just [math]\sqrt{Var(X)} [/math].

The following formula for the variance is often easier to compute in practice:

Claim: [math]Var(X) = E(X^2) - (E(X))^2 [/math].

Proof: Note that random variables satisfy the normal rules of arithmetic. For example, [math]X(Y + Z) = XY + XZ [/math]. This is because they are evaluated pointwise. For example, we can show [math]X(Y+Z) = XY + XZ [/math] as follows: [math][X(Y+Z)](s) = (X(s))((Y+Z)(s)) = X(s)(Y(s) + Z(s)) = X(s)Y(s) + X(s)Z(s) = [XY + XZ](s) [/math]

Using this, the proof of the claim is just algebra:

[math]\begin{aligned} Var(X)

&= E((X - E(X))^2) \\
&= E(X^2 - 2XE(X) + E(X)^2) \\
&= E(X^2) - 2E(XE(X)) + E(E(X)^2) && \text{by linearity of expectation} \\
&= E(X^2) - 2E(X)^2 + E(X)^2 && \text{because \lt math\gt E(X)
[/math] and [math]E(X)^2 [/math] are constants} \\

&= E(X^2) - E(X)^2

\end{aligned} </math>