median=: -:@(+/)@((<. , >.)@midpt { /:~)
   medianindex=: >.@-:@#
   medianindex 1 2 3 4 5 6 7 8 9 10
5
   medianindex 1 2 3 4 5 6 7 8 9 10 11
6
   qu =: median@(-@medianindex {. ])
   ql =: median@(  medianindex {. ])
   (ql,median,qu) 1 2 3 4 5 6 7 8 9 10
3 5.5 8
   (ql,median,qu) 1 2 3 4 5 6 7 8 9 10 11
3.5 6 8.5


On Tue, Jan 10, 2012 at 1:16 PM, Roger Hui <[email protected]> wrote:
> Yes, but if you are writing a verb to compute the median, what are the
> results of:
>   median 1 2 3 4 5 6 7 8 9 10
>   median 1 2 3 4 5 6 7 8 9 10 11
>
>
>
> On Tue, Jan 10, 2012 at 9:57 AM, Brian Schott <[email protected]>wrote:
>
>>
>>
>> Think of the median as its position in the ordered list, not as the number
>> in that position. Then to compute the quartiles, only use the values in
>> positions above and below the position of the median. So for example if
>> there are three numbers that all equal the median, only the middle one has
>> the median's position.
>>
>> ---
>> (B=)
>>
>> On Jan 10, 2012, at 11:58 AM, Roger Hui <[email protected]> wrote:
>>
>> > Thanks to you and all other respondents for their helpful replies.
>> >
>> > Do Moore & McCabe offer any guidance on how to compute the medians?
>> > Wikipedia says "there is no universal agreement on choosing the quartile
>> > values".  As well, in computing the IQR I have seen methods that make
>> sense
>> > to me but are quite tricky depending on whether #x is odd or even.
>> >
>> > e.g Suppose x is 1 2 3 4 5, 6 7 8 9 10.  The descriptions I have seen say
>> > that the median is 5.5.  When you then compute the median of the lower
>> half
>> > (q1), you exclude the 5.5, and report that q1 is 3, and likewise q3 is 8.
>> > In contrast, if y is 1 2 3 4 5, 6, 7 8 9 10 11, the median is 6, but when
>> > you compute q1 you *include* the 6 with the lower half, and report that
>> q1
>> > is 3.5, likewise you include 6 with the upper half so that q3 is 8.5.
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm



-- 
(B=) <-----my sig
Brian Schott
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to