You have not studied for a 200 question multiple choice test, so you guess option D on every question. How many will you get right? You do not need to sit the test to know. Each question has a one in four chance, so you expect 50 right answers. That number is an expected value.
Expected value is one of the most useful ideas in probability. It lets you weigh outcomes by how likely they are, and give a single answer to the question: what should I expect on average? Insurers use it to set prices, businesses use it to compare projects, and data scientists use it to build models and judge them.
This tutorial explains what expected value is, the general formula, two worked examples with the answers, how it is used to make decisions, its main properties, and how to calculate it in Python. If you want to read about random variables and probability density first, you can use the links at the end.
The expected value of a random variable is its theoretical mean: the long run average of the results if you repeated the experiment again and again. It is written E(X).
Think of it as the return you can expect from an action. Some outcomes give more and some give less, and the expected value weighs each by how likely it is.

For a discrete random variable that takes the values x1, x2 up to xk with probabilities p1, p2 up to pk:
In words: multiply each value by its probability, and add them up.
The probabilities must add up to 1. The expected value is then a weighted average, where the weights are the probabilities.
If each question has the same chance P of being right, and there are n questions, the number of right answers is a binomial variable, and its expected value is:
This is the formula that the live page shows. It is a special case of the general formula, and it only works for a count of identical trials.
The expected value tells you the centre, and the variance tells you the spread: Var(X) = E(X squared) minus (E(X)) squared.
The live page: a test has 200 questions with options A, B, C and D, and you guess D on all of them. What is the expected number of correct answers?
The live page uses n = 200 in the working, but one line says 20. With 20 questions, the expected number is 5. The right number is 50 for 200 questions.
How far can a guesser stray from 50? The standard deviation is 6.12, so most guessers score between about 38 and 62. The chance of scoring 60 or more by pure guessing is 0.0625.
Many exams take away marks for wrong answers, to remove the benefit of guessing. With plus 4 for a right answer and minus 1 for a wrong one, each guess is worth 0.25 times 4 + 0.75 times (minus 1) = 0.25 marks, so 200 guesses give 50 marks. With plus 1 for right and minus one third for wrong, a guess is worth exactly 0, so guessing has no expected gain. That is why this scheme is used.
The live page: a stack has 10 cards. One is labelled 1, two are labelled 2, three are labelled 3 and four are labelled 4. You draw one at random. Let X be the value on the card. Find the expected value.
| Value x | Cards | P(X = x) | x times P(X = x) |
|---|---|---|---|
| 1 | 1 | 0.1 | 0.1 |
| 2 | 2 | 0.2 | 0.4 |
| 3 | 3 | 0.3 | 0.9 |
| 4 | 4 | 0.4 | 1.6 |
| Total | 10 | 1.0 | 3.0 |

Meaning: the average value over many draws is 3. A simulation of 100,000 draws gave 3.001. The value 3 can be drawn, but this is chance, since the expected value does not have to be a possible value.
For the variance: E(X squared) = 1 times 0.1 + 4 times 0.2 + 9 times 0.3 + 16 times 0.4 = 10, so Var(X) = 10 minus 3 squared = 1.
A game costs you 2 rupees to roll a die. If you roll a six, you win 12 rupees. Otherwise you win nothing, so you lose the 2 rupees. The numbers are made up.
| Outcome | Probability | Gain |
|---|---|---|
| Six | 1 of 6 | Plus 12 |
| Not six | 5 of 6 | Minus 2 |
Expected gain = 12 times (1 divided by 6) + (minus 2) times (5 divided by 6) = 2 minus 1.667 = 0.333 rupees per game. The game favours you slightly. In my simulation of 100,000 games, the average gain was 0.306, close to 0.333.
| Property | Meaning |
|---|---|
| E(aX + b) = a E(X) + b | Scaling and shifting a variable scales and shifts its mean |
| E(X + Y) = E(X) + E(Y) | The mean of a sum is the sum of the means, even if X and Y are dependent |
I checked both. For the card variable, E(X) = 3, so E(2X + 5) = 11. A simulation gave 11.006. Adding a die with a mean of 3.5, the mean of the sum is 6.5, and the simulation gave 6.5.
The second property is called linearity of expectation. It is the reason why the binomial mean is n times p: a binomial count is the sum of n trials, each with a mean of p.
I ran the code below, and the output is real.
| Mistake | Fix |
|---|---|
| Using the wrong n in P times n | Use the number of questions in the test, and check it throughout |
| Treating the expected value as the most likely value | It is a long run average |
| Thinking it must be a possible outcome | A die has an expected value of 3.5 |
| Forgetting that probabilities must add to 1 | Check the total |
| Using the simple average of the values | Weight each value by its probability |
| Ignoring negative payoffs | Losses count as negative values |
| Using the guessing formula for non identical trials | Use the general formula |
| Spelling it Expect Value | It is Expected Value |
Answers: 1) P = 0.2, so 0.2 times 80 = 16. 2) (1 + 2 + 3 + 4 + 5 + 6) divided by 6 = 3.5. 3) 5 times 0.2 = 1 rupee. 4) 3 times 4 + 2 = 14. These are my own answers, so please recheck them before publishing.
Expected value turns uncertainty into one honest number: the average you should plan for. Multiply each outcome by its chance, add them up, and remember that it is a long run average, not a promise for the next trial.