A survey asks 5,000 randomly chosen students whether they study Mathematics, and in the whole student population, 40 percent do. How many Mathematics students do you expect in your sample? Your gut says 2,000, and your gut is right. That answer is the expected value of a binomial distribution, and it comes from one short formula.
The expected value is the long run average, the number you would get on average if you could repeat the survey again and again. It sits at the centre of the binomial distribution, and it is the first number analysts compute for any count of successes: orders that ship on time, clicks on an email, defective parts in a batch.
This tutorial explains the binomial distribution and its conditions, the expected value formula E(X) = np, why it works, the variance, three worked examples with corrected answers, and how to check them in Python.
The binomial distribution gives the probability of each possible number of successes in a fixed number of independent trials. Each trial has two outcomes, success or failure, and the chance of success is the same every time.
The live page describes it as the probability of success and failure outcome in an experiment that is repeated multiple times. That misses the two conditions that matter: a fixed number of trials, and independence with a constant chance of success.
The expected value of a random variable is its theoretical mean: each possible value, weighted by its probability, added up. It is the long run average. It does not have to be a value that X can actually take. For 5 tosses of a fair coin, the expected number of heads is 2.5, which is impossible in a single experiment.

The live page: a test has 100 true or false questions, and a student marks all of them TRUE. The page says that at least 20 should be TRUE, and calls 20 the expected value. It shows no working. The right way to read it depends on the answer key.
| Answer key | p (chance a key answer is TRUE) | Expected correct answers, 100 times p |
|---|---|---|
| Random key, TRUE and FALSE equally likely | 0.5 | 50 |
| Key with about 20 TRUE answers | 0.2 | 20 |
So 20 is the expected value only if the key has TRUE answers about 20 percent of the time. For a random key, the student expects 50. The first has a standard deviation of 5, and the second has 4. Be careful with the word at least: the expected value is an average, not a minimum.

The live page: two parties contest 48 seats, and Party A predicts 20. It calls 20 the expected value, but gives no n and no p. A prediction is not a calculation.
Here is a version with a calculation. Suppose that Party A has a chance of 20 divided by 48 = 0.4167 in each of the 48 seats, and the seats are independent. Then n = 48, p = 0.4167, and the expected number of seats is 48 times 0.4167 = 20. The variance is 48 times 0.4167 times 0.5833 = 11.67, and the standard deviation is 3.42, so a result between about 13 and 27 seats would not be a surprise.
Caution: real seats are not independent, since a national wave lifts many seats at once. So the real spread is wider than a binomial says. It is a useful teaching model, but not a forecasting model.
A binomial count is the sum of n separate Bernoulli trials, each worth 1 for a success and 0 for a failure. The expected value of one Bernoulli trial is p. The expected value of a sum is the sum of the expected values, so n trials give n times p.
Variance = n times p times (1 minus p). Standard deviation = the square root of that. The live page does not give them, but you need them to say how far from np a result may be.
| n | p | Mean np | Variance np(1 minus p) |
|---|---|---|---|
| 10 | 0.5 | 5 | 2.5 |
| 100 | 0.2 | 20 | 16 |
| 100 | 0.5 | 50 | 25 |
| 5,000 | 0.4 | 2,000 | 1,200 |
You can also find the mean by adding up each value of x times its probability. For n = 10 and p = 0.3, that sum comes to 3.0, and np = 10 times 0.3 = 3. Both give the same answer, as the code below confirms.
The live page: 5,000 students are chosen at random, and 40 percent of all students study Mathematics. What is the expected number in the sample? The page shows the answer only in an image.

Answer: you expect 2,000 Mathematics students, give or take about 35. The chance of landing exactly on 2,000 is only 0.0115, but 95 percent of samples will have between 1,932 and 2,068. A simulation of 100,000 such samples gave an average of 1,999.85 and a standard deviation of 34.55, very close to the theory.
The expected value is not a promise about one sample. It is the centre of the distribution.
I ran the code below, and the output is real.
| Mistake | Fix |
|---|---|
| Calling n the number of outcomes | n is the number of trials |
| Using 40 for p instead of 0.40 | p is a probability between 0 and 1 |
| Treating the expected value as a guaranteed result | It is the long run average |
| Using the formula when trials are not independent | Check independence |
| Using it when the chance of success changes | p must be constant |
| Calling a prediction an expected value | The expected value comes from n and p |
| Reading expected as at least | It is an average, not a minimum |
| Forgetting the variance | Report the spread with the mean |
Answers: 1) 200 times 0.03 = 6. 2) 80 times 0.5 = 40, and the variance is 80 times 0.5 times 0.5 = 20, so the standard deviation is the square root of 20 = 4.47. 3) 1,200 times 0.25 = 300, and the variance is 1,200 times 0.25 times 0.75 = 225. 4) Yes, for example 2.5 heads in 5 tosses. These are my own answers, so please recheck them before publishing.
The expected value of a binomial distribution is simply the number of trials times the chance of success. Put p in as a decimal, check that your trials are independent, and always report the spread with the mean.