Standard deviation calculator

Paste your numbers. You get the sample SD (divide by n − 1) and the population SD (divide by n), with every step.

Type or paste numbers separated by spaces, commas or new lines. The table lists each deviation from the mean and its square; the steps show the sum, the two divisors and the square roots.

How it is calculated

Take the numbers 2, 4, 4, 4, 5, 5, 7 and 9, the calculator’s starting example. Their mean is 40/8 = 5. The deviations from the mean are −3, −1, −1, −1, 0, 0, 2 and 4; their squares add to 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32. Then the two standard deviations part company at a single step, the divisor:

s = √( Σ(xi − x)² ⁄ (n − 1) ) = √(32 ⁄ 7) = 2.138,    σ = √( Σ(xi − μ)² ⁄ N ) = √(32 ⁄ 8) = 2(1)

The square root returns the answer to the units of the data: if the numbers are minutes, both standard deviations are in minutes, and the variances (4.571 and 4) are in minutes squared[1]. established

Sample or population: which one do you want?

Use the sample standard deviation s (divide by n − 1) when your numbers are a sample and you want to estimate the spread of the larger group they came from. That is almost always the case: a batch of measurements, a survey, the results of an experiment. Spreadsheet functions STDEV.S and the older STDEV compute it.

Use the population standard deviation σ (divide by n) when your numbers are the whole group and you only want to describe them: the heights of every player on one team, this year’s monthly sales. Spreadsheets call it STDEV.P. The two differ by the factor √(n/(n − 1)), which is 6.9 % for 8 values and under 1 % beyond 50.

Why n − 1? The deviations are measured from the sample’s own mean, which sits closer to the sample’s values than the true mean does, so dividing by n comes out too small on average. Dividing by n − 1 corrects that exactly for the variance. The n − 1 experiment lets you watch the two rules over thousands of samples.

Assumptions and precision

  • Numbers can be separated by spaces, commas, semicolons or new lines. A comma is always a separator, never a decimal mark. Anything that is not a finite number is listed and ignored: text, and values too large for a browser to hold, such as 1e400.
  • The arithmetic uses the corrected two-pass algorithm[2], so values with a large common offset (1,000,000.1, 1,000,000.3, …) give the same answer as the small numbers they differ by.
  • Results are rounded half-up for display, to four more decimals than your data have (at most eight), or to five significant figures when that shows more. The table uses three more decimals (at most seven) or four significant figures. Trailing zeros are dropped, and numbers smaller than 0.000001 are written in scientific notation to the same significant figures, numbers from 1012 up to twelve. No number is ever shown to more than twelve significant figures. Data whose deviations from the mean pass about 10154 cannot be squared in a browser and are refused with a message. The table shows the first 400 rows; the totals use every value.
  • The standard error s/√n is shown too. It measures how much the mean would vary from sample to sample, not how spread out the values are.

Worked examples

  1. A small sample. 2, 4, 4, 4, 5, 5, 7, 9: mean 5, s = 2.138, σ = 2.
  2. Shifting and scaling. Press “Add 10 to each”: the mean becomes 15 and both standard deviations stay the same, because every distance from the mean is unchanged. Press “Double each”: both standard deviations double.
  3. One value. With a single number, σ = 0 and s is undefined: there is no spread to estimate, and n − 1 = 0.

Sources

  1. NIST/SEMATECH (2012). NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale. National Institute of Standards and Technology. standard
  2. Chan, T. F., Golub, G. H. & LeVeque, R. J. (1983). Algorithms for computing the sample variance: analysis and recommendations. The American Statistician 37(3), 242–247. doi:10.1080/00031305.1983.10483115. primary