Generic definition
$X$ random variable defined on $(\Omega, \mathcal{F} ,\mathbb{P})$:
\[\mathbb{E}[X] = \int_{\Omega} X(\omega) d\mathbb{P}(\omega)\]Using measure theory results, we find the specific cases for discrete and continuous variables.
Discrete variables:
\[\mathbb{E}[X] = \Sigma_i x_i \mathbb{P}(X=x_i)~(= \mathbb{E}_{\mathbb{P}}[X])\]Continuous variables:
\[\mathbb{E}[X] = \int_\mathbb{R} x f(x) dx~(= \mathbb{E}_{\mathbb{P}}[X])\]Conditional expectation (discrete case):
\[\mathbb{E}[Y|X=x] = \Sigma_y y \mathbb{P}(Y=y | X=x)\]It can also be written as a linear regression:
\[\mathbb{E}[Y|X=x] = \beta_0 + \beta_1 X\]