Learn
Statistics formulas
These are the formulas this site's calculators actually run, written the way the code computes them. Each one links to a calculator that shows it worked on your own numbers. For a term-by-term explanation of the standard deviation itself, see the standard deviation formula.
Notation: Greek letters (μ, σ) are population values and Latin letters (x̄, s) are sample values. Σ means “add up over every value”, n is the sample size, and a star (t*, z*) marks a critical value. The symbols page has the full list.
Centre: means, median and midrange
Where the data sits. Every spread measure below is measured from one of these.
Arithmetic mean
x̄ = Σx ÷ n
Σx is the sum of the values and n how many there are. The population mean μ uses the same formula. Mean calculator →
Weighted mean
x̄w = Σwx ÷ Σw
w is each value’s weight. The weights do not need to sum to 1. Weighted average calculator →
Geometric mean
G = (x₁ · x₂ · … · xₙ)^(1/n) = exp(Σ ln x ÷ n)
Defined only when every value is positive. Computed through logarithms so large products do not overflow. Mean calculator →
Harmonic mean
H = n ÷ Σ(1/x)
Defined only for positive values. The right average for rates, such as speeds over equal distances. Mean calculator →
Trimmed mean
k = ⌊n · p⌋; trimmed mean = mean of the sorted values x₍ₖ₊₁₎ … x₍ₙ₋ₖ₎
p is the share cut from each end (0.1 for a 10% trimmed mean). Excel’s TRIMMEAN takes the total share, 2p. Mean calculator →
Median and quantiles
h = (n − 1) · p; Q(p) = x₍⌊h⌋₎ + (h − ⌊h⌋) · (x₍⌈h⌉₎ − x₍⌊h⌋₎)
x₍ᵢ₎ is the i-th sorted value counting from 0, and p the proportion (0.5 for the median, 0.25 and 0.75 for Q1 and Q3). This is linear interpolation: R type 7, Excel PERCENTILE.INC. Median calculator →
Midrange
midrange = (max + min) ÷ 2
Halfway between the extremes. Quick, but one outlier moves it. Range calculator →
Spread: range to standard deviation
How far the values sit from the centre. The standard deviation is the one most often reported.
Range
range = max − min
Depends on only two values. Range calculator →
Interquartile range and Tukey fences
IQR = Q3 − Q1 fences = Q1 − 1.5·IQR and Q3 + 1.5·IQR
Quartiles by the interpolation rule above. Values beyond 3·IQR are extreme outliers. Outlier & IQR calculator →
Mean absolute deviation
MAD = Σ|x − x̄| ÷ n
The average distance from the mean, without squaring. The median version replaces x̄ with the median. MAD calculator →
Sum of squares
SS = Σ(x − x̄)²
The total squared deviation that both variances divide. Sum of squares calculator →
Sample variance
s² = Σ(x − x̄)² ÷ (n − 1)
n − 1 is Bessel’s correction for estimating from a sample. Sample variance calculator →
Population variance
σ² = Σ(x − μ)² ÷ N
N is the size of the whole population and μ its mean. Population variance calculator →
Sample standard deviation
s = √( Σ(x − x̄)² ÷ (n − 1) )
The square root of s², back in the data’s units. Sample SD calculator →
Population standard deviation
σ = √( Σ(x − μ)² ÷ N )
Use when the values are the entire group. Population SD calculator →
Computational (shortcut) formula
s² = ( Σx² − (Σx)² ÷ n ) ÷ (n − 1)
Algebraically identical to the definition. It loses precision on a computer when values are large and close together, so this site computes with Welford’s algorithm instead. Sum of squares calculator →
Frequency table and grouped data
x̄ = Σfx ÷ Σf s² = Σf(x − x̄)² ÷ (Σf − 1)
f is each value’s frequency; for class intervals x is the class midpoint. Use Σf in place of Σf − 1 for a population. Frequency table SD calculator →
Weighted standard deviation
σ²w = Σw(x − x̄w)² ÷ D D = V₁ − V₂ ÷ V₁ (sample) or V₁ (population)
V₁ = Σw and V₂ = Σw². With every weight equal to 1, D becomes n − 1 or n. Weighted SD calculator →
Pooled standard deviation
sp = √( Σ(nᵢ − 1)sᵢ² ÷ Σ(nᵢ − 1) )
nᵢ and sᵢ are each group’s size and SD. It averages the variances, never the SDs. Pooled SD calculator →
Coefficient of variation and %RSD
CV = s ÷ |x̄| %RSD = 100 × s ÷ |x̄|
Undefined when the mean is 0. Meaningful only on a ratio scale. CV calculator →
Root mean square
RMS = √( Σx² ÷ n )
The RMS of the deviations from the mean is the population SD. RMS calculator →
Standard scores and precision
Placing one value against the rest, and saying how precisely a mean or SD is known.
Z-score
z = (x − x̄) ÷ s
How many standard deviations x sits from the mean. With population parameters, z = (x − μ) ÷ σ. Z-score calculator →
Modified z-score
M = 0.6745 × (x − median) ÷ MAD MAD = median of |x − median|
Here MAD is the median absolute deviation. |M| > 3.5 flags a potential outlier (Iglewicz and Hoaglin). Outlier & IQR calculator →
Standard error of the mean
SE = s ÷ √n
Reversed, s = SE × √n recovers the SD from a published SE. Standard error calculator →
Margin of error for a mean
E = t* × s ÷ √n
t* is the two-sided critical t on n − 1 degrees of freedom. With σ known, or for large n, z* replaces t*. Margin of error calculator →
Margin of error for a proportion
E = z* × √( p(1 − p) ÷ n )
p is the sample proportion and z* the two-sided critical z (1.96 at 95%). Margin of error calculator →
Confidence interval for a mean
x̄ ± t* × s ÷ √n
t* on n − 1 degrees of freedom at the chosen confidence level. Confidence interval calculator →
Confidence interval for a standard deviation
√( (n − 1)s² ÷ χ²₍α/2₎ ) ≤ σ ≤ √( (n − 1)s² ÷ χ²₍1−α/2₎ )
χ²₍α/2₎ is the chi-square value with α/2 in the upper tail on n − 1 df, so the larger one sets the lower limit. Assumes normal data; the interval is not symmetric around s. CI for SD calculator →
Sample size for a mean
n = (z* × σ ÷ E)²
E is the target margin of error. Always round up. Sample size calculator →
Sample size for a proportion
n = z*² × p(1 − p) ÷ E² n′ = n ÷ (1 + (n − 1) ÷ N)
p = 0.5 is the conservative choice. The second line is the finite population correction for a population of N. Sample size calculator →
Distributions
The standard deviation of a model, rather than of a dataset.
Normal density
f(x) = 1 ÷ (σ√(2π)) × e^( −(x − μ)² ÷ (2σ²) )
Probabilities are areas under this curve, found from the standard normal CDF Φ(z) with z = (x − μ) ÷ σ. Normal distribution calculator →
Empirical rule bands
μ ± kσ covers Φ(k) − Φ(−k): 68.27%, 95.45%, 99.73% for k = 1, 2, 3
Exact for a normal distribution; approximate at best for anything else. Empirical rule calculator →
Binomial mean and SD
μ = np, σ² = np(1 − p), σ = √(np(1 − p)) P(X = k) = C(n, k) pᵏ (1 − p)ⁿ⁻ᵏ
n trials, each a success with probability p. Binomial calculator →
Poisson mean and SD
μ = σ² = λ, σ = √λ P(X = k) = λᵏ e^(−λ) ÷ k!
λ is the average number of events per interval. Poisson calculator →
Tests, effect sizes and models
Where the standard deviation feeds a decision: a test statistic, an effect size or a fitted line.
One-sample t
t = (x̄ − μ₀) ÷ (s ÷ √n), df = n − 1
μ₀ is the hypothesised mean. A paired t test applies this to the within-pair differences. T-test calculator →
Two-sample t (Welch)
t = (x̄₁ − x̄₂) ÷ √( s₁² ÷ n₁ + s₂² ÷ n₂ ) df = (s₁²/n₁ + s₂²/n₂)² ÷ [ (s₁²/n₁)² ÷ (n₁ − 1) + (s₂²/n₂)² ÷ (n₂ − 1) ]
The Welch–Satterthwaite df is usually fractional. Student’s pooled version uses sp√(1/n₁ + 1/n₂) and df = n₁ + n₂ − 2. T-test calculator →
Cohen’s d
d = (x̄₁ − x̄₂) ÷ sp sp = √( ((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2) )
The mean difference in pooled-SD units. Benchmarks 0.2, 0.5 and 0.8 are Cohen’s small, medium and large. Cohen’s d calculator →
Hedges’ g and the interval for d
g = d × (1 − 3 ÷ (4·df − 1)), df = n₁ + n₂ − 2 SE(d) = √( (n₁ + n₂) ÷ (n₁n₂) + d² ÷ (2(n₁ + n₂)) ); d ± z* × SE(d)
g removes d’s small-sample upward bias. The interval uses the large-sample normal approximation. Cohen’s d calculator →
Chi-square
χ² = Σ (O − E)² ÷ E
O observed and E expected counts. Goodness of fit: df = categories − 1. Independence: E = row total × column total ÷ grand total and df = (rows − 1)(columns − 1). Chi-square calculator →
One-way ANOVA F
SSB = Σ nⱼ(x̄ⱼ − x̄)², SSW = ΣΣ(x − x̄ⱼ)² F = (SSB ÷ (k − 1)) ÷ (SSW ÷ (N − k))
k groups, N values in total, x̄ⱼ each group’s mean and x̄ the grand mean. ANOVA calculator →
Pearson correlation
r = Sxy ÷ √(Sxx · Syy) Sxy = Σ(x − x̄)(y − ȳ), Sxx = Σ(x − x̄)², Syy = Σ(y − ȳ)²
Spearman’s rho is the same formula applied to the ranks. Correlation calculator →
Least-squares line
b = Sxy ÷ Sxx, a = ȳ − b·x̄, ŷ = a + bx
b is the slope and a the intercept, with S terms as for correlation. Linear regression calculator →
Process capability
Cp = (USL − LSL) ÷ 6σ Cpk = min( (USL − x̄) ÷ 3σ, (x̄ − LSL) ÷ 3σ )
USL and LSL are the specification limits. Cp needs both; Cpk works with one. Cpk calculator →
Two-asset portfolio SD
σp = √( w₁²σ₁² + w₂²σ₂² + 2w₁w₂ρσ₁σ₂ )
w are the weights (scaled to sum to 1), σ each asset’s SD and ρ their correlation. Portfolio SD calculator →
Conventions used here
- Arithmetic is IEEE-754 double precision, and results are displayed to six significant figures. Nothing is rounded between steps.
- Critical values (t*, z*, χ²) are computed by inverting the distribution function numerically, not read from a printed table, so they are accurate beyond the usual three decimals.
- Quartiles and percentiles use linear interpolation. Other definitions give slightly different values on small datasets.
The methodology page gives the algorithms and the tests they are checked against. Test your understanding with the quiz, or see these formulas at work in real use cases.