How to calculate the standard deviation of a sample

The sample standard deviation measures the dispersion of a dataset relative to its mean by taking the square root of the sample variance. It applies when your data represents a subset of a larger population, requiring Bessel's correction (n1n-1) to provide an unbiased estimate of the population variance.

The setup

Identify your sample dataset containing nn independent observations, denoted as x1,x2,,xnx_1, x_2, \dots, x_n. You will use the sample standard deviation formula: s=(xixˉ)2n1s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}}.

The steps

  1. Calculate the sample mean (xˉ\bar{x}) by summing all data points and dividing by nn. 2. Subtract the mean from each data point to find the deviations (xixˉx_i - \bar{x}). 3. Square each deviation to ensure positive values ((xixˉ)2(x_i - \bar{x})^2). 4. Sum all the squared deviations ((xixˉ)2\sum (x_i - \bar{x})^2). 5. Divide the sum by n1n - 1 to find the sample variance (s2s^2). 6. Take the square root of the variance to find the sample standard deviation (ss).

Checking the result

The standard deviation must be non-negative (s0s \ge 0). It equals zero if and only if all data points are identical. The units of the standard deviation must match the units of the original data.

Common errors

Dividing by nn instead of n1n-1 calculates the population standard deviation rather than the sample standard deviation. Rounding intermediate values prematurely can lead to significant propagation of error in the final result.

Worked example

Calculate the sample standard deviation for the dataset: 4, 8, 6, 5, 3.

Step 1: n=5n = 5. Mean xˉ=4+8+6+5+35=265=5.2\bar{x} = \frac{4 + 8 + 6 + 5 + 3}{5} = \frac{26}{5} = 5.2. Step 2 & 3: Compute squared deviations: (45.2)2=(1.2)2=1.44(4 - 5.2)^2 = (-1.2)^2 = 1.44; (85.2)2=(2.8)2=7.84(8 - 5.2)^2 = (2.8)^2 = 7.84; (65.2)2=(0.8)2=0.64(6 - 5.2)^2 = (0.8)^2 = 0.64; (55.2)2=(0.2)2=0.04(5 - 5.2)^2 = (-0.2)^2 = 0.04; (35.2)2=(2.2)2=4.84(3 - 5.2)^2 = (-2.2)^2 = 4.84. Step 4: Sum squared deviations = 1.44+7.84+0.64+0.04+4.84=14.81.44 + 7.84 + 0.64 + 0.04 + 4.84 = 14.8. Step 5: Divide by n1=4n-1 = 4 to get variance s2=14.84=3.7s^2 = \frac{14.8}{4} = 3.7. Step 6: Standard deviation s=3.71.9235s = \sqrt{3.7} \approx 1.9235.

FAQ

Run your own problem

References: OpenStax Introductory Statistics, Chapter 2 · Khan Academy: Summarizing quantitative data

See also