Statistics function incorrectly computing median
Ben Abbott
bpabbott at mac.com
Sun Jan 6 10:52:02 CST 2008
On Jan 7, 2008, at 12:03 AM, Miguel Garcia-Blanco wrote:
>>>> 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).
Regarding the median, it also agrees with the definition given by
Wikipedia.
In probability theory and statistics, a median is described as the
number separating the higher half of a sample, a population, or a
probability distribution, from the lower half. The median of a finite
list of numbers can be found by arranging all the observations from
lowest value to highest value and picking the middle one. If there is
an even number of observations, the median is not unique, so one often
takes the mean of the two middle values.
> 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
I can duplicate those results by using a slightly different approach.
However, I'd like to do some more tests. I don' t have R installed,
nor am I familiar with using it.
Please see the attached file and compare my results to R .... and I'd
like to see the results if they differ from mine.
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080107/5eefa37c/attachment-0002.html
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example.txt
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080107/5eefa37c/attachment-0001.txt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080107/5eefa37c/attachment-0003.html
More information about the Bug-octave
mailing list