median 3 5 5 3 0 NB. wrong
5
   median 0 3 3 5 5 NB. right
3

Follow my advice: don't write a correct definition for median! The median is a 
discontinuous function. The fix for even number of numbers solves no problem. 
Don't support bad design with good programming!

--- Den lør 25/9/10 skrev Don Guinn <dongu...@gmail.com>:

Fra: Don Guinn <dongu...@gmail.com>
Emne: Re: [Jprogramming] Median
Til: "Programming forum" <programming@jsoftware.com>
Dato: lørdag 25. september 2010 05.35

median=:[:-:[:+/]{~[:(<.,>.)[:-:[:<:#

On Fri, Sep 24, 2010 at 9:33 PM, Kip Murray <k...@math.uh.edu> wrote:

> The median of list 0 1 2 3 4 is 2 (the middle element), and the median of 0
> 1 2
> 3 is 1.5 (average of the two middle elements).  Therefore the definition of
> median given in Phrases 10C. Math and Stats is incorrect:
>
>    median =: <....@-:@# { /:~
>
>    median 0 1 2 3 4
> 2
>    median 0 1 2 3
> 2
>
> So, write a correct definition for median!  --Kip Murray
>
> ----------------------------------------------------------------------
> 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