If I understand median, the convential median index is

  median_index=: (<.~.@,>.)@(0.5 * # - 1:)

This gives you indices into the sorted list.

This is also apparently an arbitrary convention.

Based on the current description at
http://en.wikipedia.org/wiki/Quantile the general approach apparently
looks like this:

  quantile_indices=: >.@((%~ }.@i.)@[ * #@]) - 1:


  2 quantile_indices  i.100
49
  3 quantile_indices i.100
33 66
  4 quantile_indices  i.100
24 49 74

--
Raul

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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to