0
$\begingroup$

Does outliers begin on the whisker limit or above it?

In the (Python) example below the calculcated upper whisker limit is 64.8125. Is a value of 64.8125 an outlier (>= upper_limit)? Or the outliers are higher then the limit (> upper_limit)?

>>> import seaborn as sns
>>> df = sns.load_dataset('titanic)

>>> df.age.quantile([.25, .5, .75])
0.25    20.125
0.50    28.000
0.75    38.000
Name: age, dtype: float64

>>> q1, q2, q3 = df.age.quantile([.25, .5, .75])
>>> iqr = q3 - q1
>>> whisker_length = iqr * 1.5

>>> upper_limit = q3 + whisker_length
>>> lower_limit = q1 - whisker_length
>>> lower_limit, upper_limit
(-6.6875, 64.8125)
$\endgroup$
5
  • $\begingroup$ related stats.stackexchange.com/a/603446/56940 $\endgroup$
    – utobi
    Apr 18, 2023 at 9:11
  • $\begingroup$ No it don't because it doesn't fit to my MWE. $\endgroup$
    – buhtz
    Apr 18, 2023 at 11:40
  • 2
    $\begingroup$ What is an "MWE" and why should it matter here? BTW, I found the duplicate threads by searching for "boxplot fence" and "boxplot whisker outlier" and looking at the top-voted hits. I'm sure you can find even more answers by searching further. $\endgroup$
    – whuber
    Apr 18, 2023 at 13:00
  • $\begingroup$ MWE = stackoverflow.com/help/minimal-reproducible-example $\endgroup$
    – buhtz
    Apr 18, 2023 at 14:04
  • 1
    $\begingroup$ I thought it might be that, but your example is by no means "minimal." $\endgroup$
    – whuber
    Apr 19, 2023 at 15:32

1 Answer 1

2
$\begingroup$

Under Tukey's approach, the whiskers are specifically drawn in each direction to the furthest observation from the median that is still within (or equal to) the inner fence. If a point is exactly on the inner fence, the whisker includes it.

A marked point must therefore be outside the inner fences.

That is strictly above on the high side (above the upper inner fence) but strictly below on the low side (below the lower inner fence).

Here's an illustration where there's points above the upper inner fence.

Box plot with calculation of inner fence shows and showing points strictly outside the fences marked with circles

$\endgroup$
3
  • $\begingroup$ Can you please fit your answer to my MWE and give a number. $\endgroup$
    – buhtz
    Apr 18, 2023 at 8:51
  • 6
    $\begingroup$ No. ... That looks like I'd be doing homework. I believe my answer is unambiguous. $\endgroup$
    – Glen_b
    Apr 18, 2023 at 8:52
  • $\begingroup$ I'm far behind homework. I just try to "translate" it into my world. I know Tukey of course. But I don't "speak" math. Also English isn't my nativ language. So I just want to be sure if I understand it correct. My assumption is > upper_limit but I'm not sure without confirmation based on my MWE. $\endgroup$
    – buhtz
    Apr 18, 2023 at 9:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.