How to Calculate the Mean: Formula and Step by Step Examples
By Dr. Zubair Khalid, DVM, MS, PhD ·

To calculate the mean, add every value in a dataset and divide the sum by the number of values. That single number, the arithmetic mean, summarizes the center of your data. This article shows the formula, walks through a full example, and covers the sample mean and population mean so you can compute either one correctly.
Quick Answer
- The mean formula is $\bar{x} = \frac{\sum x}{n}$ for a sample and $\mu = \frac{\sum x}{N}$ for a population.
- $\sum x$ means "add up all the values." $n$ or $N$ is how many values you have.
- The arithmetic mean is the balance point of the data. It is the value where the deviations above and below cancel out.
- Sample and population means use the same arithmetic. Only the symbol and the count label change.
- For the reaction-time dataset below, the mean is 438.80 ms.
What Is the Mean and How Do You Calculate It?
To calculate the mean, add all the values in your dataset and divide that total by how many values you have. For the numbers 4, 8, and 6, the sum is 18 and there are 3 values, so the mean is 6. That is the whole method: one addition step and one division step.
The formula is written as the sum of all values divided by the count. In symbols, the sample mean is x-bar equals the sum of x divided by n, and the population mean is mu equals the sum of x divided by N. The only difference between the two versions is the label: n counts a sample, N counts a whole population. The arithmetic never changes.
If you want a formula you can copy and paste into a document or spreadsheet note, use this plain-text version: mean = (sum of all values) / (number of values). In spreadsheet syntax that becomes =SUM(range)/COUNT(range), or simply =AVERAGE(range).
A common question asks how to compute an overall mean when you already have group means. You cannot just average the group means unless every group has the same number of observations. Instead, multiply each group mean by its group size, add those products, and divide by the total number of observations across all groups. This weighted approach gives the true overall mean.
In statistics, the mean is the balance point of the data: the value where the distances above and below cancel out. It uses every observation, which makes it informative but also sensitive to extreme values. That is why skewed data such as incomes are often summarized with the median instead.
| Situation | What to do |
|---|---|
| Raw values in front of you | Add them, divide by the count |
| Group means of unequal sizes | Weight each mean by its group size, then divide by the total count |
| Spreadsheet | Use the AVERAGE function on the range |
| Skewed data | Report the mean alongside the median |
The Hindi phrase for the mean formula, माध्य ज्ञात करने का सूत्र, describes the same relationship: all values added together, divided by how many there are. The concept is identical in every language and every classroom.
The Formula
The mean, also called the arithmetic mean, is the sum of all observations divided by the count of observations.
$$\bar{x} = \frac{\sum_{i=1}^{n} x_i}{n}$$
Each symbol has a specific job:
| Symbol | Meaning |
|---|---|
| $\bar{x}$ | Sample mean, read as "x-bar" |
| $\mu$ | Population mean, read as "mu" |
| $\sum$ | Summation sign, meaning "add all of these" |
| $x_i$ | The i-th value in the dataset |
| $n$ | Number of values in a sample |
| $N$ | Number of values in a population |
The population version is written the same way with different labels:
$$\mu = \frac{\sum_{i=1}^{N} x_i}{N}$$
The meaning of arithmetic mean is simple: it is the total spread evenly across every observation. If ten people each had the same value, that shared value would be the mean.
How to Calculate It Step by Step
- Write down every value. Keep the original units, such as milliseconds, dollars, or centimeters.
- Count the values. This count is $n$ for a sample or $N$ for a population.
- Add all the values. This gives $\sum x$.
- Divide the sum by the count. The result is the mean.
- Attach the unit. A mean of 438.8 in a reaction-time study means 438.8 milliseconds, not a bare number.
If you are working in a spreadsheet, the process is the same but the arithmetic is automatic. See how to calculate the mean in Excel for the function and menu steps.
Worked Example

A researcher records ten reaction times in milliseconds from a simple reaction-time task. Here is the dataset.
| Trial | Reaction time (ms) |
|---|---|
| 1 | 412 |
| 2 | 388 |
| 3 | 501 |
| 4 | 455 |
| 5 | 430 |
| 6 | 476 |
| 7 | 399 |
| 8 | 444 |
| 9 | 462 |
| 10 | 421 |
Step 1. List the values.
412, 388, 501, 455, 430, 476, 399, 444, 462, 421
Step 2. Count them.
$n = 10$
Step 3. Sum them.
$\sum x = 4388$
Step 4. Divide.
$$\bar{x} = \frac{4388}{10} = 438.8000$$
The sample mean is 438.80 ms.
Step 5. Population mean. If these ten trials were the entire population of interest, the calculation is identical.
$$\mu = \frac{4388}{10} = 438.8000$$
The population mean is also 438.80 ms. The number is the same because the arithmetic does not change. What changes is the notation and how you describe the result.
For context, the sample standard deviation is $s = 35.5240$ ms and the population standard deviation is $\sigma = 33.7010$ ms. Those values describe spread, not center, and they use different divisors. The standard deviation guide explains why the sample version divides by $n-1$.
How to Interpret the Result
A mean of 438.80 ms tells you the typical reaction time in this set of ten trials. It does not tell you that every trial took 438.80 ms. Individual trials ranged from 388 ms to 501 ms.
The mean is sensitive to every value. One unusually slow trial pulls it upward. One unusually fast trial pulls it downward. That sensitivity is a feature when the data are roughly symmetric and a problem when they are not.
Compare the mean with the median when you have skewed data. If the mean and median sit far apart, the distribution is lopsided and the mean may not represent a typical case well. A mean, median and mode calculator lets you check all three at once.
The mean is also the input to many other statistics. Variance, standard deviation, z-scores, and confidence intervals all start from it. The variance formula uses the mean as its reference point.
Doing It in Software (Excel, R or Python)
In Excel, the AVERAGE function returns the mean of a range. If the ten values sit in cells A1 through A10, the formula is =AVERAGE(A1:A10).
In R, the mean function does the same job. For a vector named data, you write mean(data).
In Python, the statistics module provides mean. Here is the full calculation for this dataset.
import statistics
data = [412, 388, 501, 455, 430, 476, 399, 444, 462, 421]
mean = statistics.mean(data)
Output:
mean = 438.8000
The statistics.mean function works on any sequence of numbers, including a list, a tuple, or a generator. For large numeric datasets, NumPy's mean is faster, but the result is the same arithmetic.
If you are computing a mean across several groups, the grand mean formula shows how to combine group means correctly. Combining them by averaging the averages is only valid when the groups are the same size.
Common Mistakes
- Dividing by the wrong count. Use $n$ for a sample and $N$ for a population. The arithmetic is identical, but the label matters when you report the result. Fix: state clearly which one you computed.
- Forgetting to include every value. A dropped observation changes both the sum and the count. Fix: count the values before and after summing, and confirm the two match.
- Averaging averages from unequal groups. The mean of group means is not the overall mean unless every group has the same size. Fix: weight each group mean by its count, or pool the raw values.
- Treating the mean as a typical value in skewed data. Income and house prices are common examples. Fix: report the median alongside the mean.
- Mixing units. Adding seconds to milliseconds produces a meaningless sum. Fix: convert everything to one unit before summing.
- Rounding too early. Rounding intermediate sums can shift the final answer. Fix: keep full precision until the last step.
Limitations
The mean compresses an entire dataset into one number, so it hides the shape of the distribution. Two datasets with the same mean can look completely different. One might cluster tightly around the center, the other might have values spread across a wide range. Always pair the mean with a measure of spread such as the standard deviation or the range.
The mean is also not resistant to outliers. A single extreme value can move it far from the bulk of the data. When your data are skewed or contain errors, the median often describes the center better. The mean remains the right choice when you need a value that uses all the information in the dataset, or when you are computing statistics that depend on it, such as variance and the standard error.
Worked Examples Across Real Situations
Averaging a small set by hand
Suppose a pet owner weighs a puppy on five visits: 2.1, 2.6, 3.0, 3.4, and 3.9 kilograms. The sum is 15.0 kg and the count is 5, so the mean weight is 3.0 kg. Notice that 3.0 kg never appears on the scale. The mean is a summary, not a measurement, and it can land between observed values.
Combining group means correctly
A clinic tracks waiting times in two sessions. Morning had 20 patients with a mean wait of 12 minutes. Afternoon had 30 patients with a mean wait of 17 minutes. Averaging 12 and 17 gives 14.5, but that is wrong because the groups differ in size. The correct overall mean weights each group by its count: (20 times 12) plus (30 times 17) equals 240 plus 510, which is 750. Divide by 50 total patients to get 15 minutes. The larger afternoon group pulls the overall mean closer to its own value. This weighting rule is the single most useful idea for anyone combining summary statistics from different sources.
Estimating a mean from grouped data
When data arrive only as a frequency table, treat each category's midpoint as the value for every observation in that category. For a class of test scores grouped as 50 to 59 (4 students), 60 to 69 (9 students), and 70 to 79 (7 students), use midpoints 54.5, 64.5, and 74.5. Multiply each midpoint by its frequency: 218, 580.5, and 521.5. The total is 1320, and dividing by 20 students gives 66. This grouped estimate is close to, but not identical to, the mean of the raw scores, because the midpoint stands in for values that were rounded into bins.
A diagram in words
Picture a number line with a fulcrum under it. Place each data value as a weight at its position on the line. The mean is the spot where the line balances perfectly. Move one weight far to the right and the balance point shifts right, which is exactly how an outlier drags the mean. The median, by contrast, only cares which value sits in the middle, so it barely moves when one extreme value changes.
Mean Versus Other Averages
Mean, median, and mode side by side

The mean uses every value and is the basis for variance, standard deviation, and most inferential statistics. The median is the middle value when data are ordered and resists outliers. The mode is the most frequent value and suits categorical data such as favorite pet species. For the set 1, 2, 2, 3, 40, the mean is 9.6, the median is 2, and the mode is 2. The mean is pulled far upward by the single value of 40, while the median and mode describe the bulk of the data far better. Choosing among them depends on the shape of the data and the question being asked.
Arithmetic, geometric, and harmonic means
The arithmetic mean adds values, which suits quantities that combine additively, such as total rainfall across days. The geometric mean multiplies values and then takes the nth root, which suits growth rates and ratios. The harmonic mean divides the count by the sum of reciprocals, which suits averaging rates such as speeds over equal distances. Using the arithmetic mean on growth factors overstates average performance, a classic trap in finance and biology.
Common Misconceptions and Edge Cases
The mean is not always typical
People often read the mean as "the normal value." In a skewed distribution, most observations can sit on one side of the mean. A small number of very high incomes can raise the average income well above what most households earn. Always ask whether the distribution is roughly symmetric before treating the mean as representative.
Rounding and precision
Round only at the final step. If you round each value before summing, small errors accumulate. In the puppy example, rounding 2.1 and 2.6 to 2 and 3 before adding would shift the mean noticeably. Keep full precision through the sum and division, then round the answer to a sensible number of digits for the context.
Zero and negative values
Zero is a legitimate data value and must be included in both the sum and the count. Negative values are equally valid: temperatures below freezing or account balances in deficit are summed normally. A common error is dropping zeros as if they were missing data, which inflates the mean.
Missing data
If a value is missing, you cannot simply treat it as zero. Either exclude that observation from both the sum and the count, or use an imputation method and state clearly what you did. Mixing the two approaches produces a number that matches neither the complete-case mean nor the imputed mean.
The mean of percentages
Averaging percentages directly is valid only when the denominators are equal. If one group is 10 people and another is 100, a simple average of their success rates misrepresents the combined rate. Weight each percentage by its group size, exactly as with group means.
Checking Your Answer
A quick sanity check catches most errors. The mean must fall between the smallest and largest values in the dataset. If it does not, you have summed or counted incorrectly. You can also verify that the deviations above the mean balance the deviations below it: subtract the mean from each value, and the positive and negative results should sum to zero. Finally, compare your hand calculation with a spreadsheet function on the same numbers. If the two disagree, recount the values first, since a miscount is the most frequent mistake.
Frequently Asked Questions
How do you find the mean of a set of numbers?
Add all the numbers together, then divide by how many numbers there are. For the values 2, 4, and 6, the sum is 12 and the count is 3, so the mean is 4. The same two steps work for any dataset, large or small.
What is the difference between the sample mean and the population mean?
The sample mean, written $\bar{x}$, is computed from a subset of a larger group. The population mean, written $\mu$, is computed from every member of the group. The formula is the same. The difference is what the number represents and how much uncertainty surrounds it. A sample mean is an estimate of the population mean.
Can the mean be a number that is not in the dataset?
Yes. The mean is a computed summary, not an observed value. In the reaction-time example, 438.80 ms does not appear in the data, yet it is the correct mean. This is normal and expected for most datasets.
How do you find the mean of a vector?
A vector is an ordered list of numbers, so the process is identical. Sum the components and divide by the number of components. In Python, statistics.mean accepts a list or tuple. In R, mean accepts a numeric vector.
What is the mean of a histogram?
You estimate it by treating each bin's midpoint as the value for every observation in that bin. Multiply each midpoint by its frequency, sum those products, and divide by the total frequency. The histogram mean guide walks through the calculation with an example.
References
This article draws on the standard references listed under Further Reading.
Further Reading
- NIST/SEMATECH e-Handbook of Statistical Methods
- OpenStax. Introductory Statistics 2e
- Krzywinski M, Altman N. Krzywinski M, Altman N (2013). Importance of being uncertain. Nature Methods
- Krzywinski M, Altman N. Krzywinski M, Altman N (2013). Significance, P values and t-tests. Nature Methods
- Wasserstein RL, Lazar NA. Wasserstein RL, Lazar NA (2016). The ASA Statement on p -Values: Context, Process, and Purpose. The American Statistician
- Greenland S, Senn SJ, Rothman KJ et al. (2016). Statistical tests, P values, confidence intervals, and power: a guide to misinterpretations. European Journal of Epidemiology
Related Articles
- How to Calculate the Mean in Excel (Step by Step)
- How to Calculate Variance: Formula, Steps and Examples
- Sample Mean: Definition, Formula and Examples
- How to Calculate Standard Deviation: Formula and Steps
- How to Find the Mean From a Histogram (With Examples)
- Test Statistic Formula: How to Calculate and Use It