# Section 4

The **Expected Value** (or *expectation, mean*) of a random variable can be thought of as the "weighted average" of the possible outcomes of the random variable. Mathematically, if $$x\_1, x\_2, x\_3,\cdots$$, are all of the possible values that *X* can take, the expected value of *X* can be calculated as follows:

$$
E(X | A) = \sum\limits\_{i}x\_iP(X=x\_i | A)
$$

**Linearity of Expectation**

The most important property of expected value is **Linearity of Expectation**. For **any** two random variables *X* and *Y*, *a* and *b* scaling coefficients and *c* is our constant, the following property of holds:

$$E(aX + bY + c) = aE(X) + bE(Y) + c$$

The above is true regardless of whether *X* and *Y* are independent.

## Conditional Expectations

Conditional distributions are still distributions. Treating them as a whole and applying the definition of expectation gives:

$$
E(X | A) = \sum\limits\_{i}x\_iP(X=x\_i | A)
$$

## Variance

**Variance** tells us how spread out the distribution of a random variable is. It is defined as

$$
Var(X) = E(X - E(X))^2 = E(X^2) - (E(X))^2
$$

**Properties of Variance**

* $$Var(cX) = c^2 Var(X)$$
* $$Var(X \pm Y) = Var(X) + Var(Y)$$ if $$X$$ and $$Y$$ are independent

## Indicator Random Variables

Indicator Random Variables are random variables whose value is 1 when a particular event happens, or 0 when it does not. Let $$I\_A$$ be an indicator random variable for the event $$A$$. Then, we have:

$$$
I\_A = \begin{cases}
1 & \text{$$A$$ occurs} \\
0 & \text{$$A$$ does not occur}
\end{cases}
$$$

Suppose $$P(A) = p$$. Then, $$I \sim Bern(p)$$ because $$I$$ has a $$p$$ chance of being 1, and a $$1-p$$ chance of being 0.

**Properties of Indicators**

* $$(I\_A)^2 = I\_A$$, and $$(I\_A)^k = I\_A$$ for any power $$k$$.
* $$I\_{A^c} = 1 - I\_A$$
* $$I\_{A \cap B} = I\_A I\_B$$ is the indicator for the event $$A \cap B$$ (that is, $$I\_A I\_B = 1$$ if and only if $$A$$ and $$B$$ occur, and 0 otherwise)&#x20;
* $$I\_{A \cup B} = I\_A + I\_B - I\_A I\_B$$

## The Fundamental Bridge

The **fundamental bridge** is the idea that $$E(I\_A) = P(A)$$. When we want to calculate the expected value of a complicated event, sometimes we can break it down into many indicator random variables, and then apply linearity of expectation on that. For example, if $$X = I\_1 + I\_2 + \ldots + I\_n$$, then:

$$
E(X) = E(I\_1) + E(I\_2) + \ldots + E(I\_n) = P(I\_1) + P(I\_2) + \ldots + P(I\_n)
$$
