4 Expectation

For a random variable XX, the expectation is Discrete: ๐”ผ[X]=โˆ‘xxpX(x)\text{Discrete: } \mathbb{E}[X]=\sum_xxp_X(x) Continuous: ๐”ผ[X]=โˆซโˆ’โˆžโˆžxfX(x)dx\text{Continuous: } \mathbb{E}[X]=\int_{-\infty}^{\infty}xf_X(x)\:\mathrm{d}x where pX(x)p_X(x) is the probability mass function (PMF) and fX(x)f_X(x) is the probability density function (PDF).

The expectation is the weighted average of all possible outcomes, where the weight is the probability of that outcome happening.

For a function g:โ„โ†’โ„g:\mathbb{R}\rightarrow\mathbb{R}, the expectation of g(X)g(X) is Discrete: ๐”ผ[g(X)]=โˆ‘xg(x)pX(x)\text{Discrete: } \mathbb{E}[g(X)]=\sum_xg(x)p_X(x) Continuous: ๐”ผ[g(X)]=โˆซโˆ’โˆžโˆžg(x)fX(x)dx\text{Continuous: } \mathbb{E}[g(X)]=\int_{-\infty}^{\infty}g(x)f_X(x)\:\mathrm{d}x Example XX is the outcome of a fair coin flip, X(H)=1X(H)=1, X(T)=0X(T)=0.
For a function g(X)=(X+2)2g(X)=(X+2)^2, g(1)=9g(1)=9, g(0)=4g(0)=4.
Then ๐”ผ[g(X)]=(9ร—0.5)+(4ร—0.5)=6.5\mathbb{E}[g(X)]=(9\times0.5) + (4\times0.5)=6.5.

Properties For a constant cc, we have that

  1. ๐”ผ[c]=c\mathbb{E}[c]=c
    โˆต๐”ผ[c]=โˆ‘xcโ‹…pX(x)=cโ‹…โˆ‘xpX(x)=cโ‹…1=c\because \mathbb{E}[c]=\sum_xc\cdot p_X(x)=c\cdot \sum_xp_X(x)=c \cdot 1=c

  2. ๐”ผ[X+c]=๐”ผ[X]+c\mathbb{E}[X+c]=\mathbb{E}[X]+c
    โˆต๐”ผ[X+c]=โˆ‘x(x+c)pX(x)=โˆ‘x(xpX(x))+c(pX(x))=๐”ผ[X]+cโ‹…1=๐”ผ[X]+c\because \mathbb{E}[X+c]=\sum_x(x+c)p_X(x)=\sum_x(xp_X(x))+c(p_X(x))=\mathbb{E}[X]+c\cdot 1=\mathbb{E}[X]+c

  3. ๐”ผ[cX]=c๐”ผ[X]\mathbb{E}[cX]=c\mathbb{E}[X]
    โˆต๐”ผ[cX]=โˆ‘x(cx)pX(x)=cโ‹…โˆ‘xxpX(x)=cโ‹…๐”ผ[X]\because \mathbb{E}[cX]=\sum_x(cx)p_X(x)=c\cdot \sum_xxp_X(x)=c\cdot \mathbb{E}[X]

Multivariate expectation

For multiple random variables X,YX,Y and a function g:โ„2โ†’โ„g:\mathbb{R}^2\rightarrow\mathbb{R}, the expectation is Discrete: ๐”ผ[g(X,Y)]=โˆ‘x,yg(x,y)pX,Y(x,y)\text{Discrete: }\mathbb{E}[g(X, Y)]=\sum_{x, y}g(x, y)p_{X, Y}(x, y) Continuous: ๐”ผ[g(X,Y)]=โˆซโˆ’โˆžโˆžโˆซโˆ’โˆžโˆžg(x,y)fX,Y(x,y)dxdy\text{Continuous: }\mathbb{E}[g(X, Y)] = \int_{-\infty}^{\infty}\int_{-\infty}^{\infty}g(x, y)f_{X, Y}(x, y)\:\mathrm{d}x\:\mathrm{d}y

Similarly, for constants c1c_1, c2c_2,
๐”ผ[c1X+c2Y]=c1๐”ผ[X]+c2๐”ผ[Y]\mathbb{E}[c_1X+c_2Y] = c_1\mathbb{E}[X] + c_2\mathbb{E}[Y] โˆต๐”ผ[c1X+c2Y]=โˆ‘xโˆ‘y(c1x+c2y)โ‹…pX,Y(x,y)=โˆ‘xโˆ‘yc1xโ‹…pX,Y(x,y)+โˆ‘xโˆ‘yc2yโ‹…pX,Y(x,y)=โˆ‘xc1x(โˆ‘ypX,y(x,y))+โˆ‘yc2y(โˆ‘xpX,Y(x,y))=โˆ‘xc1xโ‹…pX(x)+โˆ‘yc2yโ‹…pY(y)=c1โˆ‘xxpX(x)+c2โˆ‘yypY(y)=c1๐”ผ[X]+c2๐”ผ[Y]\begin{align*} \because \mathbb{E}[c_1X+c_2Y] &= \sum_x\sum_y(c_1x + c_2y)\cdot p_{X,Y}(x,y) \\ &= \sum_x\sum_yc_1x\cdot p_{X,Y}(x,y) + \sum_x\sum_yc_2y\cdot p_{X,Y}(x,y) \\ &= \sum_xc_1x(\sum_yp_{X,y}(x,y)) + \sum_yc_2y(\sum_xp_{X,Y}(x,y)) \\ &= \sum_xc_1x\cdot p_X(x) + \sum_yc_2y\cdot p_Y(y) \\ &= c_1\sum_xxp_X(x) + c_2\sum_yyp_Y(y) \\ &= c_1\mathbb{E}[X] + c_2\mathbb{E}[Y] \end{align*}

Linearity of expectation For any two random variables XX and YY, ๐”ผ[X+Y]=๐”ผ[X]+๐”ผ[Y]\mathbb{E}[X+Y] = \mathbb{E}[X] + \mathbb{E}[Y] This rule holds true regardless of whether XX and YY are independent or completely dependent. Dependency affects variance, but it never breaks the linearity of expectation.

  1. Independent scenario: flip two fair coins, let X=1X=1 if Coin 1 = H, let Y=1Y=1 if Coin 2 = H.
    ๐”ผ[X]=0.5\mathbb{E}[X] = 0.5 and ๐”ผ[Y]=0.5\mathbb{E}[Y] = 0.5.
    ๐”ผ[X+Y]=(0ร—0.25)+(1ร—0.50)+(2ร—0.25)=1\mathbb{E}[X+Y] = (0 \times 0.25) + (1 \times 0.50) + (2 \times 0.25) = 1.

  2. Dependent scenario: Flip one fair coin, but count its result twice. Let X=1X = 1 if the coin is Heads, and let Y=XY = X.
    ๐”ผ[X]=0.5\mathbb{E}[X] = 0.5 and ๐”ผ[Y]=0.5\mathbb{E}[Y] = 0.5.
    ๐”ผ[X+Y]=(0ร—0.50)+(2ร—0.50)=1\mathbb{E}[X+Y] = (0 \times 0.50) + (2 \times 0.50) = 1.