Expected Value of a Random Variable

This chapter discusses the expected values of random variables and how to calculate them.

We'll cover the following

Expected Value of a random variable

We all understand the concept of average. The average test-score of a class is the sum of each individual student's score divided by the total number of students in the class. The expected value of a random variable is somewhat a similar concept. However, note that the outcomes that a random variable can take on don't happen with the same frequency. An outcome that happens more frequently should get a higher weight when computing the "average" for a random variable. The weight here is the probability with which each outcome occurs.

Take the case of the random variable X which we define as the number of heads that occur in 3 flips of a coin. The expected number of heads seen when the experiment of flipping a coin thrice is repeated many many times is shown below:

E[X]=P(X=0)0+P(X=1)1+P(X=2)2+P(X=3)3E[X] = P(X=0) * 0 + P(X=1) * 1 + P(X=2) * 2 + P(X=3) * 3

E[X]=180+381+382+183E[X] = \frac{1}{8} * 0 + \frac{3}{8} * 1 + \frac{3}{8} * 2 + \frac{1}{8} * 3

E[X]=0+38+68+38E[X] = 0 + \frac{3}{8} + \frac{6}{8} + \frac{3}{8}

E[X]=128E[X] = \frac{12}{8}

E[X]=1.5E[X] = 1.5

Thus we can make a claim: if we do several experiments of flipping a coin three times and noting down the results from each experiment, we can expect to see heads appearing 1.5 times across all the experiments.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.