The descriptive, inference and probability formulas behind the statistics calculators. The worked data set is 2, 4, 4, 4, 5, 5, 7, 9, and every number was checked against Python's statistics module and SciPy. For a guided explanation, read How Standard Deviation Works.
Describing data
| Name | Formula | Example |
|---|---|---|
| Mean | x̄ = Σx / n |
5 for the data above (sum 40, n = 8) |
| Median | middle value (average the two middle ones when n is even) |
4.5 |
| Mode and range | most frequent value; max − min |
Mode 4, range 7 |
| Population variance and SD | σ² = Σ(x − μ)² / N, σ = √σ² |
4 and 2 |
| Sample variance and SD | s² = Σ(x − x̄)² / (n − 1), s = √s² |
4.571 and 2.138 |
| z-score | z = (x − μ) / σ |
9 is z = 2 |
| Weighted average | Σ(w·x) / Σw |
90 (40%), 80 (30%), 70 (30%): 81 |
Try them: Average Calculator, Mean, Median, Mode & Range Calculator, Standard Deviation Calculator, Statistics Calculator, Z-score Calculator and Weighted Average Calculator. Use n for a whole population and n − 1 for a sample drawn from a larger one.
Estimating and testing
| Name | Formula | Example |
|---|---|---|
| Standard error of the mean | SE = s / √n |
0.756 |
| 95% confidence interval (small sample) | x̄ ± t* · SE |
t* = 2.365 (7 degrees of freedom): 3.21 to 6.79 |
| Sample size for a proportion | n = z² · p(1 − p) / e² |
95%, p = 0.5, margin ±5%: 384.16, round up to 385 |
| Chi-square statistic | χ² = Σ (O − E)² / E |
60 die rolls (5, 8, 9, 8, 10, 20 against 10 expected): 13.4, p = 0.020 |
| p-value of a z-score | p = 2 · (1 − Φ(|z|)) |
z = 1.96 (two-sided): p = 0.05 |
| Least-squares line | slope = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)², intercept = ȳ − slope · x̄ |
Points (1,2) (2,4) (3,5) (4,4) (5,5): y = 0.6x + 2.2, r = 0.775 |
Try them: Confidence Interval Calculator, Sample Size Calculator, t-Test Calculator, Chi-Square Test Calculator, P-value Calculator and Linear Regression Calculator.
Counting and probability
| Name | Formula | Example |
|---|---|---|
| Combinations | C(n, k) = n! / (k!(n − k)!) |
Choose 3 of 10, order ignored: 120 |
| Permutations | P(n, k) = n! / (n − k)! |
Arrange 3 of 10, order matters: 720 |
| Independent events | P(A and B) = P(A) · P(B) |
Two heads in a row: 0.5 × 0.5 = 0.25 |
| At least one | 1 − P(none) |
At least one 6 in 4 rolls: 1 − (5/6)⁴ = 0.5177 |
| Binomial probability | P(X = k) = C(n, k) · p^k · (1 − p)^(n − k) |
Exactly 3 heads in 10 fair tosses: 0.1172 |
| Poisson probability | P(X = k) = e^−λ · λ^k / k! |
Exactly 2 events when the mean is 3: 0.2240 |
Try them: Permutation and Combination Calculator, Probability Calculator, Binomial Distribution Calculator and Poisson Distribution Calculator.
Rules of thumb
- 68-95-99.7. In a normal distribution about 68%, 95% and 99.7% of values lie within 1, 2 and 3 standard deviations of the mean.
- Mean versus median. Outliers pull the mean, not the median, so income and house prices are quoted as medians.
- A small p-value is not proof. It says the data would be surprising if there were no effect; it does not give the size or importance of an effect.
- Correlation is not causation. A strong
ronly says two variables move together.