# What Is a Z-Score? Definition, Formula and Examples

A z-score tells you how many standard deviations a single data value sits above or below the mean of its distribution. It converts any raw number into a common scale, so you can compare values from different datasets and judge how unusual a value is. A positive z-score means the value is above the mean, a negative one means it is below.

## Quick Answer

- A z-score is the number of standard deviations a raw value is above or below the mean [1].
- The formula is $z = \dfrac{x - \mu}{\sigma}$, where $x$ is the value, $\mu$ is the mean and $\sigma$ is the standard deviation [2].
- A z-score of 0 means the value equals the mean. A z-score of +1 means it is one standard deviation above the mean.
- Z-scores let you compare scores measured on different scales, such as an SAT score against an ACT score [1].
- Under a normal distribution, roughly 95% of values fall between z = -2 and z = +2, which makes z-scores a quick check for outliers [2].

## What a Z-Score Means

In plain terms, a z-score answers the question "how far from average is this value, measured in units of typical spread?" If the average test score is 74 and the standard deviation is about 10, a score of 84 is roughly one typical step above average. That step is the z-score.

The precise statistical definition is the number of standard deviations by which the value of a raw score is above or below the mean value of what is being observed or measured [1]. Raw scores above the mean have positive standard scores, and those below the mean have negative standard scores [1]. A z-score is also called a standard score or a z value, and all three names refer to the same quantity.

Because the result is unit-free, a z-score of 1.5 means the same thing whether the original data was measured in points, dollars, seconds or millimeters. That is what makes standardization useful.

## How It Works

The formula for a population is:

$$z = \frac{x - \mu}{\sigma}$$

Each symbol means the following:

| Symbol | Meaning |
|---|---|
| $x$ | The raw value you are standardizing |
| $\mu$ | The mean of the distribution |
| $\sigma$ | The standard deviation of the distribution |
| $z$ | The resulting z-score |

You subtract the mean from the value, then divide by the standard deviation. The subtraction centers the data on zero. The division rescales it so one unit equals one standard deviation.

When you work with a sample instead of a full population, you replace $\mu$ with the sample mean $\bar{x}$ and $\sigma$ with the sample standard deviation $s$. The logic is identical. Software follows the same steps. In Python, `scipy.stats.zscore` computes the z score of each value in the sample relative to the sample mean and standard deviation, and it exposes a `ddof` argument for the degrees of freedom correction [3]. Its default is `ddof=0` (dividing by n), so pass `ddof=1` to match the n - 1 sample standard deviation used below. In MATLAB, `zscore(X)` standardizes along the first array dimension whose size does not equal 1, and it can also return the means and standard deviations it used [4]. In R, the `zscore` function in the SocEpi package calculates standardized scores with a mean close to zero and a standard deviation close to one, using a population weighted mean and standard deviation [5].

## Worked Example

Suppose you have test scores for 10 students in a class. You want to know how one student's score of 82 compares to the rest of the group.

| student_id | score |
|---|---|
| 1 | 82 |
| 2 | 65 |
| 3 | 74 |
| 4 | 90 |
| 5 | 58 |
| 6 | 77 |
| 7 | 85 |
| 8 | 70 |
| 9 | 62 |
| 10 | 79 |

Step 1. Compute the sample mean.

$$\bar{x} = 74.2000$$

Step 2. Compute the sample standard deviation using n - 1 in the denominator.

$$s = 10.3902$$

Step 3. Standardize the student's score of 82.

$$z = \frac{82 - 74.2000}{10.3902} = 0.7507$$

Step 4. Standardize a classmate's score of 66 for comparison.

$$z = \frac{66 - 74.2000}{10.3902} = -0.7892$$

Step 5. Convert each z-score to a normal-curve probability. The student's score sits above 0.7507, so the proportion of a standard normal distribution above it is 0.2264. The classmate's score sits below -0.7892, so the proportion below it is 0.2150.

Here is the same calculation in Python:

```python
import statistics
scores = [82, 65, 74, 90, 58, 77, 85, 70, 62, 79]
mean = statistics.mean(scores)
sd = statistics.stdev(scores)
z = (82 - mean) / sd  # 0.7507
z_classmate = (66 - mean) / sd  # -0.7892
print(f"mean = {mean:.4f}, sd = {sd:.4f}, z_student = {z:.4f}, z_classmate = {z_classmate:.4f}")
```

Output:

```
mean = 74.2000, sd = 10.3902, z_student = 0.7507, z_classmate = -0.7892
```

The student scored about three quarters of a standard deviation above the class mean. The classmate scored about four fifths of a standard deviation below it. Neither value is extreme for a group of this size.

## How to Interpret It

The sign tells you direction. A positive z-score means the value is above the mean. A negative z-score means it is below the mean [1].

The size tells you distance in standard deviation units. A z-score of 0.75 is close to average. A z-score of 2.5 is far out in the tail.

If the underlying data is normally distributed, you can attach probabilities to z-scores. About 68% of values fall within one standard deviation of the mean, about 95% within two, and about 99.7% within three. This is the empirical rule, and z-scores are a quick way to apply it. For example, you can check whether 95% of the values in a data set are within two standard deviations by checking the percentage of values with z-scores between -2 and 2 [2].

Z-scores also make cross-scale comparisons possible. When scores are measured on different scales, they may be converted to z-scores to aid comparison [1]. If one student scores 1800 on the SAT and another scores 24 on the ACT, the raw numbers cannot be compared directly. Converting each to a z-score against its own test's mean and standard deviation shows which student performed better relative to other test-takers [1]. To turn a z-score into a percentile, see [Z-Scores and Percentiles: How They Relate and How to Convert](/blog/data-analysis/z-scores-and-percentiles).

## When to Use It (and when not to)

Use a z-score when you want to:

- Compare values drawn from distributions with different means and standard deviations [1].
- Flag possible outliers by checking which values fall beyond z = -2 or z = +2 [2].
- Apply the empirical rule quickly without computing exact probabilities [2].
- Standardize variables before certain analyses that assume comparable scales.

Avoid or reconsider a z-score when:

- The distribution is heavily skewed or has extreme outliers. The mean and standard deviation are themselves sensitive to outliers, so the z-score can mislead.
- The standard deviation is zero or near zero. Every value then produces a division by zero or an enormous z-score. MATLAB handles the zero-variance case by using a standard deviation of 1 for columns that consist of identical values [4].
- You need a bounded score. Z-scores are unbounded, so a single extreme value can produce a very large z-score.
- The data is categorical. Z-scores only make sense for numeric values on an interval or ratio scale.

## Z-Score vs Standard Deviation

These two ideas are related but they answer different questions. Standard deviation describes the spread of a whole dataset. A z-score describes the position of one value within that dataset.

| | Standard deviation | Z-score |
|---|---|---|
| What it describes | Spread of the whole dataset | Position of a single value |
| Units | Same units as the data | Unit-free |
| Typical range | 0 upward | Unbounded, often -3 to +3 |
| Uses the other? | No | Yes, divides by the standard deviation |
| Main use | Measuring variability | Comparing and flagging values |

A z-score cannot exist without a standard deviation, because the standard deviation is the unit the z-score is measured in.

## Common Mistakes

- **Forgetting to subtract the mean first.** Dividing the raw value by the standard deviation gives a meaningless number. Fix: always compute $x - \mu$ before dividing.
- **Mixing up population and sample standard deviation.** Using n instead of n - 1 in the denominator changes the result slightly. Fix: use the population formula when you have the whole population, and the sample formula when you have a sample.
- **Treating a z-score as a probability.** A z-score of 2 is not a 2% chance. Fix: convert the z-score to a probability with a normal table or software.
- **Assuming normality without checking.** Percentile statements only hold if the data is roughly normal. Fix: plot the data or check skewness before quoting percentages.
- **Comparing z-scores across unrelated groups.** A z-score of 1 in one class is not the same as a z-score of 1 in another class with a different spread. Fix: state which mean and standard deviation you used.
- **Ignoring a zero standard deviation.** If every value is identical, the z-score is undefined. Fix: check the spread before standardizing.

## Limitations

A z-score depends entirely on the mean and standard deviation you feed it. If those two numbers are wrong, or if they come from a different population than the value you are standardizing, the result is misleading. This matters most when you standardize a new observation using statistics from an old dataset.

Z-scores also assume that distance from the mean is meaningful in the way the formula implies. For skewed data, a value far above the mean and a value equally far below it are not equally unusual, yet the z-score treats them symmetrically. The z-score is a descriptive tool, not proof that a value is an error or an outlier. It flags candidates for you to inspect.

## Frequently Asked Questions

### What is a good z-score?

There is no universally good or bad z-score. A value near 0 is close to average. Values beyond about -2 or +2 are unusual under a normal distribution and are worth a closer look [2]. What counts as extreme depends on your field and your data.

### Can a z-score be negative?

Yes. A negative z-score simply means the value is below the mean [1]. It does not mean the value is invalid or that anything went wrong. A z-score of -1.5 means the value is one and a half standard deviations below the mean.

### What is the difference between a z-score and a t-score?

Both standardize a value, but they use different reference distributions. A z-score is compared against the standard normal distribution. A t-score is compared against a t distribution, which has heavier tails and is used when the sample is small or the population standard deviation is unknown. For large samples the two converge.

### How do I calculate a z-score in Excel or Python?

In Python, `scipy.stats.zscore` computes the z score of each value in the sample relative to the sample mean and standard deviation, using `ddof=0` by default, so pass `ddof=1` for the n - 1 version [3]. In MATLAB, `zscore(X)` does the same and can return the means and standard deviations used [4]. In a spreadsheet you can compute it manually as `(value - mean) / standard_deviation`. To try it without writing code, use the [Z-Score Calculator](/tools/z-score-calculator).

### What does a z-score of 1.96 mean?

A z-score of 1.96 marks the point beyond which about 2.5% of a standard normal distribution lies in the upper tail. It is the familiar cutoff for a two-tailed 95% confidence level. In plain terms, a value with z = 1.96 is unusually high if the data is normally distributed.

### How is a z-score used in hypothesis testing?

Z-scores convert a sample statistic into a standardized distance from what you would expect under a null hypothesis. That standardized distance becomes a test statistic, which you compare against a critical value or convert to a p-value. The [Two Proportion Z-Test: Formula and Worked Example](/blog/data-analysis/two-proportion-z-test-formula) walks through that process step by step.

## References

1. [Standard score - Wikipedia](https://en.wikipedia.org/wiki/Standard_score)
2. [Z-Score](https://www.jmp.com/en/statistics-knowledge-portal/inferential-statistics/hypothesis-testing/z-score)
3. [z-score, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.z-score.html)
4. [z-score - Standardized z-scores - MATLAB](https://www.mathworks.com/help/stats/z-score.html)
5. [z-score function - RDocumentation](https://www.rdocumentation.org/packages/SocEpi/versions/1.0.0/topics/z-score)

## Further Reading

- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/index.htm)
- [OpenStax. Introductory Statistics 2e](https://openstax.org/details/books/introductory-statistics-2e)
- [Krzywinski M, Altman N (2013). Importance of being uncertain. Nature Methods](https://doi.org/10.1038/nmeth.2613)

## Related Articles

- [Z-Scores and Percentiles: How They Relate and How to Convert](/blog/data-analysis/z-scores-and-percentiles)
- [Two Proportion Z-Test: Formula and Worked Example](/blog/data-analysis/two-proportion-z-test-formula)
- [F1 Score: Definition, Formula and When to Use It](/blog/data-analysis/f1-score-definition-formula)
- [How to Calculate a Percentage: Formula and Examples](/blog/data-analysis/how-to-calculate-a-percentage)
- [What Is an Independent Variable? Definition and Examples](/blog/data-analysis/what-is-an-independent-variable)