Statistics formulas

Mean, median, variance and standard deviation

Paste a list of numbers to get the count, sum, mean, median, mode, range, and both the population and the sample variance and standard deviation.

Formula

x‾=Σxin;s2=Σ(xi−x‾)2n−1 x̄ = Σxᵢ / n; σ² = Σ(xᵢ − x̄)² / n; s² = Σ(xᵢ − x̄)² / (n − 1)

The mean, median and mode describe where the data lie, while the variance and the standard deviation describe how far the values spread around the mean: a full population divides the squared deviations by n, a sample divides them by n − 1.

Mean, median, variance and standard deviation calculator

What is this data set?

Data

Sorted data: 2; 4; 4; 4; 5; 5; 7; 9

The result updates automatically. You can paste the values from a spreadsheet.

Results

Variance σ² (n = 8)

4

Standard deviation σ

2

For the other choice — Sample (divisor n − 1): s² = 4.571429; s = 2.13809

Count n
8
Sum Σxᵢ
40
Mean x̄
5
Median Me
4.5
Mode Mo
4
Range R
7
Minimum
2
Maximum
9

Sum of squared deviations Σ(xᵢ − x̄)² = 32

Symbols and units

SymbolQuantitySISupported units
xᵢobservationsIndividual values of the data set; the order of entry does not matter.11
ncountNumber of observations in the data set.11
x̄arithmetic meanSum of all values divided by the count.11
MemedianMiddle value of the sorted data, or the average of the two middle values for an even count.11
MomodeMost frequent value; it does not exist when no value repeats and it is ambiguous when several values share the highest frequency.11
RrangeDifference between the largest and the smallest value.11
σ²population varianceMean squared deviation from the mean, with the divisor n.11
σpopulation standard deviationSquare root of the population variance, expressed in the unit of the data.11
s²sample varianceUnbiased estimator of the population variance, with the divisor n − 1; it needs at least two observations.11
ssample standard deviationSquare root of the sample variance, expressed in the unit of the data.11

Formula rearrangements

Arithmetic mean

x̄ = (x₁ + x₂ + … + xₙ) / n

Median of sorted data

Me = x₍ₖ₎ dla n nieparzystego, k = (n + 1) / 2; Me = (x₍ₙ/₂₎ + x₍ₙ/₂₊₁₎) / 2 dla n parzystego

Population variance (divisor n)

σ² = Σ(xᵢ − x̄)² / n

Sample variance (divisor n − 1)

s² = Σ(xᵢ − x̄)² / (n − 1)

Standard deviation

σ = √σ²; s = √s²

Range

R = max − min

Worked examples

Standard deviation of a whole population

Eight measurements form the complete data set: 2, 4, 4, 4, 5, 5, 7, 9. Calculate the population standard deviation.

  1. 1Step 1: Add the values: 2 + 4 + 4 + 4 + 5 + 5 + 7 + 9 = 40, and divide by n = 8 to obtain x̄ = 5.
  2. 2Step 2: Square every deviation from the mean: 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32.
  3. 3Step 3: Divide by n = 8 to obtain σ² = 4, then take the square root: σ = 2.
  4. 4Step 4: Treating the same numbers as a sample would divide by n − 1 = 7: s² = 32/7 ≈ 4.571 and s ≈ 2.138.

Result: σ = 2 (population); s ≈ 2.138 (sample)

Variance of a sample

Five test scores drawn from a larger class: 12, 15, 15, 18, 20. Calculate the sample variance.

  1. 1Step 1: Add the values: 12 + 15 + 15 + 18 + 20 = 80, and divide by n = 5 to obtain x̄ = 16.
  2. 2Step 2: Square every deviation from the mean: 16 + 1 + 1 + 4 + 16 = 38.
  3. 3Step 3: Because the data are a sample, divide by n − 1 = 4: s² = 9.5 and s = √9.5 ≈ 3.082.
  4. 4Step 4: The same numbers treated as a whole population would give σ² = 38/5 = 7.6, a visibly smaller value.

Result: s² = 9.5; s ≈ 3.082 (population: σ² = 7.6)

Sources and review