Menu

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

Written by Jagdeesh | 3 min read

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.

Free Course
Master Core Python โ€” Your First Step into AI/ML

Build a strong Python foundation with hands-on exercises designed for aspiring Data Scientists and AI/ML Engineers.

Start Free Course
Trusted by 50,000+ learners
Jagdeesh
Written by
Related Course
Master Probability โ€” Hands-On
Join 5,000+ students at edu.machinelearningplus.com
Explore Course
Get the full course,
completely free.
Join 57,000+ students learning Python, SQL & ML. One year of access, all resources included.
๐Ÿ“š 10 Courses
๐Ÿ Python & ML
๐Ÿ—„๏ธ SQL
๐Ÿ“ฆ Downloads
๐Ÿ“… 1 Year Access
No thanks
๐ŸŽ“
Free AI/ML Starter Kit
Python ยท SQL ยท ML ยท 10 Courses ยท 57,000+ students
๐ŸŽ‰   You're in! Check your inbox (or Promotions/Spam) for the access link.
โšก Before you go

Python.
SQL. NumPy.
All free.

Get the exact 10-course programming foundation that Data Science professionals use.

๐Ÿ
Core Python โ€” from first line to expert level
๐Ÿ“ˆ
NumPy & Pandas โ€” the #1 libraries every DS job needs
๐Ÿ—ƒ๏ธ
SQL Levels Iโ€“III โ€” basics to Window Functions
๐Ÿ“„
Real industry data โ€” Jupyter notebooks included
R A M S K
57,000+ students
โ˜…โ˜…โ˜…โ˜…โ˜… Rated 4.9/5
โšก Before you go
Python. SQL.
All Free.
R A M S K
57,000+ students  โ˜…โ˜…โ˜…โ˜…โ˜… 4.9/5
Get Free Access Now
10 courses. Real projects. Zero cost. No credit card.
New learners enrolling right now
๐Ÿ”’ 100% free โ˜• No spam, ever โœ“ Instant access
๐Ÿš€
You're in!
Check your inbox for your access link.
(Check Promotions or Spam if you don't see it)
Or start your first course right now:
Start Free Course โ†’
Scroll to Top
Scroll to Top
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