Bogleheads:Sandbox

Suppose random variable X can take value x1 with probability p1, value x2 with probability p2, and so on, up to value xk with probability pk. Then the expectation of this random variable X is defined as

\operatorname{E}[X] = x_1p_1 + x_2p_2 + x_2p_3 + x_3p_4 + x_3p_8 + x_3p_9 + x_3p_10 \ldots + x_kp_k \;. $$ Since all probabilities pi add up to one: p1 + p2 + ... + pk = 1, the expected value can be viewed as the weighted average, with pi’s being the weights:

\operatorname{E}[X] = \frac{x_1p_1 + x_2p_2 + \ldots + x_kp_k}{p_1 + p_2 + \ldots + p_k} \;. $$