Members of the forum -
while looking up some statistical definitions, I came across this example
http://www2.le.ac.uk/offices/ssds/sd/ld/resources/numeracy/variability
in which the calculation of the median disagrees with the result of the one
listed as "m0=: median=: <....@-:@# { /:~" in "MathStats" on the J wiki.
I was actually looking at the definition of quartiles when I noticed this.
For the series
#scrs=. 43 48 50 50 52 53 56 58 59 60 62 65 66 68 70 71 74 76 78 80
20
m0=: <....@-:@# { /:~
m0 scrs
62
median scrs NB. my own definition
61
median
-:@(+/)@((<. , >.)@midpt { /:~)
midpt
-:@<:@#
Also, this site's answers disagree with Excel and with my own quartile
function, applied to "scrs" above, but I think the site is correct:
NB. Quartiles 1-3 according to Excel:
52.75 61 70.25
NB. According to
http://www2.le.ac.uk/offices/ssds/sd/ld/resources/numeracy/variability:
52.5 61 70.5
0 1 2 quartile&><scrs
52 60 70
NB. My "quartile" disagrees with my "median": the middle quartile should be
the same as the median.
quartile
4 : 'x{4 ntilebps y'
ntilebps
4 : 0
NB.* ntilebps: return breakpoint values of x-tiles of y; e.g. 4 ntilebps y
NB. -> quartiles; 0-based so "1st" quartile is 0{4 ntilebps y.
quant=. x
y=. /:~y
wh=. 0 1#:(i.quant)*quant%~#y NB. Where partition points are exactly
'n f'=. |:wh NB. whole and fractional part of
partitions
1|.+/"1 ((1-f),.f)*(n+/_1 0){y NB. "1|." moves top quantile to end.
)
Anyone care to weigh in on this?
Regards,
Devon
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm