Expected Value Calculator: Variance and Standard Deviation

Enter outcomes and probabilities to get the expected value, variance, and standard deviation of a discrete distribution, with a probability check that shows the running sum and one-click normalize.

At a glance

Computes
Expected value, variance, and SD of a discrete distribution, or gambler's ruin probabilities.
You supply
Outcomes with their probabilities, or a step probability, bankroll, and target.
Use when
You have outcomes with known probabilities and need the long-run average.
Assumes
Probabilities sum to one; the running sum is shown and never silently normalized.
Mode
Outcome xProbability p Actions

Probability check Σp = 0

Worked example

Shown without JavaScript: an example computed when this page was built, using the values the fields above suggest. This page calculates in your browser, so entering your own outcomes and computing from them needs JavaScript enabled.

Expected value E[X]

-0.05263

An American roulette single-number bet: it pays 35 at probability 1/38 and loses 1 at probability 37/38.

Variance σ² In X's units squared
33.21
Standard deviation σ Shares X's units
5.763

Probability mass by Outcome; 2 centered outcomes; Expected value -0.05263; one standard deviation from -5.815 to 5.71

0.00.20.40.60.8−135
Per-outcome contributions (the total row sums to E[X] and to the variance)
xpx·p(x - μ)²·p
350.026320.921132.33
-10.9737-0.97370.8739
Total-0.0526333.21

The same example in Gambler's Ruin mode

A fair game at p = 0.5, starting from a bankroll of 5, with a target of 10.

P(reach target)

0.5

P(ruin)

0.5

Expected duration (steps to absorption)
25
Method
Fair game (p = 1/2): P = i/N

Add outcomes and their probabilities to see the expected value.

Export

E[X] = μ = Σ xᵢ·pᵢ; σ² = Σ (xᵢ - μ)²·pᵢ; σ = √σ² How?

How this is calculated

The expected value is the probability-weighted mean of the outcomes. Because the probabilities define the entire distribution, this is a population: there is no sample, so no n - 1 (Bessel) correction is applied. The variance is computed in deviation form, Σ (xᵢ - μ)²·pᵢ, rather than the algebraic identity E[X²] - μ². The two are equal, but the deviation form avoids the catastrophic cancellation that E[X²] - μ² suffers when the mean is large relative to the spread.

Expected value is a long-run average over many independent trials, not a prediction of the next draw. The standard deviation reports how far a single result can land from that average, in the same units as the outcomes. The binomial and Poisson pages print those moments in closed form beside the exact probability of a count.

Probabilities are validated: each must lie in [0, 1], and their sum is checked against 1 within a tolerance of 1e-9 (so 0.1 + 0.2 + 0.7 counts as exact). A sum other than 1 is never silently accepted. The running sum is shown, and one click normalizes each probability by dividing it by Σp.

Formula: E[X] = μ = Σ xᵢ·pᵢ; σ² = Σ (xᵢ - μ)²·pᵢ; σ = √σ²

Gambler's Ruin and the Gambler's Fallacy

Gambler's Ruin models a bankroll that changes by $1 per step: you win a step with probability p and lose it with probability q = 1 - p, starting at i and cashing out at a target N, with absorbing barriers at 0 and N. For a fair game (p = 1/2) the probability of reaching N before ruin is i/N and the expected number of steps is i(N - i). For a biased game it uses the ratio ρ = q/p. This is bankroll arithmetic, and it says nothing about the memory of the trials.

The Gambler's Fallacy is the belief that independent trials have memory: that a run of losses makes a win "due", or that a streak of reds makes black more likely next spin. Independent trials have no memory. Each spin of a fair American roulette wheel lands on any one number with probability 1/38 regardless of what came before, so a past streak does not shift the next outcome. Gambler's Ruin is about the bankroll; the Gambler's Fallacy is about the trials, and confusing the two is the mistake these two blocks separate.

Sources

  1. 4.2 Mean or Expected Value and Standard Deviation. OpenStax Introductory Statistics. Retrieved .
  2. The Gambler's Ruin Problem (lecture notes). Karl Sigman, Columbia University. Retrieved .
  3. MATH2750 Section 3: Gambler's ruin. Matthew Aldridge, University of Leeds. Retrieved .