> For the complete documentation index, see [llms.txt](https://cs70.bencuan.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cs70.bencuan.me/probability/expectation-and-variance.md).

# Expectation and Variance

The expectation of a random variable, $$E(X)$$, is the average of possible values weighted by their probabilities. Formally, it can be defined in two ways:

1. Domain definition: $$E(X) = \sum\_{\omega \in \Omega} X(\omega) P(\omega)$$.
2. Range definition: $$E(X) = \sum\_x x P(X = x)$$.

Expectation has nice properties of linearity: $$E(X + Y) = E(X) + E(Y)$$ and $$E(aX + b) = aE(x) + b$$.

<http://prob140.org/textbook/content/Chapter_08/01_Definition.html>
