Menu

Expected Value – Understanding Expected Value in Probability and Its Real-Time Applications in Machine Learning

In the world of probability and statistics, the concept of the expected value plays a pivotal role. Whether we realize it or not, we make decisions based on expected outcomes in our daily lives. But what does this term mean mathematically, and how is it employed in machine learning?

In this Blog post we will learn

  1. What is Expected Value?
  2. How to Calculate the Expected Value?
  3. Examples
    3.1. Simple Dice Roll
    3.2. Lottery Ticket
  4. Applications in Machine Learning
  5. Conclusion

1. What is Expected Value?

In probability theory, the expected value (often denoted as $E[X]$ for a random variable $X$) represents the average or mean value of a random experiment if it were repeated many times. It provides us with a single summary number of a probability distribution, rather than looking at the entire distribution.

2. How to Calculate the Expected Value?

For a discrete random variable $X$, which can take on values $x_1, x_2, … x_n$ with respective probabilities $p_1, p_2, … p_n$:

$ E[X] = \sum_{i=1}^{n} x_i \times p_i $

For continuous random variables, the calculation involves integration over the entire probability density function.

3. Examples

3.1. 1. Simple Dice Roll

Consider a fair six-sided die. What’s the expected value of a roll?

The possible outcomes (values) are: $1, 2, 3, 4, 5,$ and $6$.
Since it’s a fair die, each outcome has a probability of $ \frac{1}{6} $.

$ E[X] = 1(\frac{1}{6}) + 2(\frac{1}{6}) + 3(\frac{1}{6}) + 4(\frac{1}{6}) + 5(\frac{1}{6}) + 6(\frac{1}{6}) = 3.5 $

Thus, even though you can’t roll a 3.5 on a die, the expected value tells us the average outcome over many rolls would be 3.5.

3.2. 2. Lottery Ticket

Suppose you buy a lottery ticket for $5.

There’s a 0.01% chance you’ll win $5000 and a 99.99% chance you’ll win nothing. What’s the expected value of your gain?

$ E[X] = 5000(0.0001) + 0(0.9999) = 0.5 $

The expected value is $0.5.

This means if you play many, many times, on average, you’d expect to gain 50 cents per play (though you’re paying $5 for the

ticket each time, making your expected net loss $4.50 per ticket).

4. Applications in Machine Learning

  1. Loss Functions: In machine learning, especially in supervised learning, we aim to minimize a loss function, which measures the discrepancy between the predicted and true values. The expected value can be seen as an average loss over all possible data points, guiding the optimization process.

  2. Reinforcement Learning: In this domain, agents aim to maximize the expected cumulative reward. The Q-function, for instance, represents the expected value of the total reward an agent can achieve starting from a state and taking an action.

  3. Decision Trees: The expected value is used to decide the best feature to split on by evaluating the expected impurity or information gain of potential splits.

  4. Bayesian Inference: When making predictions using a Bayesian model, we might be interested in the expected value of the posterior distribution as our point prediction.

5. Conclusion

Expected value is a foundational concept in probability and provides a means to summarize a probability distribution in a single number. In machine learning, it serves as a guiding principle in many algorithms and models. By understanding and utilizing the expected value, machine learning practitioners can design better algorithms and make more informed decisions.

Course Preview

Machine Learning A-Z™: Hands-On Python & R In Data Science

Free Sample Videos:

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science