# Expectation

The average value of a function evaluated over every possible outcome of a random number or numbers.

For example, for a function \(f\) and a discrete random variable with a set of possible outcomes \(X\) it is given by

For a continuous random variable with a set of values \(X\), it is given by the integral

For example, for a function \(f\) and a discrete random variable with a set of possible outcomes \(X\) it is given by

\[
\mathrm{E}\left[f(X)\right] = \sum_{x \in X} p(x) \times f(x)
\]

where \(p(x)\) is the probability of observing \(x\), \(\sum\) is the summation sign and \(\in\) means *within*.For a continuous random variable with a set of values \(X\), it is given by the integral

\[
\mathrm{E}\left[f(X)\right] = \int_{x \in X} p(x) \times f(x) \mathrm{d}x
\]

where \(p(x)\) is the probability density function.