Data AnalyticsStatisticsbeginner
Updated:

Mean, Median and Mode Explained

4 min read

Mean, median and mode are the three averages. Learn how each is computed, how outliers pull them apart, and which one to report for skewed data.

TL;DR – Quick Answer

The mean is the sum of all values divided by how many there are. The median is the middle value when the data is sorted. The mode is the value that appears most often. The mean is sensitive to outliers, so for skewed data such as incomes the median is a more honest measure of the typical value.

On This Page

Mean, median and mode are the three ways to answer one deceptively simple question: what is the typical value in this data? They are collectively called measures of central tendency, and choosing the wrong one is one of the most common ways analysts accidentally mislead their audience. Getting them right is a core skill you will use in every report.

Each measure has a precise definition and a situation where it shines. This page walks through all three, shows how a single outlier splits them apart, and gives you a clear rule for which one to report.

The three averages defined

The mean is the arithmetic average: add every value and divide by the count. If five sales are 4, 8, 6, 8 and 10, the sum is 36 and the mean is 36 / 5 = 7.2. The mean uses every data point, which makes it informative but also fragile, because a single extreme value shifts it.

The median is the middle value once the data is sorted. Sorting 4, 8, 6, 8, 10 gives 4, 6, 8, 8, 10, and the middle of five values is the third one, 8. With an even count you average the two middle values. The median cares only about position, not magnitude, so distant outliers do not move it.

The mode is the most frequently occurring value. In our list, 8 appears twice and everything else once, so the mode is 8. A dataset can have one mode, several, or none. The mode is the only average that works for categorical data like product names or cities.

A worked example showing the outlier effect

The clearest way to feel the difference is to watch an outlier drag the mean away from the median. Here is a small, illustrative sample of five monthly salaries.

import numpy as np
from scipy import stats

salaries = [30000, 32000, 35000, 38000, 200000]

print("mean:  ", np.mean(salaries))
print("median:", np.median(salaries))
print("mode:  ", stats.mode(salaries, keepdims=False).mode)

Expected output:

mean:   67000.0
median: 35000.0
mode:   30000

Check the mean by hand: 30000 + 32000 + 35000 + 38000 + 200000 = 335000, and 335000 / 5 = 67000. Now look at what happened. Four of the five people earn between 30,000 and 38,000, yet the mean is 67,000 — a figure nobody actually earns. The single 200,000 salary hauled the mean far above the pack. The median, 35,000, sits right in the middle of the realistic values and is the honest answer to "what does a typical person here earn?"

This is exactly why news reports quote median household income and median home prices. Means would be inflated by a handful of billionaires and mansions.

How analysts choose

The decision rule is short and worth memorizing:

  • Symmetric data, no outliers: the mean is ideal because it uses all the information.
  • Skewed data or outliers present: report the median, optionally alongside the mean so readers see the gap.
  • Categorical data: the mode is your only option.

A quick diagnostic: compute both mean and median. If they are close, the data is roughly symmetric and either is fine. If the mean is noticeably higher than the median, the data is right-skewed (a long tail of large values). If the mean is lower, it is left-skewed. That gap is a free skewness detector you can eyeball in seconds.

import numpy as np

data = [30000, 32000, 35000, 38000, 200000]
gap = np.mean(data) - np.median(data)
print("mean minus median:", gap)   # 32000.0 -> strong right skew

A positive gap of 32,000 confirms a heavy right skew, driven by the one large salary.

Common mistakes

Averaging an already-skewed metric. Reporting the mean response time or mean deal size when a few huge values dominate paints an overly rosy or alarming picture. Reach for the median whenever the tail is long.

Forgetting to sort before taking the median. The median is defined on sorted data. Taking the "middle of the list" without sorting gives a meaningless number. Libraries sort for you, but if you compute by hand, sort first.

Treating the mode as reliable on continuous data. Precise measurements like 7.31, 7.32, 7.33 rarely repeat, so the mode is either undefined or an accident of rounding. Save the mode for discrete or categorical values.

Reporting only one number. A single average hides variability. Pair any measure of center with a measure of spread from the variance and standard deviation tutorial so your audience knows how consistent the data is.

In interviews

This topic is a guaranteed interview warm-up. The classic question is "What is the difference between mean and median, and when would you use each?" The strong answer names outlier sensitivity: the mean is pulled by extreme values, the median is not, so skewed data calls for the median. Expect a live calculation too, such as "find the median of 3, 7, 2, 8, 5" — sort to 2, 3, 5, 7, 8 and read off 5. You may also be handed a scenario ("Average salary is far above the median — what does that tell you?") and asked to interpret it as right skew. Interviewers care that you can connect the numbers to a real decision, not just recite definitions.

Where this fits in your learning path

Mean, median and mode are the center half of descriptive statistics; the spread half lives in variance and standard deviation. Once you are comfortable summarizing a single column, percentiles and quartiles extend the idea to any position in the data, not just the middle. All of it sits inside the broader data analytics learning path, and these fundamentals are exactly what the data analyst roadmap expects you to have solid before interviews.

Frequently Asked Questions

What is the difference between mean and median?
The mean adds every value and divides by the count, so extreme values pull it up or down. The median is just the middle value when sorted, so it ignores how far away the extremes are. On symmetric data they are close; on skewed data they diverge.
When should I use the median instead of the mean?
Use the median when the data is skewed or contains outliers, such as house prices, salaries or response times. In those cases a few large values inflate the mean and misrepresent the typical case. The median stays anchored at the middle regardless of how extreme the tails are.
Can a dataset have more than one mode?
Yes. A dataset with two values tied for most frequent is bimodal, and one with several is multimodal. If every value appears exactly once, the data effectively has no mode. Continuous measurements often have no meaningful mode at all.
How do you find the median of an even number of values?
Sort the values, then average the two middle ones. For eight sorted values, the median is the mean of the 4th and 5th. For an odd count, the median is simply the single middle value.
Which average is best for categorical data?
The mode, because mean and median require numbers you can order and add. For a column like favorite product or city, the most frequent category is the only meaningful average. Mean and median are undefined for pure categories.

Want to Build Your Career in Data Analytics with AI?

Join CodeBegun and train with working industry engineers — See the Data Analytics course in Hyderabad

Apply for Demo Class →
Siva Prasad Galaba
Founder, CodeBegun · Staff Engineer

Founder of CodeBegun. 15+ years building Java systems at companies like Crunchyroll. Teaches Java, Spring Boot and system design the way the industry actually works, and mentors students through projects, mock interviews and placement preparation.

Technically reviewed by CodeBegun Technical TeamLast reviewed 16 July 2026 LinkedIn
Chat with us