3
$\begingroup$

I'm a programmer, so apologies if this is a bad question. I'm writing some code that needs to detect outliers. I am currently calculating first and third quartiles. In a sample set of data, I have the following numbers:

179,179,179,178,177

The median comes out to 179 and the first quartile 178, but since there is no number above the median what should I do? Or what if all the numbers were the same? Is the quartile the median? This is my reference.

$\endgroup$

1 Answer 1

2
$\begingroup$

Yes. Essentially you are looking for the data value in the position where ~75% of the data lies below. For five pieces of data, 75% would be .75(5) = 3.75, so take the 4th data value (from lowest to highest). This would give you the 179.

$\endgroup$
3
  • $\begingroup$ I'm calculating the first quartile by saying 1. Give me the median of the numbers. 2. Give me all the numbers below that. 3. Give me the median of those numbers. Is this acceptable or should I use something like the percentages and index method you mentioned? $\endgroup$ Feb 24, 2016 at 21:53
  • 1
    $\begingroup$ For computer programming, it may end up more efficient to put your data into an ordered list/array and look for the correct index. You can avoid having to create new lists in your calls to the 'median' function this way and if you have any interest in other percentiles as well, you could probably just create a single function to find the xxx-th percentile and feed it xxx = .500, xxx = .250, etc. when you want to find median, quartiles, etc. $\endgroup$ Feb 24, 2016 at 21:58
  • $\begingroup$ Great idea, thanks!!! $\endgroup$ Feb 24, 2016 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .