median of even-number sized lists

Bugs

Modérateur : xcasadmin

lukamar
Messages : 331
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

median of even-number sized lists

Message par lukamar » lun. janv. 29, 2018 3:11 am

Hello,

I've noticed that median command is producing the result 3 for the list [1,2,3,4,5,6]. But since its size is an even number, shouldn't the median be equal to the arithmetic mean of the elements surrounding the "middle" of the list, in this case 3.5 (Octave, for example, returns this result)?

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: median of even-number sized lists

Message par parisse » lun. janv. 29, 2018 8:32 am

There are several definitions for median, the precise definition is not important to do descriptive statistics. I have selected the simplest to implement (and it also has the advantage that it can be extended to every kind of objects with an ordering, not necessarily requiring arithmetic operations).

lukamar
Messages : 331
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Re: median of even-number sized lists

Message par lukamar » lun. janv. 29, 2018 12:20 pm

Thanks for the explanation. Now it's also clear why Octave developers chose the definition returning 3.5 in the above case, as they are focused almost exclusively on floating point computation.

Répondre