Instead of stating the mathematical definition of expected values upfront, let's go through a motivating example first to develop our intuition.
Motivating example
Suppose we have an unfair coin with the following probability of heads and tails:
Now, suppose we play a game where we get dollars per heads and dollars per tails. Whether we get a heads or tails is random, so we can use random variable to denote the profit of a single toss. The probability mass function of , denoted as , is as follows:
Outcome |
|
|
---|
Heads |
|
|
Tails |
|
|
This table states that for a single toss:
Note that represents a specific value that a random variable could take on.
Now, the key question we wish to answer is:
If we toss the coin times, how much do we expect to profit?
To answer this question, we should first find out how many heads and tails we expect from tosses. Intuitively, since the probability of heads is , we should expect the outcome to be heads and tails. Mathematically, we are performing the following calculations:
Keep in mind that these are only the expected outcome since the outcome is random. Because we profit dollars for each heads and dollars for each tails, we can easily calculate the expected profit from heads and the expected profit from tails:
The sum of the expected profits from heads and tails gives us the total expected profit:
Therefore, if we were to toss the coin times, then our expected profit is dollars! We can generalize the above calculations as follows:
Now, instead of tossing the coin times, let's calculate the expected profit from a single coin toss, that is, . Plugging in in the above formula gives:
Recall that the random variable represents the profit of a single trial. We can mathematically denote the expected value of as , which in this case means:
Moreover, notice how the right-hand side of can be written as:
Here, the summation symbol means that we are summing over all possible values of .
Therefore, using and , we can express generally as:
For our example, we know that and , so the expected profit for a single toss is:
Therefore, we should expect to profit dollars per toss on average! Note that this does not mean that we get dollars per toss - in fact, that's impossible because we either get or dollars per toss. An expected profit of dollars per toss means that if we were to toss the coin a large number of times, the average profit we make per toss is dollars.
Simulation to demonstrate expected values
Let's run a quick simulation to demonstrate this. Suppose we toss the coin times - the simulated outcome is as follows:
As expected, we get around heads () and tails (). Below is a graph showing the running average of the profit per toss:
We can see that the average profit per toss fluctuates a lot in the beginning. However, as we keep tossing the coin, the average profit per toss stabilizes to the theoretical expected value of that we calculated earlier! The more tosses we make, the closer the average profit per toss will be to .
In this example, the random variable represents the profit from a single toss and so represents the expected profit from a toss. Of course, does not have to represent profit - it could for instance represent waiting time, in which case would represent the expected waiting time.
We now state the formal definition of the expected value of random variables.
Definition.
Expected value of a random discrete variable
Let be a discrete random variable with probability mass function . The expected value of is defined as follows:
In words, the expected value involves summing the products of all possible values of the random variable and their respective probability. Intuitively, the expected value of is a number that tells us the average value of we expect to see when we perform a large number of independent repetitions of an experiment.
Note that is sometimes denoted as .
Example.
Expected profit from a lottery
Consider a lottery game where the cost of a single ticket is dollars. Let the random variable denote the lottery prize. The following table describes the three possible outcomes and their corresponding probabilities:
Compute and interpret the expected value of .
Solution. By definition, the expected value of is:
This means that we should expect to win dollars per lottery game. However, since the cost of a single lottery ticket is dollars, we will lose dollars per game on average. If we play games, then we should expect to lose a total of dollars.
■
Example.
Expected waiting time for food
The waiting time (in minutes) for food delivery is represented by the random variable . The probability mass function of is:
On average, how long do we have to wait to get our food?
Solution. Let random variable be the waiting time for the food to arrive. The expected value of is:
Therefore, on average, we must wait 23 minutes for our food!
■
Example.
Expected value of a symmetric distribution
Suppose we have a probability mass function like so:
This is visualized below:
When we have symmetric distributions like this, we can find the expected value without having to calculate it. We know that the expected value is the mean value that a random variable takes in the long run. For a symmetric distribution, the mean is at the center, which means .
Example.
Expected value of rolling a dice
Suppose we roll a fair dice once. Let the random variable denote the face of the rolled dice. What is the expected value of ?
Solution. Since we have a fair dice, the probability mass function of is:
|
|
|
|
|
|
|
---|
|
|
|
|
|
|
|
---|
The expected value of is:
One way of interpreting this is to think of as points - for instance, if we roll a , we get points. On average, we would get points per roll.
As a side note, notice that is a symmetric probability distribution. We know from earlier that the expected value of a symmetric distribution is the mean value of , that is:
This way of computing the expected value is convenient because we don't have to deal with probabilities - we simply compute the average of all possible values!
■
We will now discuss the expected values of continuous random variables. The underlying intuition is the same as that for the discrete case - the main difference is that instead of summing over all possible values of a random variable, we integrate over them!
Definition.
Expected value of a continuous random variable
Let be a continuous random variable with probability density function . The expected value of is defined as follows:
Note the following:
this definition holds only if the integral exists.
the bounds of the integral are typically written as and for the formal definition of expected values. In practice, we use the bounds of instead.
Example.
Computing the expected value of a continuous random variable (1)
Suppose random variable has the following probability density function:
Compute the expected value of .
Solution. By definition, the expected value of is:
Therefore, if we repeatedly sample from this distribution a large number of times, the average value that will take on is .
■
Example.
Computing the expected value of a continuous random variable (2)
Suppose random variable has the following probability density function:
Compute .
Solution. By definition, the expected value of is:
Therefore, the average value that takes on in the long run is .
Just as in the discrete case, we don't have to rely on the formula to compute the expected value when the distribution is symmetric. The probability density function of in this case is symmetric:
Because represents the average value that takes on upon repeated sampling, we have that must be at the center when the distribution of is symmetric. Therefore, we can easily conclude that in this case.
■
In the next section, we will go over the mathematical properties of expected value of random variables.