0

I'm trying to understand a little more about how Octave calculates quartiles and interquartile range. Consider the following:

A=[1 4 7 10 14];
quantile(A, [0.25 0.75])
    ans = 3.2500   11.0000

This result seems consistent with Method 3 on the Wikipedia page about quartiles. Given that the interquartile range is Q3-Q1, I'd expect the result to be 7.75.

However, running iqr(A) gives a result of 6. Clearly this is calculated from 10 minus 4 from the original data, which is consistent with Method 2 from the same Wikipedia page.

What is the reason for using two different methods for calculating Q1 and Q3?

Michael McMullin
  • 1,450
  • 1
  • 14
  • 25
  • 1
    `help quantile` lists the methods that Octave supplies for calculating quantiles. As for `iqr()` - the documentation does not state the method. – stephematician Oct 31 '16 at 12:12
  • @StephenWade That's useful to know. So it seems that `quantile` can optionally specify which method to use, but `iqr` cannot. Strange that they have different defaults though. – Michael McMullin Nov 01 '16 at 22:25
  • I had a quick look, `iqr()` calculates quantiles using `discrete_inv()` rather than the `quantile()` function. Not sure why this is. They should probably clean this up. – stephematician Nov 01 '16 at 23:31

0 Answers0