How to Calculate Standard Deviation: Step-by-Step With Worked Examples
The population and sample formulas explained clearly, with full worked examples, the empirical rule, and real-world applications.
Skip the manual calculation
Enter your dataset into our Standard Deviation Calculator to instantly compute the mean, variance, and standard deviation with step-by-step workings.
Calculate Standard DeviationWhat Is Standard Deviation?
Standard deviation is a measure of how spread out numbers are from their average (mean) value. A low standard deviation means data points cluster closely around the mean, while a high standard deviation means they are dispersed over a wider range.
Introduced by English statistician Karl Pearson in 1894, standard deviation (represented by the Greek letter sigma for populations and the letter "s" for samples) has become the most widely used measure of statistical dispersion. It is fundamental to virtually every field that uses data: the National Institute of Standards and Technology (NIST) maintains reference datasets specifically for validating standard deviation calculations in scientific software.
In practical terms, standard deviation answers the question: "How much do individual measurements typically differ from the average?" If the average test score in a class is 75 and the standard deviation is 10, most scores fall between 65 and 85. If the standard deviation is 3, most scores cluster between 72 and 78. The concept appears everywhere -- from quality control in manufacturing (Six Sigma methodology) to investment risk analysis (portfolio volatility) to medical research (clinical trial endpoints).
The Standard Deviation Formula
There are two versions of the formula depending on whether you are working with an entire population or a sample drawn from a larger population.
Population Standard Deviation (sigma)
sigma = sqrt[ (1/N) x SUM(xi - mu)2 ]
Sample Standard Deviation (s)
s = sqrt[ (1/(n-1)) x SUM(xi - x-bar)2 ]
N = population size; n = sample size
xi = each individual data point
mu = population mean; x-bar = sample mean
SUM = sum across all data points
The only difference between the two formulas is the denominator: N for population, n-1 for sample. The n-1 adjustment (called Bessel's correction) compensates for the fact that a sample's mean is always slightly closer to the sample's data points than the true population mean would be, which would otherwise cause the standard deviation to be systematically underestimated.
Step-by-Step Calculation: Worked Example
Let us calculate the sample standard deviation for this dataset of five test scores: 72, 85, 90, 68, 95.
Step 1: Find the mean (average).
Mean = (72 + 85 + 90 + 68 + 95) / 5 = 410 / 5 = 82
Step 2: Subtract the mean from each data point (find deviations).
| Data Point (xi) | Deviation (xi - mean) | Squared Deviation |
|---|---|---|
| 72 | 72 - 82 = -10 | 100 |
| 85 | 85 - 82 = 3 | 9 |
| 90 | 90 - 82 = 8 | 64 |
| 68 | 68 - 82 = -14 | 196 |
| 95 | 95 - 82 = 13 | 169 |
Step 3: Sum the squared deviations.
Sum = 100 + 9 + 64 + 196 + 169 = 538
Step 4: Divide by n-1 (for sample) to get the variance.
Variance = 538 / (5 - 1) = 538 / 4 = 134.5
Step 5: Take the square root to get standard deviation.
Standard deviation = sqrt(134.5) = 11.60
This means the test scores typically deviate from the mean of 82 by about 11.6 points. You can verify this calculation instantly with our standard deviation calculator, which shows each step.
Population vs. Sample: When to Use Which
Choosing the correct formula depends on whether your dataset represents the complete group of interest or a subset of it.
| Use Population SD When... | Use Sample SD When... |
|---|---|
| You have data for every member of the group | You have a subset and want to estimate the whole |
| All 30 students in a class took the exam | You surveyed 100 of 10,000 customers |
| Every transaction in a company's database | A random sample of patient records |
| Census data (entire country measured) | Poll data (subset of voters sampled) |
In practice, sample standard deviation is used far more frequently because it is rare to have data for an entire population. When in doubt, use sample standard deviation (dividing by n-1). For large datasets (n greater than 30), the difference between the two formulas becomes negligible -- for n=100, the population SD is only about 0.5% lower than the sample SD.
The Empirical Rule (68-95-99.7)
For data that follows a normal (bell-shaped) distribution, standard deviation has a powerful interpretive property known as the empirical rule or the 68-95-99.7 rule.
- 68% of data falls within 1 standard deviation of the mean (mean +/- 1 SD)
- 95% of data falls within 2 standard deviations (mean +/- 2 SD)
- 99.7% of data falls within 3 standard deviations (mean +/- 3 SD)
Example: Adult male height in the U.S. has a mean of approximately 69.1 inches (5 feet 9 inches) with a standard deviation of 2.9 inches, according to CDC anthropometric data. Applying the empirical rule:
- 68% of men are between 66.2 and 72.0 inches (5'6" to 6'0")
- 95% of men are between 63.3 and 74.9 inches (5'3" to 6'3")
- 99.7% of men are between 60.4 and 77.8 inches (5'0" to 6'6")
Any value more than 3 standard deviations from the mean is considered an extreme outlier, occurring less than 0.3% of the time. This principle is the foundation of Six Sigma quality control, which aims for defect rates below 3.4 per million opportunities (equivalent to being more than 6 standard deviations from the mean). Use our z-score calculator to determine how many standard deviations a specific value is from the mean.
Key Terms You Should Know
Standard deviation is closely related to several other statistical measures. Understanding these connections helps you choose the right tool for your analysis.
- Variance: The square of the standard deviation. Variance (sigma-squared for populations, s-squared for samples) is mathematically simpler to work with in formulas but harder to interpret because it is in squared units. If heights are measured in inches, variance is in square inches. Standard deviation converts back to the original units by taking the square root.
- Mean (average): The central value around which standard deviation measures spread. Calculated by summing all values and dividing by the count. Our mean, median, mode calculator computes all three measures of central tendency.
- Z-score: The number of standard deviations a specific data point is from the mean. Calculated as z = (x - mean) / SD. A z-score of 2.0 means the value is 2 standard deviations above the mean. Z-scores allow comparison across different datasets and scales.
- Standard error: The standard deviation of a sampling distribution, calculated as SD / sqrt(n). It measures how much a sample mean is likely to vary from the true population mean. Smaller standard errors indicate more precise estimates.
- Coefficient of variation (CV): Standard deviation expressed as a percentage of the mean (CV = SD/mean x 100%). Allows comparison of variability between datasets with different scales or units. A salary dataset with CV of 25% has more relative spread than one with CV of 10%.
Real-World Applications
Standard deviation is not just an academic exercise -- it drives decisions worth billions of dollars across multiple industries.
- Finance and investing: Standard deviation of returns is the primary measure of investment risk. The S&P 500's historical annualized standard deviation is approximately 15%, meaning annual returns typically range from about -5% to +25% (one SD from the long-term average of ~10%). Portfolio managers use standard deviation to construct diversified portfolios that minimize risk for a given return target. According to Morningstar, funds with higher standard deviations have experienced steeper drawdowns during market downturns.
- Manufacturing quality control: The Six Sigma methodology, developed at Motorola and popularized by GE, uses standard deviation to define acceptable quality levels. A "six sigma" process produces fewer than 3.4 defects per million units -- meaning the process is controlled to within 6 standard deviations of the target.
- Scientific research: Standard deviation is used to calculate confidence intervals and p-values. In medical research, a treatment is considered statistically significant if the effect exceeds approximately 2 standard errors (p less than 0.05). In particle physics, the discovery standard is 5 sigma -- the Higgs boson was confirmed in 2012 when CERN detected it at 5.9 sigma.
- Weather forecasting: Temperature variability at a location is expressed using standard deviation. A city with an average January high of 35 degrees F and SD of 5 degrees has predictable winters, while one with SD of 15 degrees has wildly variable conditions. Use our probability calculator for related statistical computations.
Second Worked Example: Investment Returns
Let us calculate the population standard deviation for five years of annual returns for a mutual fund: 12%, -5%, 18%, 7%, 3%.
Step 1: Mean = (12 + (-5) + 18 + 7 + 3) / 5 = 35 / 5 = 7%
| Year Return | Deviation | Squared Deviation |
|---|---|---|
| 12% | 12 - 7 = 5 | 25 |
| -5% | -5 - 7 = -12 | 144 |
| 18% | 18 - 7 = 11 | 121 |
| 7% | 7 - 7 = 0 | 0 |
| 3% | 3 - 7 = -4 | 16 |
Step 2: Sum of squared deviations = 25 + 144 + 121 + 0 + 16 = 306
Step 3: Variance = 306 / 5 = 61.2 (population, since these are all 5 years of the fund's existence)
Step 4: Standard deviation = sqrt(61.2) = 7.82%
This fund has an average return of 7% with a standard deviation of 7.82%. Applying the empirical rule, about 68% of future annual returns would be expected to fall between -0.82% and 14.82% (assuming returns are normally distributed). This level of volatility is moderate -- slightly below the S&P 500's historical standard deviation of approximately 15%. For portfolio analysis, you can use our correlation calculator to measure how different investments move relative to each other.
Common Mistakes to Avoid
Even experienced analysts make errors with standard deviation. Watch out for these pitfalls.
- Using the wrong formula: The most common error is using population SD (dividing by N) when sample SD (dividing by N-1) is appropriate. For small samples, this matters significantly. With n=5, the sample SD is about 12% larger than the population SD.
- Confusing standard deviation with variance: Variance is the standard deviation squared. If a report says "variance is 25," the standard deviation is 5, not 25. Always check which measure is being reported.
- Applying the empirical rule to non-normal data: The 68-95-99.7 rule only works for approximately normally distributed data. Skewed distributions (like income or home prices) require different approaches like Chebyshev's theorem, which guarantees at least 75% of data within 2 SD regardless of distribution shape.
- Comparing SDs across different scales: A standard deviation of 5 means very different things for a dataset with mean 10 versus mean 10,000. Use the coefficient of variation (SD/mean) to compare variability across different scales.
- Ignoring outliers: Standard deviation is sensitive to extreme values because deviations are squared. A single outlier can dramatically inflate the result. Always examine your data for outliers before interpreting the SD.
Frequently Asked Questions About Standard Deviation
What is the difference between population and sample standard deviation?
Population standard deviation (sigma) measures the spread of an entire population, while sample standard deviation (s) estimates the spread of a population based on a subset of data. The key mathematical difference is in the denominator: population standard deviation divides by N (total population size), while sample standard deviation divides by N-1 (sample size minus one). This N-1 correction, known as Bessel's correction, compensates for the fact that a sample tends to underestimate the true population variability. For example, if you measured the heights of all 500 students in a school, you would use population standard deviation (N=500). If you measured 50 randomly selected students to estimate the variation for the whole school, you would use sample standard deviation (N-1=49). The difference between the two values becomes negligible for large samples (N greater than 30).
What does a high standard deviation mean?
A high standard deviation means that data points are spread widely around the mean, indicating greater variability or dispersion in the dataset. Whether a standard deviation is "high" depends on the context and scale of the data. For example, a standard deviation of 10 is very high for exam scores on a 100-point test (meaning scores vary widely), but low for home prices in a city where the mean is $400,000. The coefficient of variation (CV = standard deviation / mean x 100%) provides a scale-independent measure: a CV below 15% generally indicates low variability, 15-30% moderate variability, and above 30% high variability. In finance, a high standard deviation in investment returns means higher risk and more volatile performance -- according to Morningstar, the S&P 500's historical annualized standard deviation is about 15%, while individual stocks can exceed 40%.
How do you calculate standard deviation in Excel?
Excel provides built-in functions for both types of standard deviation. For sample standard deviation, use =STDEV.S(range) or the older =STDEV(range). For population standard deviation, use =STDEV.P(range) or the older =STDEVP(range). For example, if your data is in cells A1 through A20, type =STDEV.S(A1:A20) for the sample standard deviation. Excel also offers STDEV.S for ignoring text and logical values, and STDEVA for including them (treating TRUE as 1 and FALSE as 0). Google Sheets uses the same function names. In Python, use numpy.std(data, ddof=0) for population or numpy.std(data, ddof=1) for sample. In R, the sd() function calculates sample standard deviation by default. For quick calculations without software, use our standard deviation calculator which shows each step.
What is the empirical rule (68-95-99.7 rule)?
The empirical rule, also called the 68-95-99.7 rule, states that for a normal (bell-shaped) distribution, approximately 68% of data falls within one standard deviation of the mean, 95% within two standard deviations, and 99.7% within three standard deviations. For example, if exam scores have a mean of 75 and a standard deviation of 10, then about 68% of students scored between 65 and 85, about 95% scored between 55 and 95, and about 99.7% scored between 45 and 105. This rule, first described by Abraham de Moivre in 1733, is fundamental to quality control (Six Sigma uses 6 standard deviations), scientific research (2-sigma results suggest evidence, 5-sigma confirms a discovery in physics), and finance (Value at Risk calculations). The rule only applies to approximately normal distributions -- for skewed data, use Chebyshev's inequality instead.
Why do we square the differences when calculating standard deviation?
We square the differences (deviations from the mean) for three mathematical and practical reasons. First, squaring eliminates negative signs -- without squaring, positive and negative deviations would cancel each other out, always summing to zero, which would tell us nothing about spread. Second, squaring gives more weight to larger deviations, making standard deviation sensitive to outliers (a desirable property in many applications like quality control). Third, squared deviations have useful mathematical properties: variance (the square of standard deviation) is additive for independent random variables, which is essential in probability theory and statistical inference. An alternative approach, mean absolute deviation (MAD), uses absolute values instead of squares and is less sensitive to outliers. However, standard deviation remains preferred because of its mathematical tractability and its direct connection to the normal distribution and central limit theorem.
What is a good standard deviation for test scores?
A typical standard deviation for classroom test scores is 10 to 15 points on a 100-point scale. A standard deviation below 10 suggests the test did not adequately differentiate between students (scores were clustered tightly), while a standard deviation above 20 may indicate the test was too inconsistent or the class had extremely varied preparation levels. Standardized tests are specifically designed to produce predictable standard deviations: the SAT has a standard deviation of approximately 200 points per section (mean 500, range 200-800), the ACT has a standard deviation of about 5.7 (mean around 20.6, range 1-36), and IQ tests are calibrated to a mean of 100 with a standard deviation of 15 according to the Wechsler scale. In educational measurement, the standard error of measurement (SEM) -- which uses standard deviation -- helps determine whether the difference between two scores is statistically meaningful.
Compute Statistics Instantly
Use our free math and statistics calculators: