Standard Deviation and Variance for Data Analysts, With Worked Examples

7 min read

Standard deviation measures how far values typically sit from their average. Variance is the same idea before the final step: the average of the squared distances from the mean. Standard deviation is the square root of variance, which puts it back in the original units, so it is the number you report and variance is the number you calculate on the way.

A small standard deviation means the values cluster tightly around the mean. A large one means they are spread out, and the average alone is hiding a lot. In Excel, use =STDEV.S() for a sample and =STDEV.P() for a full population; in SQL, STDDEV_SAMP and STDDEV_POP do the same jobs.

The formulas, in plain words

There are two versions of each measure. The only difference is the number you divide by, and the rest of this lesson explains when that matters.

Measure Formula in words Divide by
Population variance sum of (each value minus the mean) squared, divided by n n, the number of values
Sample variance sum of (each value minus the mean) squared, divided by (n minus 1) n minus 1
Population standard deviation square root of the population variance n
Sample standard deviation square root of the sample variance n minus 1

Written as one line: standard deviation = square root of (sum of (x minus mean) squared divided by n), with n replaced by n minus 1 when your data is a sample.

A worked example: two outlets with the same average

One scenario runs through this lesson. A Bengaluru cloud kitchen has two outlets, one in Koramangala and one in Whitefield. Over the same six days, both took exactly 120 orders a day on average. The operations manager wants to know whether they need the same staffing and stock plan.

Here are the daily orders.

Day Koramangala orders Whitefield orders
Monday 118 90
Tuesday 122 150
Wednesday 125 135
Thursday 120 105
Friday 119 140
Saturday 116 100
Average 120 120

Same mean, very different weeks. Standard deviation turns that difference into a number.

Step by step for Koramangala

Subtract the mean from each day, square the result, and add the squares up.

Day Orders Orders minus mean Squared
Monday 118 -2 4
Tuesday 122 2 4
Wednesday 125 5 25
Thursday 120 0 0
Friday 119 -1 1
Saturday 116 -4 16
Total 720 0 50

The deviations always add up to zero, which is exactly why we square them: without squaring, the ups and downs cancel and you learn nothing. The sum of squares is 50.

Now finish both versions:

Step Population (divide by n = 6) Sample (divide by n minus 1 = 5)
Variance 50 / 6 = 8.33 50 / 5 = 10
Standard deviation square root of 8.33 = 2.89 square root of 10 = 3.16

The same steps for Whitefield

Day Orders Orders minus mean Squared
Monday 90 -30 900
Tuesday 150 30 900
Wednesday 135 15 225
Thursday 105 -15 225
Friday 140 20 400
Saturday 100 -20 400
Total 720 0 3,050
Step Population (divide by 6) Sample (divide by 5)
Variance 3,050 / 6 = 508.33 3,050 / 5 = 610
Standard deviation square root of 508.33 = 22.55 square root of 610 = 24.70

So Koramangala’s daily orders typically sit about 3 away from 120, and Whitefield’s about 25 away. One outlet is predictable; the other swings by a fifth of its volume from one day to the next. The average said they were identical.

Why variance is not the number you report

Look at the units. Orders minus mean is in orders. Squaring it gives “orders squared”, which means nothing to an operations manager. Whitefield’s sample variance of 610 orders squared is correct and useless in a meeting. Its standard deviation of 24.70 orders is something people can act on. Variance earns its place inside other calculations, because variances of independent things add up neatly and standard deviations do not, but it rarely belongs on a slide.

Population or sample: n or n minus 1?

This is the question that trips up most people, in exams and at work.

Use the population version when your data is every value you care about. If the question is “how spread out were the loan sizes across all 42 branches last quarter”, and you have all 42, there is nothing beyond your data to estimate. Divide by n.

Use the sample version when your data stands in for something larger. Six days of orders are not the point; the manager wants to know what a typical day at Whitefield looks like, including days that have not happened yet. Those six days are a sample of the outlet’s behaviour, so divide by n minus 1.

Why the adjustment? A sample’s own mean is, by construction, the point closest to that sample’s values. The true long-run mean is a little further away from them on average. So deviations measured from the sample mean come out slightly too small, and the variance with them. Dividing by a smaller number, n minus 1, nudges the result back up. This is called Bessel’s correction, and interviewers like to hear the name.

In practice, most analyst work is the sample case, because you are almost always using recent data to describe a process that continues. When in doubt, STDEV.S is the safer default.

The gap between the two shrinks fast as data grows. The sample standard deviation is larger than the population one by a factor of the square root of (n divided by (n minus 1)):

Number of values (n) Sample SD is larger by
6 9.5%
30 1.7%
100 0.5%

With six days, the choice changes the answer noticeably. With a year of daily data it barely matters, though you should still be able to say which one you used and why.

Standard deviation in Excel

Excel has a function for each version. Assume the six Whitefield order counts sit in cells B2 to B7.

Function What it does Syntax Example and result
STDEV.S Sample standard deviation =STDEV.S(range) =STDEV.S(B2:B7) returns 24.70
STDEV.P Population standard deviation =STDEV.P(range) =STDEV.P(B2:B7) returns 22.55
VAR.S Sample variance =VAR.S(range) =VAR.S(B2:B7) returns 610
VAR.P Population variance =VAR.P(range) =VAR.P(B2:B7) returns 508.33
AVERAGE Mean, for context =AVERAGE(range) =AVERAGE(B2:B7) returns 120
STDEV Older name for the sample version =STDEV(range) =STDEV(B2:B7) returns 24.70

STDEV and VAR without a suffix still work for backward compatibility and behave like STDEV.S and VAR.S. Use the suffixed versions in new work so a reviewer can see your choice. All of these ignore text and empty cells in a range, so a blank day is dropped rather than counted as zero. That is usually what you want, but if a closed outlet should count as a zero-order day, type the zero in. More Excel functions for analysis are covered in our guide to Excel for data analysis.

Standard deviation in SQL

Every major database calculates standard deviation, but the function names differ, and one common name means opposite things in different databases. The examples assume a table called daily_orders with columns outlet, order_date and orders.

Database Sample SD Population SD Sample variance Population variance
PostgreSQL STDDEV_SAMP(orders) STDDEV_POP(orders) VAR_SAMP(orders) VAR_POP(orders)
MySQL STDDEV_SAMP(orders) STDDEV_POP(orders) VAR_SAMP(orders) VAR_POP(orders)
SQL Server STDEV(orders) STDEVP(orders) VAR(orders) VARP(orders)
Oracle STDDEV_SAMP(orders) STDDEV_POP(orders) VAR_SAMP(orders) VAR_POP(orders)

The trap is the short name. In PostgreSQL and Oracle, STDDEV() is the sample version. In MySQL, STDDEV() and STD() are the population version. A query that moves from one database to another can silently change its answer, so use the explicit _SAMP and _POP names whenever the database supports them.

Here is the query that produces the outlet comparison above, one clause per row.

Clause What it does Example
SELECT Picks the outlet and the three statistics SELECT outlet, AVG(orders) AS avg_orders, STDDEV_SAMP(orders) AS sd_orders, VAR_SAMP(orders) AS var_orders
FROM Names the table FROM daily_orders
WHERE Limits it to the six days WHERE order_date BETWEEN ‘2026-11-02’ AND ‘2026-11-07’
GROUP BY Gives one row per outlet GROUP BY outlet

The result has two rows: Koramangala with 120, 3.16 and 10, and Whitefield with 120, 24.70 and 610.

If you work in Python instead, the same trap exists between libraries. A pandas column’s .std() method returns the sample standard deviation by default, while NumPy’s np.std() returns the population version unless you pass ddof=1. Our Python for data analysis guide covers pandas in more depth.

What standard deviation means in business terms

A standard deviation on its own is just a number. These are the ways analysts turn it into a decision.

Planning ranges

When data is roughly bell-shaped, about 68% of values fall within one standard deviation of the mean and about 95% within two. For Whitefield, that suggests most days land between 120 minus 2 times 24.70 and 120 plus 2 times 24.70, or roughly 71 to 169 orders. For Koramangala the same range is roughly 114 to 126. One outlet can be staffed for a fixed number; the other needs a flexible roster or a stock buffer. Six days is a thin basis for a staffing decision, and a real analysis would use several months, but the logic is the same.

That 68 and 95 rule only holds for data that is roughly symmetric. Order values, salaries and loan sizes are usually skewed by a few very large values, and for those the rule misleads. The normal distribution lesson in this series covers when the rule applies.

Flagging unusual days

The z-score tells you how many standard deviations a value sits from the mean: z = (value minus mean) divided by standard deviation. Suppose next Monday Koramangala takes 135 orders and Whitefield takes 175.

Outlet Orders Mean SD z-score
Koramangala 135 120 3.16 4.74
Whitefield 175 120 24.70 2.23

Whitefield’s day is bigger in raw orders, but Koramangala’s is far more unusual for that outlet. Something changed in Koramangala that day, perhaps a promotion or a listing problem on a delivery app, and it is the outlet worth investigating. A common working rule flags anything beyond two or three standard deviations.

Comparing spread across different scales

Standard deviation is in the units of the data, so you cannot compare the spread of daily orders with the spread of daily revenue in rupees directly. The coefficient of variation fixes this: standard deviation divided by mean, as a percentage. Koramangala’s is 3.16 divided by 120, about 2.6%. Whitefield’s is 24.70 divided by 120, about 20.6%. Now you can compare it with any other metric, in any unit.

Mistakes analysts make with standard deviation

Using the wrong version without saying so. STDEV.P on a sample understates spread, most of all on small data. Name the function in your report so someone can check it.

Letting one outlier drive the answer. A single day with zero orders because the kitchen was shut can double the standard deviation of a quiet outlet. Check the extremes before you report spread, and consider the interquartile range for data with known outliers.

Averaging standard deviations. If one outlet’s SD is 3.16 and another’s is 24.70, the SD of the two combined is not their average. Combine the raw data and recalculate.

Comparing standard deviations of different-sized things. A large store will have a larger SD than a small one simply because its numbers are bigger. Use the coefficient of variation.

Reporting variance to a business audience. Squared units confuse people. Report standard deviation.

Frequently asked questions

What is standard deviation in simple terms?

Standard deviation is the typical distance between each value and the average of the data. If two outlets both average 120 orders a day, the one with a standard deviation of 3 is steady and the one with a standard deviation of 25 swings widely. It is in the same units as the data, which makes it easy to explain.

What is the difference between variance and standard deviation?

Variance is the average of the squared differences from the mean, and standard deviation is its square root. They carry the same information, but variance is in squared units, such as orders squared, while standard deviation is back in the original units. Analysts calculate variance on the way and report standard deviation.

When should I divide by n minus 1 instead of n?

Divide by n minus 1 when your data is a sample used to describe something larger, such as six days of orders standing in for a typical day. Divide by n when your data is the complete set you care about, such as every branch in a lender’s network. Most business analysis is the sample case, so STDEV.S is the usual default in Excel.

What is the difference between STDEV.S and STDEV.P in Excel?

STDEV.S calculates the sample standard deviation and divides by n minus 1. STDEV.P calculates the population standard deviation and divides by n. On six values the two differ by about 9.5%, and on a few hundred values the difference is negligible.

Can standard deviation be negative or zero?

It cannot be negative, because it is the square root of an average of squared numbers. It is zero only when every value is identical, meaning there is no spread at all. A standard deviation close to zero relative to the mean means the data is very consistent.

What counts as a high standard deviation?

There is no fixed threshold, because standard deviation depends on the scale of the data. Divide it by the mean to get the coefficient of variation: a figure of a few percent means steady data, while 20% or more means large swings for most operational metrics. Compare it against the same metric in other periods, stores or segments rather than judging it alone.

Learn statistics the way analysts use it

Standard deviation is one of the first tools in descriptive statistics, and it is the base for z-scores, confidence intervals and hypothesis tests. If you want to work through these with real data, SkilloVilla’s Data Analytics and Statistics Using Python course covers descriptive statistics, inferential statistics and probability alongside NumPy, pandas and data visualisation, and ends with a capstone project. It is a beginner-level course, and no coding experience is required.

Power BI vs Tableau: Which to Learn for an…

For most people aiming at a data analyst job in India, Power BI is the better first tool. It shows up in more Indian...
SkilloVilla Team
5 min read

Power Query in Power BI: Clean and Shape Data…

Power Query in Power BI explained: connecting to SQL, query folding, profiling, merging, what loads to the model, parameters and the M behind each...
SkilloVilla Team
8 min read

Power BI Projects for Your Portfolio: 8 Ideas Using…

Power BI projects for a data analyst portfolio, built on Indian public data: the dataset, the question, the visuals and what each one shows...
SkilloVilla Team
7 min read

Leave a Reply