Understanding the expected value and variance calculator — concept and principle
The expected value E[X] of a discrete random variable is its probability-weighted average: the long-run mean you would see if the same situation were repeated many times. Variance and standard deviation measure how far individual outcomes typically fall from that mean. Together they are used to compare games and lotteries, price insurance, evaluate business decisions with uncertain payoffs and summarize any probability distribution given as a table.
How it is calculated
Enter the outcomes x₁, x₂, … and their probabilities p₁, p₂, … as two comma-separated lists of the same length.
- Expected value: E[X] = Σ xᵢ·pᵢ
- Variance: Var(X) = Σ pᵢ·(xᵢ − E[X])², which equals E[X²] − (E[X])²
- Standard deviation: σ = √Var(X), in the same units as x
- Σp: the sum of the probabilities, shown so you can confirm it equals 1
The principle
Think of the probabilities as weights on a number line. E[X] is the balance point, the centre of mass of those weights. By the law of large numbers, the average of many independent repetitions approaches E[X]. Variance squares each deviation so that values above and below the mean do not cancel and large deviations count more; the square root returns to the original units. Expected value is linear: E[aX + b] = aE[X] + b, while Var(aX + b) = a²Var(X).
Worked example
- Defaults: x = 0, 10, 100 with p = 0.7, 0.25, 0.05 (Σp = 1).
- E[X] = 0·0.7 + 10·0.25 + 100·0.05 = 0 + 2.5 + 5 = 7.5.
- Deviations squared and weighted: 0.7·(−7.5)² = 39.375; 0.25·(2.5)² = 1.5625; 0.05·(92.5)² = 427.8125.
- Variance = 39.375 + 1.5625 + 427.8125 = 468.75. Check: E[X²] = 0 + 25 + 500 = 525, and 525 − 7.5² = 468.75.
- Standard deviation = √468.75 ≈ 21.65063509.
How to read the result
If the outcomes were prizes and a ticket cost 10, the expected net result would be 7.5 − 10 = −2.5 per play: a loss in the long run even though one play in twenty wins 100. The standard deviation of 21.65 is almost three times the mean, showing that the result is dominated by the rare large outcome. Use E[X] to compare long-run averages and σ to compare risk.
Common mistakes
- Probabilities that do not sum to 1, often from rounding or a missing outcome; check Σp.
- Treating E[X] as the most likely value; here the most likely outcome is 0, not 7.5.
- Confusing the population formula used here with the sample variance (divide by n − 1) for data.
Frequently asked questions
Can the expected value be a value X never takes?
Yes. A fair die has E[X] = 3.5, which is not a face of the die.
Is a positive expected value always a good bet?
Not necessarily. High variance can wipe out a limited budget before the average shows up.
How is this different from the mean of a data set?
A data mean weights each observation equally; E[X] weights each outcome by its probability. With observed relative frequencies as probabilities, they coincide.
Sources: Sheldon M. Ross, A First Course in Probability, Pearson — expectation and variance · William Feller, An Introduction to Probability Theory and Its Applications, Vol. 1, Wiley