Mean Median and Mode: How to Calculate Each, With Worked Examples
Learn how to find the mean median and mode of a list of numbers, when each is the right average, and how sample and population standard deviation differ.
By TheTextKit TeamPublished

A table of results for the list 2, 4, 4, 4, 5, 5, 7, 9. The mean is 5. The median is 4.5. The mode is 4. The range is 7.
The mean, median and mode are three ways to describe the middle of a list of numbers. The mean is the sum divided by the count, the median is the middle number once the list is sorted, and the mode is the number that appears most often.
They often differ, and which one is right depends on the data. For 2, 4, 4, 4, 5, 5, 7 and 9, the mean is 5, the median is 4.5 and the mode is 4. This guide shows how to work each out by hand, when to use which, how range, quartiles and standard deviation fit in, and how we checked our calculator against Python on 20,000 lists.
How to find the mean, median and mode
- Open the Mean, Median and Mode Calculator.
- Paste your numbers, separated by spaces, commas or line breaks. Use a point for decimals.
- Read the mean, median and mode, with the range, quartiles and standard deviation beside them.
- Choose how many decimal places to round to.
By hand, the steps depend on the average:
- Mean. Add all the numbers and divide by how many there are.
- Median. Sort the numbers from smallest to largest. If the count is odd, take the middle one. If it is even, average the two middle ones.
- Mode. Count how often each number appears and take the one that appears most.
A worked example
Take the list 2, 4, 4, 4, 5, 5, 7, 9. There are 8 numbers and they add up to 40, so the mean is 40 ÷ 8 = 5. The list is already sorted. With 8 numbers, the middle two are the fourth and fifth, 4 and 5, so the median is 4.5. The number 4 appears three times, more than any other, so it is the mode.
| Measure | Value |
|---|---|
| Count | 8 |
| Sum | 40 |
| Mean | 5 |
| Median | 4.5 |
| Mode | 4 |
| Range (9 minus 2) | 7 |
The Python statistics module defines them the same way. Its median is the common "mean of middle two" method for an even count, and its multimode function returns the most frequent values in the order they were first seen.
When the mean and the median disagree
The mean uses every number, so one extreme value can pull it far from the rest. The median ignores how large the extremes are. Take seven salaries, in thousands: 30, 32, 35, 36, 38, 40 and 500. The mean is 101.5714, higher than six of the seven values. The median is 36, which is close to what most people earn in that list.
| Measure | Value |
|---|---|
| Mean | 101.5714 |
| Median | 36 |
| Largest value | 500 |

A table for the list 30, 32, 35, 36, 38, 40 and 500. The mean is 101.5714. The median is 36. The largest value is 500.
Use the median when a few extreme values would mislead, as with salaries or house prices. Use the mean when the numbers are fairly even, or when you need a total. Use the mode for the most common category, such as the most frequent shoe size.
More than one mode, or none
A list can have two modes, or more. In 1, 1, 2, 2, 3 the numbers 1 and 2 each appear twice, so both are modes. A list where every number appears once has no mode. The list 9, 2, 5, 4, 12 and 7 is like that. The calculator says so instead of picking one, because a mode that appears once is not telling you anything.
Range, quartiles and the interquartile range
The range is the largest minus the smallest. Quartiles split the sorted list into four parts. The lower quartile, Q1, is the median of the lower half, and the upper quartile, Q3, is the median of the upper half. The interquartile range, Q3 minus Q1, is the spread of the middle half of the data. The NIST e-Handbook page on measures of scale lists it with the range and the standard deviation. It describes the interquartile range as an estimate of scale with robustness of validity, which is why it is used when a few values are extreme.
For 2, 4, 4, 4, 5, 5, 7 and 9, the halves are 2, 4, 4, 4 and 5, 5, 7, 9, so Q1 is 4, Q3 is 6 and the interquartile range is 2.
That is one method, and others give different answers. We asked Python for the upper quartile of the same list three ways:
| Method | Q3 for 2, 4, 4, 4, 5, 5, 7, 9 |
|---|---|
| Median of the halves (our tool) | 6 |
Python quantiles, exclusive (the default) | 6.5 |
Python quantiles, inclusive, and numpy | 5.5 |

A table of the upper quartile of the list 2, 4, 4, 4, 5, 5, 7, 9 by three methods. The median of the halves gives 6. Python's exclusive method gives 6.5. Python's inclusive method gives 5.5.
Python's documentation explains the difference. The exclusive method suits samples that can contain more extreme values than were seen, and the inclusive method treats the smallest and largest values as the 0th and 100th percentiles. Neither is wrong. Check which method a spreadsheet or a textbook uses before you compare answers.
Variance and standard deviation
The variance is the average squared distance from the mean, and the standard deviation is its square root. It shows how spread out the numbers are. There are two versions. The population version divides by n, the count, and is for data that is the whole group. The sample version divides by n minus 1, called Bessel's correction, and is for data that is a sample from a larger group. The Python documentation says that applying the population formula to a sample gives a biased variance, while the sample version, with Bessel's correction, uses N minus 1 degrees of freedom.
Take 9, 2, 5, 4, 12 and 7, with a mean of 6.5. The population standard deviation is 3.304 and the sample standard deviation is 3.6194.
| Version | Divides by | Standard deviation |
|---|---|---|
| Population | n (6) | 3.304 |
| Sample | n minus 1 (5) | 3.6194 |

A table of the standard deviation of the list 9, 2, 5, 4, 12 and 7 in two versions. The population version divides by 6 and gives 3.304. The sample version divides by 5 and gives 3.6194.
The sample value is always the larger one. Use it when your numbers are a sample, which is most of the time, and use the population version only when you really have every member of the group.
Why decimals need exact arithmetic
Computers store most decimals in binary, so some sums are slightly off. In JavaScript, 0.1 + 0.2 + 0.3 gives 0.6000000000000001, and dividing by 3 gives 0.20000000000000004 instead of 0.2. For a mean on a report, that tail is ugly and sometimes wrong in the last digit after rounding.
Our calculator reads every number as an exact decimal and does the sums with whole numbers, so 0.1, 0.2 and 0.3 add to 0.6 and have a mean of 0.2. It rounds once, at the end, half away from zero, to the number of places you choose.
How we tested it
We compared the calculator with Python's exact arithmetic. A script made 20,000 random lists with 1 to 100 numbers, whole numbers and decimals with up to six places, negative values, repeated values and numbers up to 10 to the 12th. Python's Fraction type and its statistics module worked out 16 results for each list with no rounding error, and we compared every one after rounding to 10 places.
| Check | Result |
|---|---|
| Lists compared | 20,000 |
| Results compared for each list | 16 |
| Lists where every result matched | 20,000 of 20,000 |

A table of results for the statistics calculator compared with Python's exact fraction arithmetic. 20,000 random lists were compared. Each list had 16 results. Every result matched on all 20,000 lists.
The test used the median of the halves for quartiles on both sides, so it proves the arithmetic and not the choice of method. The square roots for standard deviation agree to 10 decimal places.
Frequently asked questions
How do I find the mean, median and mode?
The mean is the sum of the numbers divided by how many there are. For the median, sort the numbers and take the middle one, or the average of the middle two when the count is even. The mode is the number that appears most often. Paste a list into the calculator and it gives all three.
When should I use the median instead of the mean?
Use the median when a few very large or very small values would pull the mean away from what is typical, such as salaries or house prices. In the list 30, 32, 35, 36, 38, 40 and 500 the mean is 101.57 but the median is 36.
What is the difference between sample and population standard deviation?
The population version divides by n and is used when your numbers are the whole group. The sample version divides by n minus 1, called Bessel's correction, and is used when they are a sample from a larger group. The sample value is always a little larger.
Why do different tools give different quartiles?
Because there is no single definition. For the list 2, 4, 4, 4, 5, 5, 7, 9 the upper quartile is 6 by the median of halves, 6.5 by Python's exclusive method and 5.5 by its inclusive method. Check which method a tool uses before comparing results.
Is my data uploaded?
No. The calculation runs in your browser, and the numbers you enter are not sent anywhere or stored. The tool needs no account and keeps nothing after you close the page.
Calculate yours now
Paste a list into the Mean, Median and Mode Calculator to see the mean, median and mode and every other measure at once. For grades, try the Grade Calculator, and for percentages the Percentage Calculator. Everything runs in your browser, so nothing is uploaded.


