Definition 3.8.4 (Probability measure). A probability space is a set $S$, a collection of subsets $A\in S$, and a function $P:A\to [0,1]$ satisfying some axioms.
Definition 3.8.5 (Random variable). A random variable is a function $S\to \R$. The vector space of random variables is denoted as $RV(S)$.
When the sample space is finite: $S = \{s_1, \dots, s_m\}$, then the space of random variables on $S$ is simply $\R^m$, with $f\in RV(S)$. This is because $f$ has $m$ inputs: $f(s_1), \dots, f(s_m)$. A smart way to map $RV(S)$ to $\R^m$ is
$$ \Phi:RV(S)\to \R^m:f\mapsto \begin{bmatrix}f(s_1)\sqrt{P(\{s_1\})}\\ \vdots \\ f(s_m)\sqrt{P(\{s_m\})} \end{bmatrix}. $$
When $S$ is finite, we define the inner product as
$$ <f,g> = \sum_{s\in S}f(s) g(s)P(\{s\}). $$
Generally,
$$ <f,g>_{S,P} = \Phi(f)\cdot \Phi(g). $$
For continuous probability spaces,the inner product is
$$ <f,g> = \int_{\R^n}f(x)g(x)\mu(x)|d^nx|. $$
Definition 3.8.6 With this definition of inner product, we can easily define several terms.
Expected value. The expected value is the "average/most likely event". Note that the integrand must have bounded support.
$$ E(f) = <f,1_S>\\ = \int_{\R^n}f(x)1_S\mu(x)|d^nx|. $$