Statistics function incorrectly computing median

Miguel Garcia-Blanco miguel.01 at ihug.com.au
Sun Jan 6 10:03:22 CST 2008


>>> What would the 1st quartile, median and 3rd quartile be for a
>>> population of [0, 1, 2, 3, 4, 5]?
>>>
>>> My first impression would be 1.25, 2.5, and 3.75.

I don't know about the quartiles, but 2.5 agrees with the only definition I
can find for sample median [1]. As for the population median, the
distribution is symmetric so the median should coincide with the population
mean (mu = 2.5).

The statistical package R (GNU S) gives:
> x <- c(0, 1, 2, 3, 4, 5)
> quantile( x )
  0%  25%  50%  75% 100%
0.00 1.25 2.50 3.75 5.00
> summary( x )
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   0.00    1.25    2.50    2.50    3.75    5.00

[1] Equation (1) at http://mathworld.wolfram.com/StatisticalMedian.html (The
same definition is also given in "John E. Freund's Mathematical Statistics
with Applications" by Miller and Miller.)

-Miguel


More information about the Bug-octave mailing list