# Why don't we automatically have outliers when mean and median differ strongly?

Assume you have a data set with information on income of all students in the lecture. The mean value is 1500\$. The median value is however only 800\$. Which of the following conclusions is wrong?

The answer is: The difference between median and mean can be explained by outliers.

Why is this wrong? When Mean and Median deviate in such a manner, there have to be outliers or am I completely wrong? I can check outliers with |z| > 2.5 or a boxplot with IQR*1.5

But why do there not have to be outliers in such a case? I am completely lost and cannot think of a data set that fulfils such a case. Could you please help me?

• How do you define “outliers”?
– Tim
Jan 28, 2022 at 21:44
• Consider a dataset of a small lecture with three students. The values are 800, 800, 2900. You will have a hard time advancing a claim that this dataset has "outliers," because you would be flagging at least one-third of all the data! See what your checks tell you. Another interesting dataset comes from a class of students drawn from two different backgrounds: eight of them have incomes of 800 and the remaining seven have incomes of 2300. What would be an "outlier"?
– whuber
Jan 28, 2022 at 21:45
• @whuber: I love you! Thanks a lot. That makes things clear Jan 28, 2022 at 21:48
• Incidentally, how do you define "differ strongly"? It can't reasonably be an additive or multiplicative relation, since you could simply add a fixed number to all data points, which would shift the mean and the median, but "differ strongly" should be invariant to this. Jan 28, 2022 at 21:56
• @whuber: can I give you a like or the best answer or sth like that? That really helped me. I'm a complete noob when it comes to statistics :( Jan 28, 2022 at 21:56

Sometimes a sample with a mean larger than the sample median can have boxplot outliers, as you say. (Sometimes many outliers.) The exponential sample with $$n=1000$$ observations below illustrates this. [Using R.]

set.seed(128)
y = rexp(1000)
mean(y); median(y)
[1] 1.029919
[1] 0.679321
boxplot(y, horizontal=T)
abline(v=mean(y), col="red")


In the figure below, the heavy black line within the box shows the sample median $$0.6793$$ and the vertical red line shows the sample mean $$1.0299.$$

The population mean is $$\mu = 1$$ and the population median is $$\eta = -\ln(.5) = 0.6931.$$

qexp(.5); -log(.5)
[1] 0.6931472
[1] 0.6931472


Below is a histogram of the $$1000$$ observations along with the density curve of the distribution $$\mathsf{Exp}(1).$$

hist(y, prob=T, col="skyblue2")


By contrast, moderately large samples from many right-skewed distributions have mean larger than median, but may not have any outliers at all. Many examples can be found among samples from beta and other distributions.

set.seed(2022)
x = rbeta(1000, 2, 4)
mean(x); median(x)
[1] 0.3369563      # sample mean
[1] 0.3059188      # sample median
boxplot(x, horizontal=T)
abline(v=mean(x), col="red")


The population mean is $$\mu = 1/3$$ and the population median is $$\eta = 0.3138.$$

qbeta(.5, 2, 4)
[1] 0.3138102

hist(x, prob=T, col="skyblue2")
curve(dbeta(x, 2, 4), add=T, lwd=2, col="orange")


• The first boxplot example might confuse readers, because many people understand the individual dots in the boxplot to be outliers--almost by definition.
– whuber
Jan 29, 2022 at 15:44
• @whuber: No confusion here. Of the 1000 observations 57 really are boxplot outliers: In R, length(boxplot.stats(y)$out) returns 57. Nor is this an especially large number of outliers (using yesterday's date as seed). By simulation an exponential sample of 1000 will average about 48 outliers, and will show 57 or more with probability about 0.13. // The contrast comes later, showing a right-skewed sample with no outliers at all. Jan 29, 2022 at 18:46 • Labeling those as outliers is dangerous. Jan 30, 2022 at 13:16 Here is an example. Say there are 2001 students, and 1000 of them have a score of 0 and 1001 of them have a score of 100. Then the mean is around 50, but the median is 100, and there are no outliers in this dataset. Outliers from what? You must be assuming a normal (Gaussian) distribution. But with lognormal distributions, some high values are expected as the distribution can be quite skewed. The mean is almost always larger than the median with data sampled from lognormal distributions. To test this idea, take the logarithm of all the values, and see if that distribution is closer to normal (Gaussian). The difference between the mean and the median is not a good sign of outliers. Example: You have five students, four earning \$1 and the fifth earning \$6 dollars. Then, the median income is \$1 and the average income is \\$2. In this example, the average is two times the median! But that doesn't imply we should exclude one student from our analysis.