Standard Deviation: Formula, Sample vs Population, Example

Last updated on by Editorial Staff
Standard deviation: the sample formula, s equals the square root of the sum of squared deviations over n minus 1, above two bell curves with the same mean, one narrow (small s) and one wide (large s)

Standard deviation measures how far the values in a data set typically sit from their mean, in the same units as the data. Square each value’s distance from the mean, add the squares, divide by n − 1 for a sample or by N for a whole population, then take the square root.

A small standard deviation means the values cluster near the mean; a large one means they are spread out. Two data sets can share a mean and still differ a lot in spread, which is why the mean on its own rarely tells you enough.

Try it on your own numbers: our standard deviation calculator returns both the sample and the population result

What is the standard deviation?

It is the typical distance between a value and the mean of its data set. NIST’s Engineering Statistics Handbook calls the variance “roughly the arithmetic average of the squared distance from the mean” and the standard deviation its square root, which “restores the units of the spread to the original data units (the variance squares the units).” Measure spending in dollars and the standard deviation is in dollars; the variance is in dollars squared.

The Greek letter σ is used for a population and the Latin s for a sample. Python’s statistics module follows the same split: its sample function takes the sample mean as xbar and its population function takes the population mean as mu.

SymbolWhat it stands for
σ (sigma)Population standard deviation
sSample standard deviation
μ (mu)Population mean
x (x-bar)Sample mean
N, nNumber of values in the population, in the sample
σ2, s2Population variance, sample variance
Common notation. Texts vary: NIST’s handbook writes the sample formula with Y and N.

What is the standard deviation formula?

There are two versions, and they differ only in what you divide by.

Sample standard deviation formula: s equals the square root of the sum of squared deviations from the sample mean x-bar, divided by n minus 1, with each symbol defined
Sample formula: divide by n − 1.

Sample: s = √[ Σ(xi − x)2 / (n − 1) ]

Population standard deviation formula: sigma equals the square root of the sum of squared deviations from the population mean mu, divided by N, with each symbol defined
Population formula: divide by N.

Population: σ = √[ Σ(xi − μ)2 / N ]

Sample or population: which formula should you use?

Use the population formula only when your data hold every member of the group you care about. Use the sample formula when the data stand in for a larger group, which is the usual case. Microsoft’s documentation for STDEV.S draws the same line: the function “assumes that its arguments are a sample of the population. If your data represents the entire population, then compute the standard deviation using STDEV.P.”

Why divide by n − 1?

The sample mean is worked out from the same numbers, so the squared distances to it come out a little too small on average. NumPy’s documentation says the N − 1 divisor “corrects for bias (toward lower values) in the variance estimate” that comes from using the sample mean in place of the true mean of the population. The usual name for it is Bessel’s correction.

The correction matters most when samples are small. With five values it multiplies the variance by 5/4 and the standard deviation by about 1.118 (our calculation). With thousands of values it barely moves the result: Microsoft notes that “for large sample sizes, STDEV.S and STDEV.P return approximately equal values.”

How do we calculate standard deviation?

  1. Find the mean. Add the values and divide by how many there are.
  2. Subtract the mean from each value. These differences are the deviations; some are negative.
  3. Square each deviation. Every term turns positive and big gaps count for more: in NIST’s words, “a point 2 units from the mean adds 4 to the above sum while a point 10 units from the mean adds 100 to the sum.”
  4. Add the squared deviations.
  5. Divide by n − 1 for a sample, or by N for a population. The result is the variance.
  6. Take the square root. That is the standard deviation.
Six-step infographic: find the mean (14), subtract it from each value (-4, -9, 6, 1, 6), square the deviations, add them (170), divide by 4 for a sample (42.5) or 5 for a population (34), and take the square root (6.52 or 5.83)
The six steps worked on the example below.

Calculation example

Someone writes down what they spend on eating out over five working days and wants to know how much it swings from day to day. Those five days stand in for their habits in general, so the sample formula fits. The population figure is shown as well: it is the right one if you only want to describe this one week.

DaySpent ($)x − x(x − x)2
Monday10−416
Tuesday5−981
Wednesday20636
Thursday1511
Friday20636
Total700170
Illustrative figures; our calculation. Deviations always sum to zero, which is why they are squared.
Calculation table for the example: each day's spending of 10, 5, 20, 15 and 20 dollars, its deviation from the mean of 14, and the squared deviation
The same calculation as an image.
  • Mean: 70 ÷ 5 = $14.
  • Sum of squared deviations: 170.
  • Sample variance: 170 ÷ 4 = 42.5 dollars squared. Sample standard deviation: s = √42.5 = $6.52.
  • Population variance: 170 ÷ 5 = 34 dollars squared. Population standard deviation: σ = √34 = $5.83.
Dot plot of five days of spending, 5, 10, 15, 20 and 20 dollars, with the mean of 14 marked and a green band from 7.48 to 20.52 that covers four of the five days
Four of the five days fall within one sample standard deviation of the mean.

How to read it: on a typical day this person spends about $6.50 more or less than $14. Four of the five days land between $7.48 and $20.52; only Tuesday falls outside. Do not look for the 68% figure here: that rule describes a normal distribution, and five numbers are far too few to show a shape.

Standard deviation in Excel, Google Sheets, Python, R and the TI-84

Each tool below can give you either version, though R needs a one-line rescale for the population figure. They do not agree on which one you get by default, and that alone can give two people different answers from the same numbers.

ToolSample (n − 1)Population (N)
ExcelSTDEV.SSTDEV.P
Google SheetsSTDEV or STDEV.SSTDEVP or STDEV.P
Python statisticsstdev()pstdev()
NumPystd(x, ddof=1)std(x), the default
pandas.std(), the default.std(ddof=0)
Rsd(x)sd(x) × √((n − 1)/n)
TI-84 PlusSxσx
Checked 13 October 2026 against each vendor’s documentation. The R population line is our rescaling.

The trap is NumPy against pandas. We ran the five days above on 13 October 2026: numpy.std() (NumPy 2.4.6) returned 5.8310 and pandas.Series.std() (pandas 3.0.6) returned 6.5192. NumPy’s docs say “By default ddof is zero”, so numpy.std divides by N, while pandas is “Normalized by N-1 by default.” Python’s own statistics.stdev and pstdev returned the same 6.5192 and 5.8310. If a notebook and a spreadsheet disagree, check the divisor first.

  • Excel: STDEV.S uses “the ‘n-1’ method” and STDEV.P “the ‘n’ method”. The older STDEV still works but is kept “for backward compatibility”.
  • Google Sheets: STDEV “calculates the standard deviation based on a sample”; STDEVP uses the entire population. The function list maps STDEV.S and STDEV.P onto them, so Excel formulas carry over.
  • R: sd() “uses denominator n – 1”.
  • TI-84 Plus: Texas Instruments explains that the population figure, “denoted by σx, divides the calculated values by n”, and the sample figure, “denoted by Sx, uses the value n-1 as the denominator”. Both are filled in when you run a 1-Var Stats analysis.
  • Our standard deviation calculator has one button for each version.

What does variance mean?

Variance is the spread before the square root: the sum of squared deviations divided by n − 1 (sample, s2) or N (population, σ2). In the example it is 42.5 or 34, in dollars squared. Because the deviations are squared, NIST warns that the variance “can be greatly affected by the tail behavior”: one far-out value can dominate it.

Difference between standard deviation and variance

Standard deviationVariance
UnitsSame as the data ($)Squared ($2)
RelationshipSquare root of varianceStandard deviation squared
Example (sample)$6.5242.5
Best forDescribing spreadCombining spreads

Variance earns its place in the algebra: for independent quantities, variances add while standard deviations do not. MIT’s Mathematics for Computer Science notes put it as σ(R1 + R2)2 = σ(R1)2 + σ(R2)2 when the two are independent. King’s combined safety stock formula (below) works the same way: when demand and lead-time variability are independent, safety stock is “Z-score times the square root of the sum of the squares of the individual variabilities.”

What does a standard deviation graph show?

Normal distribution curve with bands at one, two and three standard deviations from the mean, labelled 68.27%, 95.45% and 99.73%
Share of a normal distribution within 1, 2 and 3 standard deviations of the mean.

For a normal, bell-shaped distribution the share of values within a given number of standard deviations is fixed: 68.27% within one, 95.45% within two and 99.73% within three. These come from NIST’s standard normal table (areas of 0.34134, 0.47725 and 0.49865 on each side of the mean, doubled). NIST’s control-chart chapter uses the same fact: “the 3σ in one direction is 0.00135, or in both directions 0.0027.”

Those figures hold only for normal data. For any distribution at all, Chebyshev’s inequality gives a floor instead: at most 1/k2 of the values lie k or more standard deviations from the mean (MIT 6.1200J, lecture 24). So at least 75% lie within two standard deviations and at least 88.9% within three (our calculation). Altman and Bland, writing in the BMJ, add that “the standard deviation is a valid measure of variability regardless of the distribution.” They also note: “About 95% of observations of any distribution usually fall within the 2 standard deviation limits, though those outside may all be at one end.”

How do we use standard deviation in different situations?

Quality control: control limits and process capability

Control charts set their limits a fixed number of standard deviations from the center line. NIST: “it is an acceptable practice to base the control limits upon a multiple of the standard deviation. Usually this multiple is 3 and thus the limits are called 3-sigma limits.” The process capability index compares the specification width with six standard deviations: Cp = (USL − LSL) / 6σ. For normally distributed data, NIST’s table translates Cp = 1.00 into 0.27% rejects and Cp = 1.33 into 64 parts per million. More on charts in our guide to statistical process control.

Inventory: sizing safety stock

Peter King’s APICS article on safety stock sums up the demand-driven case: the safety stock needed “simply is the standard deviation of demand variability multiplied by the Z-score”. For a 95% cycle service level that Z-score is 1.65. When the lead time is longer than the period the standard deviation was measured over, it is scaled by the square root of the ratio: weekly data and a three-week lead time means multiplying by √3.

Our calculation with illustrative numbers: weekly demand with a standard deviation of 40 units and a three-week lead time gives 1.65 × 40 × √3 = 114.3, so about 115 units of safety stock. The target inventory level guide works the full formula, including the review period.

Finance: volatility

In investing, volatility is the standard deviation of returns. A fund prospectus filed with the SEC by AQR Funds defines it as “a statistical measurement of the dispersion of returns of a security or fund or index, as measured by the annualized standard deviation of its returns.”

Comparing spreads on different scales

A standard deviation of 25 is large for a mean of 50 and small for a mean of 1,000. To compare, divide by the mean. NIST’s Dataplot manual defines the coefficient of variation as standard deviation / mean, and the relative standard deviation as 100 × (standard deviation / |mean|). Those two series come out at 50% and 2.5%; the spending example at 6.52 / 14 = 46.6% (our calculations).

Standard deviation vs standard error

They answer different questions. Douglas Altman and Martin Bland put it plainly in a BMJ statistics note: “if we want to say how widely scattered some measurements are, we use the standard deviation. If we want to indicate the uncertainty around the estimate of the mean measurement, we quote the standard error of the mean.”

The standard error comes from the standard deviation: “SE = SD/√(sample size)”. For the five days, 6.52 / √5 = 2.92 (our calculation). More data shrinks the standard error. “By contrast the standard deviation will not tend to change as we increase the size of our sample.”

Strengths

  • It is in the data’s own units, so it reads plainly: about $6.50 a day either side of the mean.
  • It uses every value. The range, by contrast, “is based only on the lowest and highest extreme values” (NIST).
  • Variances of independent quantities add, which makes it the building block for control limits and safety stock.
  • Excel, Google Sheets, Python, R and the TI-84 all compute it (see the table above).

Limitations

  • Outliers pull it hard, because deviations are squared. NIST lists the average absolute deviation as “less affected by extreme observations than are the variance and standard deviation”, and the median absolute deviation as even less affected. For the example they are 5.2 and 5 (our calculation).
  • It says nothing about shape. The 68-95-99.7 reading needs normal data; in skewed data the values outside two standard deviations may all sit on one side (BMJ).
  • There are two versions. Always say whether you divided by n − 1 or N: with five values the choice alone changes the answer by about 12%.
  • It describes the data you have. It is not a forecast of the next value.

FAQs

What is the difference between sample and population standard deviation?

The divisor. The sample standard deviation (s) divides the sum of squared deviations by n − 1; the population standard deviation (σ) divides by N. Use σ only when you have every value in the group, and s when the data stand in for a larger group. For the values 10, 5, 20, 15 and 20, s = 6.52 and σ = 5.83.

Is standard deviation the square root of variance?

Yes. Variance is the sum of squared deviations from the mean divided by n − 1 (sample) or N (population), and the standard deviation is its square root, which puts the spread back into the data’s own units. A variance of 42.5 dollars squared is a standard deviation of $6.52.

What does a high standard deviation mean?

That the values are spread widely around the mean; a low one means they cluster close to it. What counts as high depends on the mean and the context, so to compare data sets with different averages, divide the standard deviation by the mean to get the coefficient of variation.

Why do NumPy and pandas give different standard deviations?

Different defaults. numpy.std divides by N unless you pass ddof=1, while pandas Series.std divides by n − 1 unless you pass ddof=0. On the values 10, 5, 20, 15 and 20, NumPy 2.4.6 returned 5.83 and pandas 3.0.6 returned 6.52.

What is the difference between standard deviation and standard error?

Standard deviation describes how scattered individual values are. Standard error describes how precisely a sample mean estimates the population mean. It equals the standard deviation divided by the square root of the sample size, so it shrinks as the sample grows while the standard deviation does not.

Which standard deviation should you report?

Report the sample standard deviation (n − 1) unless your data are the whole group you care about. Label it s or SD, give the number of values, and say which tool or formula produced it, since the defaults differ. If your point is how precise an average is, report the standard error instead. And never join either one to a mean with a bare ± sign: the BMJ asks authors to “indicate clearly whether the standard deviation or standard error is being quoted.”

How we researched this page (checked 13 October 2026). Definitions and formulas come from the NIST/SEMATECH e-Handbook of Statistical Methods. Spreadsheet, code and calculator behavior comes from Microsoft, Google, Python, NumPy, pandas, R and Texas Instruments documentation, and we ran the NumPy, pandas and Python results ourselves. The standard error is from Altman and Bland (BMJ, 2005) and safety stock from King (APICS Magazine, 2011). The worked example uses illustrative figures, and every result marked as ours can be recomputed from the numbers shown. An earlier version of this page reported only the population result ($5.8) while describing the sample method, and called each deviation a ‘variance’; both are corrected, including in the images.

References

  1. NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.6 Measures of Scale
  2. NIST/SEMATECH e-Handbook, 1.3.6.6.1 Normal Distribution
  3. NIST/SEMATECH e-Handbook, 1.3.6.7.1 Cumulative Distribution Function of the Standard Normal Distribution
  4. NIST/SEMATECH e-Handbook, 6.3.1 What are Control Charts?
  5. NIST/SEMATECH e-Handbook, 6.1.6 What is Process Capability?
  6. NIST Dataplot Reference Manual: Coefficient of Variation
  7. NIST Dataplot Reference Manual: Relative Standard Deviation
  8. Microsoft Support: STDEV.S function
  9. Microsoft Support: STDEV.P function
  10. Microsoft Support: STDEV function
  11. Google Docs Editors Help: STDEV
  12. Google Docs Editors Help: STDEVP
  13. Google Docs Editors Help: Google Sheets function list
  14. Python documentation: statistics, Mathematical statistics functions
  15. NumPy manual: numpy.std
  16. pandas documentation: pandas.Series.std
  17. R documentation: sd {stats}
  18. Texas Instruments: Calculating variance on the TI-84 Plus family (Solution 34473)
  19. Altman DG, Bland JM. Standard deviations and standard errors. BMJ 2005;331:903
  20. King PL. Crack the Code: Understanding safety stock and mastering its equations. APICS Magazine, July/August 2011
  21. MIT OpenCourseWare 6.1200J (Spring 2024), Lecture 24: Large Deviations: Chebyshev and Chernoff Bound
  22. AQR Funds prospectus, SEC filing (prospectus date 1 May 2022)

Using Google Search? Add erp-information.com as a preferred source.