Statistics Formulas

The core descriptive statistics formulas in one place, with the notation explained and a worked example computed by the same engine as the Calxy statistics calculator.

Descriptive statistics formulas

Notation: n is the number of values in a sample and N the size of a whole population; x̄ is the sample mean and μ the population mean; Σ means sum over all values.

Measures of location and spread
StatisticFormulaNotes
Mean (sample)x̄ = Σx ÷ nPopulation mean μ = Σx ÷ N
MedianMiddle value of the sorted dataAverage of the two middle values when n is even
ModeMost frequent valueA data set may have several modes or none
Rangemax − minSensitive to outliers
Population varianceσ² = Σ(x − μ)² ÷ NEvery member of the population is measured
Sample variances² = Σ(x − x̄)² ÷ (n − 1)n − 1 (Bessel's correction) makes s² unbiased
Standard deviationσ = √σ², s = √s²Same units as the data
Standard error of the meanSE = s ÷ √nSpread of the sample mean
z-scorez = (x − μ) ÷ σStandard deviations above (+) or below (−) the mean
Coefficient of variationCV = s ÷ x̄ × 100%Only meaningful for ratio-scale data
Interquartile rangeIQR = Q₃ − Q₁Quartile methods differ slightly between textbooks and software
Skewness (moment coefficient)g₁ = [Σ(x − x̄)³ ÷ n] ÷ [Σ(x − x̄)² ÷ n]^(3/2)0 for symmetric data; positive means a longer right tail

Sources: NIST/SEMATECH: e-Handbook of Statistical Methods §1.3.5.1 Measures of Location; NIST/SEMATECH: e-Handbook of Statistical Methods §1.3.5.6 Measures of Scale; OpenStax: Introductory Statistics 2e §2.7 Measures of the Spread of the Data

Expected value and variance of a random variable

For a discrete random variable X that takes value x with probability P(x), the expected value (expectation) is the probability-weighted average of its outcomes, and the variance measures spread around it.

  • Expectation: E[X] = μ = Σ x·P(x)
  • Variance: Var(X) = σ² = Σ (x − μ)²·P(x) = E[X²] − (E[X])²
  • Linearity: E[aX + b] = a·E[X] + b and Var(aX + b) = a²·Var(X)
  • Sum of variables: E[X + Y] = E[X] + E[Y]; Var(X + Y) = Var(X) + Var(Y) when X and Y are independent

Sources: OpenStax: Introductory Statistics 2e §4.2 Mean or Expected Value and Standard Deviation

Worked example

For the data 2, 4, 4, 4, 5, 5, 7, 9 (n = 8), the values below are computed by the Calxy statistics engine. The population and sample standard deviations differ only in the divisor, N versus n − 1.

Statistics of 2, 4, 4, 4, 5, 5, 7, 9
StatisticValue
Sum Σx40
Mean x̄5.0000
Median4.5000
Mode4
Q₁ / Q₃ (linear interpolation)4.0000 / 5.5000
Population variance σ²4.0000
Population SD σ2.0000
Sample variance s²4.5714
Sample SD s2.1381
z-score of 9 (population)2.0000

References

Frequently asked questions

Why does sample variance divide by n − 1?

Deviations are measured from the sample mean, which is itself fitted to the data, so they are slightly too small. Dividing by n − 1 instead of n corrects that bias.

What is the difference between variance and standard deviation?

Standard deviation is the square root of variance. Variance is in squared units; standard deviation is in the same units as the data, which makes it easier to interpret.