Intuition

Main idea: Expected value is the theoretical average of outcomes of a random variable. Expected value does not determine anything itself, but rather describes a model’s long-term tendency towards a value. In short, it is just an expectation.

For example, if we were modeling the number of heads in n coin tosses, we would expect n/2 heads. Obviously this does not mean that we will obtain n/2 heads, but over a large number of trials, we can expect a value that approximates it. The following slides shows code in R, a statistical programming language, that models coin flipping along with a graph of the results from hundred random trials with a line depicting expected value.

100 Coin Flips

library(ggplot2)

set.seed(123)

tosses <- sample(c("Heads", "Tails"), size = 100, replace = TRUE)

coin_data <- data.frame(
  num_tosses = 1:100,
  num_heads = cumsum(tosses == "Heads")
)

ggplot(coin_data, aes(x = num_tosses, y = num_heads)) +
  geom_line() +
  geom_point() +
  geom_abline(intercept = 0, slope = 0.5, linetype = "dashed") +
  labs(title = "Cumulative Number of Heads in 100 Coin Tosses",
       x = "Number of Coin Tosses",
       y = "Number of Heads")

We used the concept of expected value when describing a real life event, but the concept can be extended to describe functions as well. The next slide shows the mathematical definition of expected value in the context of discrete random variables.

If \(X\) is a discrete random variable with possible values

\[ x_1, x_2, \dots, x_n \]

and probabilities

\[ P(X=x_1), P(X=x_2), \dots, P(X=x_n), \]

then the expected value of \(X\) is

\[ E[X] = \sum_{i=1}^{n} x_i P(X=x_i) \]

Interpretation:

\[ \text{Expected value} = \text{weighted average of possible outcomes} \]

Binomial Distribution Example

Here is an example of a discrete distribution known as a binomial distribution. A binomial distribution describes the number of occurrences of an event with only two possible outcomes (most of the times, whether something happens or not) in a sequence of independent trials.

Suppose a basketball player takes \(10\) free throws.
Each free throw has a probability of success \(p = 0.70\).

Let \(X\) be the number of made free throws.

\[ X \sim \text{Binomial}(n = 10, p = 0.70) \]

This means:

  • There are \(10\) independent trials.
  • Each trial has two outcomes: make or miss.
  • The probability of making a shot is \(0.70\).
  • We are interested in the number of made shots.

Interpretation

We see that the expected value for this binomial distribution is \(np\), which in this case is

\[ E[X] = np = 10(0.7) = 7. \] That is also the most frequent value as commonly seen in other distributions.

Expected Value: Continuous Version

\[ E[X] = \int_{-\infty}^{\infty} x f(x)\,dx \]

Continuous Expected Value Example

Suppose \(X\) has probability density function

\[ f(x) = 2x, \qquad 0 \leq x \leq 1. \]

The expected value is

\[ E[X] = \int_0^1 x f(x)\,dx. \]

Calculation

expected_value <- integrate(function(x) x * 2*x,
                            lower = 0,
                            upper = 1)

expected_value$value
## [1] 0.6666667

So,

\[ E[X] = \int_0^1 x(2x)\,dx = \int_0^1 2x^2\,dx = \frac{2}{3}. \]

Graph of the Density

Interpretation

The expected value is

\[ E[X] = \frac{2}{3}. \]

Since the density \(f(x)=2x\) is larger near \(x=1\), outcomes closer to \(1\) are more likely.