octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59636] iqr function does not produce Matlab c


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #59636] iqr function does not produce Matlab compatible output
Date: Mon, 7 Dec 2020 19:44:44 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36

Follow-up Comment #1, bug #59636 (project octave):

simpler example:

Octave 5.2.0 (after peeking, the function appears unchanged in dev):

>> iqr(0:3)
ans =  2
>> iqr(0:4)
ans =  2
>> iqr(0:5)
ans =  3


Matlab 2020b:

>> iqr(0:3)
ans =
     2
>> iqr(0:4)
ans =
    2.5000
>> iqr(0:5)
ans =
     3


some websearching seems to indicate that there can be different arbitrary
choices for definitions of how to calculate quartiles, and how/whether to
interpolate when it doesn't land on an exact value.  

according to the Matlab help for iqr, it is "the difference between the 75th
and 25th percentiles of X" and it does have the prctile function mentioned in
the seealso.

if I do manual iqr:


abs(prctile(x,25,dim)-prctile(x,75,dim))


I get the same output from both octave and matlab, matching matlab, and
working for n-dimensions.

for a vector  abs(diff(prctile(x,[25 75]))) works too and is probably faster,
but would have to figure out the right dimensions for prctile and diff for
n-dim arrays.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59636>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]