(<./;([:m l);m;([: m r);>./)A  NB. out of order
┌─┬───┬───┬─┬─┐
│1│7.5│4.5│2│9│
└─┴───┴───┴─┴─┘
   (<./;([:m l);m;([: m r);>./)/:~A  NB. put in a sort
┌─┬─┬───┬───┬─┐
│1│2│4.5│7.5│9│
└─┴─┴───┴───┴─┘

On Tue, May 6, 2014 at 6:03 AM, Linda Alvord <[email protected]>wrote:

> Doesn't require sstats:
>
>    A=:6 9 3 1
>    B=:6 9 3 1 4
>    l=: 13 :'(i.<.-:#y){y'
>    r=: 13 :'|.(i.<.-:#y){|.y'
>
>    NB. Mid-point and mean thanks to Devon
>    mp=:-:@<:@#
>    m=:-:@(+/)@((<. , >.)@mp { /:~)
>
>    (<./;([:m l);m;([: m r);>./)A
> --T---T---T-T-┐
> │1│7.5│4.5│2│9│
> L-+---+---+-+--
>    (<./;([:m l);m;([: m r);>./)B
> --T---T-T---T-┐
> │1│7.5│4│2.5│9│
> L-+---+-+---+--
>
> Linda
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Joe Bogner
> Sent: Tuesday, May 06, 2014 3:54 AM
> To: [email protected]
> Subject: Re: [Jprogramming] Five Number Summary
>
> From http://webdocs.cs.ualberta.ca/~smillie/Jpage/jsp601.ijs
>
> require 'stats'
> Q2=: median
> Q1=: [: Q2 ] #~ Q2 > ]
> Q3=: [: Q2 ] #~ Q2 < ]
> NB. Summaries
>
> five=: <./,Q1,Q2,Q3,>./
>
>    five 1 3 4 6 9
> 1 2 4 7.5 9
> On May 6, 2014 12:51 AM, "Kip Murray" <[email protected]> wrote:
>
> > The list 6 9 3 1 has left and right sublists 6 9 and 3 1, the list 6 9 3
> 1
> > 4 has left and right sublists 6 9 and 1 4 .  The middle number, if there
> is
> > one, is not included in the left and right sublists.
> >
> > You know the median of 6 9 3 1 is the median of 1 3 6 9 which is 4.5, and
> > the median of 6 9 3 1 4 is the median of 1 3 4 6 9 which is 4.
> >
> > The "fourths" f1 and f4 of a list y are respectively the medians of the
> > left sublist and right sublist of /:~ y .
> >
> > Write a verb to find John Tukey's "five number summary" minimum , f1 ,
> > median, f3 , maximum of a list y.
> >
> > --Kip Murray
> >
> >
> > --
> > Sent from Gmail Mobile
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> 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