# Descriptive statistics calculator

> Descriptive statistics calculator: mean, median, mode, standard deviation, variance, quartiles, IQR, outliers, skewness and kurtosis, with a histogram.

Interactive version: https://www.calcopenly.com/statistics/descriptive-statistics-calculator
Subject: Statistics and probability calculators

Descriptive statistics summarise a data set by its centre, spread and shape. The mean is the sum divided by n; the sample variance divides the squared deviations from the mean by n − 1 and the population variance by n. Quartiles come from the sorted data by linear interpolation (R-7, as Excel QUARTILE.INC), the exclusive method (R-6) or Tukey's hinges, and skewness and excess kurtosis use the adjusted formulas of Excel SKEW and KURT.

Values more than 1.5 × IQR beyond the quartiles are flagged as outliers, following Tukey's box-plot rule. The default data, 18 commute times in minutes, have a mean of 26.67 and a median of 24.5; the 64-minute trip lies beyond the upper fence of 47 and pulls the mean above the median.

Use the sample standard deviation when the data are a sample from a larger group, and the population value when they are the whole group.

## How to calculate standard deviation by hand

Standard deviation measures how far values typically sit from their mean. Eight quiz marks out of 10, 2, 4, 4, 4, 5, 5, 7 and 9, are small enough to work through on paper.

1. Find the mean: the marks add up to 40, and 40 ÷ 8 = 5.
2. Subtract the mean from each value and square the result.

| Mark x | Deviation x − 5 | Squared deviation |
|---|---|---|
| 2 | −3 | 9 |
| 4 | −1 | 1 |
| 4 | −1 | 1 |
| 4 | −1 | 1 |
| 5 | 0 | 0 |
| 5 | 0 | 0 |
| 7 | 2 | 4 |
| 9 | 4 | 16 |
| Sum | 0 | 32 |

3. Add the squared deviations: 32. The deviations themselves always sum to 0, which is a useful check on step 2.
4. Divide to get the variance: 32 ÷ 8 = 4 for the population variance σ², or 32 ÷ 7 = 4.571429 for the sample variance s².
5. Take the square root: σ = √4 = 2 and s = √4.571429 = 2.138090.

Entered into the calculator, the same eight marks give a population standard deviation of 2 and a sample standard deviation of 2.13809. These are the formulas in the [NIST/SEMATECH e-Handbook, §1.3.5.6](https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm).

Variance is in squared units, marks² here, which is why the square root is taken: the standard deviation, 2.14 marks, is back on the scale of the data and can be compared with the mean.

## Sample or population: which to use

Use the population formula (divide by n) when the data are the entire group you want to describe, such as the marks of every student in this one class. Use the sample formula (divide by n − 1) when the data stand in for a larger group, such as eight students surveyed to learn about a whole year group.

The two results differ by a factor of √(n ÷ (n − 1)), which matters for small data sets and fades as n grows:

| Values n | Sample SD ÷ population SD |
|---|---|
| 2 | 1.4142 |
| 3 | 1.2247 |
| 5 | 1.1180 |
| 10 | 1.0541 |
| 30 | 1.0171 |
| 100 | 1.0050 |
| 1,000 | 1.0005 |

Software does not agree on a default:

| Tool | Sample (n − 1) | Population (n) |
|---|---|---|
| Excel | STDEV.S | STDEV.P |
| Python statistics module | stdev() | pstdev() |
| NumPy | np.std(x, ddof=1) | np.std(x), the default |
| pandas | DataFrame.std(), the default | DataFrame.std(ddof=0) |
| This calculator | Sample standard deviation s | Population standard deviation σ |

[NumPy's std](https://numpy.org/doc/stable/reference/generated/numpy.std.html) divides by n unless told otherwise, while [pandas](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.std.html) divides by n − 1. Moving the same column between them changes the answer by the factor in the table above. Excel's [STDEV.S](https://support.microsoft.com/en-us/office/stdev-s-function-7d69cf97-0c1f-4acf-be27-f3e83904cc23) also skips text and empty cells in a range, so a number stored as text is silently left out of the calculation.

## Mean, median, mode and range

For the quiz marks, the mean is 5 and the median is 4.5, the average of the fourth and fifth sorted values (4 and 5). The mode is 4, which occurs three times, and the range is 9 − 2 = 7.

Each answers a different question. The mean uses every value and is what the standard deviation is measured from. The median is the middle of the sorted data and ignores how far the extremes reach. The mode is the only one of the three that works for categories, such as the most common shoe size sold. The range depends on just two values, so a single unusual reading changes it completely.

When the mean sits above the median, the data often have a longer tail of high values. The marks do: the 9 pulls the mean half a mark above the median, and the calculator reports a skewness of 0.818.

## Quartile methods compared

The quartiles Q1 and Q3 cut off the lowest and highest quarters of the sorted data, and the interquartile range, Q3 − Q1, is the spread of the middle half. [Hyndman and Fan (1996)](https://doi.org/10.1080/00031305.1996.10473566) catalogue nine published ways to place them, and on small data sets they disagree. The calculator offers three of them, shown here on the quiz marks:

| Method | Q1 | Q3 | IQR | 1.5 × IQR fences | Is the 9 an outlier? |
|---|---|---|---|---|---|
| Linear interpolation (R-7) | 4 | 5.5 | 1.5 | 1.75 and 7.75 | Yes |
| Exclusive (R-6) | 4 | 6.5 | 2.5 | 0.25 and 10.25 | No |
| Tukey's hinges | 4 | 6 | 2 | 1 and 9 | No, it sits on the fence |

- **R-7** places Q3 at position (n − 1) × 0.75 + 1 = 6.25 in the sorted list, a quarter of the way from the sixth value (5) to the seventh (7). It is Excel's QUARTILE.INC, the default of R's [quantile()](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html) and of NumPy's percentile().
- **R-6** uses position (n + 1) × 0.75 = 6.75 instead. It is Excel's QUARTILE.EXC and the method R's documentation attributes to Minitab and SPSS. Python's statistics.quantiles() also uses it unless told otherwise.
- **Tukey's hinges** are the medians of the lower half (2, 4, 4, 4) and the upper half (5, 5, 7, 9). R's fivenum() reports these.

With only eight values, the method alone decides whether the 9 is flagged. Before comparing quartiles or outlier counts with a textbook or another program, set the calculator to the same method.

## Reading the results and avoiding common errors

- **Standard deviation versus standard error.** The standard error of the mean, s ÷ √n, measures how precisely the sample mean estimates the population mean, not how spread out the data are. For the quiz marks it is 2.138 ÷ √8 = 0.756. Reporting it in place of the standard deviation makes data look almost three times less variable than they are. It is the input a [confidence interval](/statistics/confidence-interval-calculator) for the mean is built from.
- **The coefficient of variation needs a meaningful zero.** The CV, s ÷ |mean| × 100, is 42.76% for the marks and lets you compare spread across data on different scales. It is meaningless for temperatures in °C or any measure that can be negative, because the mean can sit near zero and inflate it without limit.
- **The one-pass formula loses precision.** The computational formula for the variance, (Σx² − (Σx)² ÷ n) ÷ (n − 1), avoids computing the mean first. On large numbers with small differences it fails in ordinary double-precision arithmetic. NIST's [NumAcc3 reference data set](https://www.itl.nist.gov/div898/strd/univ/numacc3.html), 1,001 values near 1,000,000.2, has a certified standard deviation of exactly 0.1; the computational formula run with Python floats returns 0.1072. The calculator subtracts the mean first and works with 50 significant digits, and it returns 0.1.
- **Fewer than two values.** With one value there is nothing to measure spread against, and the sample formula would divide by zero, so the calculator asks for at least two.

Once the mean and standard deviation are known, the [normal distribution calculator](/statistics/normal-distribution-calculator) turns any value into a z-score and percentile, provided the histogram looks roughly bell-shaped.

## Inputs

- **Data**: Numbers separated by commas, spaces or new lines (the default is 18 commute times in minutes).
- **Quartile method** (options: Linear interpolation (R-7, Excel QUARTILE.INC), Exclusive (R-6, Excel QUARTILE.EXC, Minitab), Tukey's hinges)
- **Histogram bins**: Blank uses Sturges' rule, ⌈log₂ n⌉ + 1 bins. Edges snap to steps of 1, 2, 2.5 or 5 times a power of 10, so the bin count can differ a little from this.

## Results

- Mean — main result
- Median
- Mode
- Count n
- Sum
- Minimum
- Maximum
- Range
- Sample variance s²
- Sample standard deviation s
- Population variance σ²
- Population standard deviation σ
- Standard error of the mean
- First quartile Q1
- Third quartile Q3
- Interquartile range
- Outliers
- Skewness (G1)
- Excess kurtosis (G2)
- Coefficient of variation

## Formula

$$
\bar x = \frac{1}{n}\sum x_i,\qquad s^2 = \frac{\sum (x_i - \bar x)^2}{n-1},\qquad G_1 = \frac{n}{(n-1)(n-2)}\sum\left(\frac{x_i-\bar x}{s}\right)^3
$$

## Worked examples

### Commute times (default data)

- Data: 12, 15, 17, 18, 19, 21, 22, 22, 24, 25, 27, 28, 29, 31, 33, 35, 38, 64
- Quartile method: Linear interpolation (R-7, Excel QUARTILE.INC)
- **Count n: 18**
- **Sum: 480**
- **Mean: 26.666667**
- **Median: 24.5**
- **Mode: 22 (occurs 2 times)**
- **Sample variance s²: 136.588235**
- **Sample standard deviation s: 11.687097**
- **Population variance σ²: 129**
- **Standard error of the mean: 2.754675**
- **First quartile Q1: 19.5**
- **Third quartile Q3: 30.5**
- **Interquartile range: 11**
- **Outliers: 64 — outside the 1.5·IQR fences 3 and 47**
- **Skewness (G1): 1.959304**
- **Excess kurtosis (G2): 5.600893**
- **Coefficient of variation: 43.83%**
- Checked against: Python 3.8 statistics (mean, median, multimode, variance, pvariance, quantiles method='inclusive') and fractions for G1/G2 (Excel SKEW/KURT formulas) with decimal square roots

### NIST StRD NumAcc1

- Data: 10000001, 10000003, 10000002
- Quartile method: Linear interpolation (R-7, Excel QUARTILE.INC)
- **Mean: 10,000,002**
- **Sample standard deviation s: 1**
- **Median: 10,000,002**
- **Skewness (G1): 0**
- Checked against: NIST StRD NumAcc1 certified values: mean 10000002, standard deviation 1

### NIST StRD NumAcc3 (1001 values near 10⁶)

- Data: 1000000.2 1000000.1 1000000.3 1000000.1 1000000.3 1000000.1 1000000.3 1000000…
- Quartile method: Linear interpolation (R-7, Excel QUARTILE.INC)
- **Count n: 1,001**
- **Mean: 1,000,000.2**
- **Sample standard deviation s: 0.1**
- **Median: 1,000,000.2**
- **Excess kurtosis (G2): -2.003003**
- Checked against: NIST StRD NumAcc3 certified values: mean 1000000.2, standard deviation 0.1; confirmed exactly with Python fractions (G2 = −667/333)

### Exclusive quartiles (R-6)

- Data: 7, 15, 36, 39, 40, 41
- Quartile method: Exclusive (R-6, Excel QUARTILE.EXC, Minitab)
- **First quartile Q1: 13**
- **Third quartile Q3: 40.25**
- **Median: 37.5**
- **Interquartile range: 27.25**
- Checked against: Python statistics.quantiles([7, 15, 36, 39, 40, 41], n=4) (method='exclusive' = R-6) → [13.0, 37.5, 40.25]

### Tukey's hinges, odd n

- Data: 6, 47, 49, 15, 42, 41, 7, 39, 43, 40, 36
- Quartile method: Tukey's hinges
- **First quartile Q1: 25.5**
- **Median: 40**
- **Third quartile Q3: 42.5**
- **Mode: No mode — every value occurs once**
- Checked against: Hand computation: sorted 6 7 15 36 39 40 41 42 43 47 49; lower half (with median) 6 7 15 36 39 40 → 25.5, upper half 40 41 42 43 47 49 → 42.5

### Bimodal data with a repeated value

- Data: 2, 3, 3, 5, 5, 8
- Quartile method: Linear interpolation (R-7, Excel QUARTILE.INC)
- **Mode: 3, 5 (each occurs 2 times)**
- **Mean: 4.333333**
- **Sample variance s²: 4.666667**
- **Skewness (G1): 0.965498**
- **Excess kurtosis (G2): 0.728571**
- Checked against: Python statistics.multimode → [3, 5]; statistics.variance = 14/3; G1 and G2 (= 51/70) with fractions and decimal square roots

## Questions

### What is the difference between sample and population standard deviation?

The sample standard deviation divides the sum of squared deviations by n − 1 (Bessel's correction), the population one by n. Deviations measured from the sample mean run slightly small, and n − 1 compensates when estimating a larger population's spread. For the 18 default values s = 11.687 and σ = 11.358, and the gap shrinks as n grows. Excel's STDEV.S and STDEV.P follow the same split.

### How are outliers identified?

By Tukey's rule: a value is an outlier if it lies below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR. For the default data Q1 = 19.5 and Q3 = 30.5, so the IQR is 11, the fences are 3 and 47, and the 64 is flagged. Values beyond 3 × IQR are often called extreme outliers. A flagged value is a prompt to check the data, not a reason to delete it.

### Why do quartiles differ between Excel, calculators and textbooks?

Hyndman and Fan (1996) list nine published definitions. Excel QUARTILE.INC and R's default interpolate at position (n − 1)p + 1, QUARTILE.EXC and Minitab use (n + 1)p, and many textbooks use Tukey's hinges, the medians of each half. For 7, 15, 36, 39, 40, 41 these give Q1 and Q3 of 20.25 and 39.75, 13 and 40.25, and 15 and 40.

### What do skewness and kurtosis values mean?

Skewness measures asymmetry: 0 for symmetric data, positive when the long tail is on the high side. Bulmer's (1979) rule of thumb reads |G1| below 0.5 as roughly symmetric, 0.5 to 1 as moderately skewed and above 1 as highly skewed. Excess kurtosis compares tail weight with a normal distribution, which scores 0. The default data give G1 = 1.96 and G2 = 5.60, both driven by the 64-minute trip.

### When should I use the median instead of the mean?

When the data are skewed or contain outliers, because one extreme value moves the mean but not the median. In the default data the 64-minute trip lifts the mean to 26.67 while the median is 24.5; without that trip the mean would be 24.47 and the median 24. Incomes and house prices are usually reported as medians for the same reason.

### How accurate is the descriptive statistics calculator?

Accuracy depends on your inputs and the method's assumptions. Decimal arithmetic uses 50 significant digits, but estimates, numerical methods and source data can be less precise; the displayed rounding does not remove those limits. It is checked against 7 worked examples whose answers come from independent sources; for example, “Commute times (default data)” is checked against Python 3.8 statistics (mean, median, multimode, variance, pvariance, quantiles method='inclusive') and fractions for G1/G2 (Excel SKEW/KURT formulas) with decimal square roots.

### Where does the method come from?

NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5 Quantitative techniques (location, scale, skewness and kurtosis); NIST Statistical Reference Datasets — univariate summary statistics (NumAcc1–4); Hyndman & Fan (1996), Sample quantiles in statistical packages, The American Statistician 50(4); Microsoft Excel SKEW and KURT functions.

## Sources

- [NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5 Quantitative techniques (location, scale, skewness and kurtosis)](https://www.itl.nist.gov/div898/handbook/eda/section3/eda35.htm)
- [NIST Statistical Reference Datasets — univariate summary statistics (NumAcc1–4)](https://www.itl.nist.gov/div898/strd/univ/homepage.html)
- Hyndman & Fan (1996), Sample quantiles in statistical packages, The American Statistician 50(4)
- [Microsoft Excel SKEW and KURT functions](https://support.microsoft.com/office/skew-function-bdf49d86-b1ef-4804-a046-28eaea69c9fa)
