One natural question to ask about a probability distribution is, "What is its center?" The expected value is one such measurement of the center of a probability distribution. Since it measures the mean, it should come as no surprise that this formula is derived from that of the mean.

To establish a starting point, we must answer the question, "What is the expected value?" Suppose that we have a random variable associated with a probability experiment. Let's say that we repeat this experiment over and over again. Over the long run of several repetitions of the same probability experiment, if we averaged out all of our values of the random variable, we would obtain the expected value.

In what follows we will see how to use the formula for expected value. We will look at both the discrete and continuous settings and see the similarities and differences in the formulas.

### The Formula for a Discrete Random Variable

We start by analyzing the discrete case. Given a discrete random variable *X*, suppose that it has values *x*_{1}, *x*_{2}, *x*_{3}, . . . *x*_{n}, and respective probabilities of *p*_{1}, *p*_{2}, *p*_{3}, . . . *p*_{n}. This is saying that the probability mass function for this random variable gives *f*(*x*_{i}) = *p*_{i}.

The expected value of *X* is given by the formula:

E(*X*) = *x*_{1}*p*_{1} + *x*_{2}*p*_{2} + *x*_{3}*p*_{3} + . . . + *x*_{n}*p*_{n}.

Using the probability mass function and summation notation allows us to more compactly write this formula as follows, where the summation is taken over the index *i*:

E(*X*) = Σ *x*_{i}*f*(*x*_{i}).

This version of the formula is helpful to see because it also works when we have an infinite sample space. This formula can also easily be adjusted for the continuous case.

### An Example

Flip a coin three times and let *X* be the number of heads. The random variable *X *is discrete and finite. The only possible values that we can have are 0, 1, 2 and 3. This has probability distribution of 1/8 for *X* = 0, 3/8 for *X* = 1, 3/8 for *X* = 2, 1/8 for *X* = 3. Use the expected value formula to obtain:

(1/8)0 + (3/8)1 + (3/8)2 + (1/8)3 = 12/8 = 1.5

In this example, we see that, in the long run, we will average a total of 1.5 heads from this experiment. This makes sense with our intuition as one-half of 3 is 1.5.

### The Formula for a Continuous Random Variable

We now turn to a continuous random variable, which we will denote by *X*. We will let the probability density function of *X *be given by the function *f*(*x*).

The expected value of *X* is given by the formula:

E(*X*) = ∫ *x f*(*x*) d*x.*

Here we see that the expected value of our random variable is expressed as an integral.

### Applications of Expected Value

There are many applications for the expected value of a random variable. This formula makes an interesting appearance in the St. Petersburg Paradox.