Statistics function incorrectly computing median
Miguel Garcia-Blanco
miguel.01 at ihug.com.au
Tue Jan 22 09:27:29 CST 2008
> Due to the need for consistency between the group of functions,
> empirical_inv/pdf/cdf/rnd, I'm leaning your way.
>
> Although, I'm still unhappy that discrete_inv does not determine a median
> that is consistent with the commonly accepted definition. So I'll try to
> resolve that as well.
I don't think this will be a big issue once prctile/quantile have been
written. Besides, it conforms with MATLAB protocol regarding inverse cdf:
"For discrete distributions, there may be no outcome whose cdf value is the
input cumulative probability. In these cases, the inverse cdf returns the
first outcome whose cdf value equals or exceeds the input cumulative
probability." [1]
> How is the following list for a short plan?
>
> (1) Add prctile.m
> (2) Add quantile.m
> (3) Change to statistic.m (call quantile.m)
Looks good.
> (4) Modify discrete_inv.m to use R's method #2
> (5) Verify consistency of discrete_pdf/cdf/rnd.
Be aware that changing discrete_inv.m will also change empirical_inv.m
(currently working as expected) and unidinv.m (currently conforms with
MATLAB: "X = unidinv(P,N) returns the smallest positive integer X such that
the discrete uniform cdf evaluated at X is equal to or exceeds P." [2]).
[1] http://www.mathworks.com/access/helpdesk/help/toolbox/stats/f4218.html
[2] http://www.mathworks.com/access/helpdesk/help/toolbox/stats/unidinv.html
-Miguel
More information about the Bug-octave
mailing list