Statistics function incorrectly computing median
Ben Abbott
bpabbott at mac.com
Mon Jan 21 10:53:29 CST 2008
On Monday, January 21, 2008, at 09:36AM, "Miguel Garcia-Blanco" <miguel.01 at ihug.com.au> wrote:
>> In the octave scripts, the routines take samples and sample probabilities
>> as inputs.
>>
>> Thus x = [1, 1, 2, 3] & p = [.25 .25 .25 .25] is equivalent to x = [1, 2,
>> 3] & p = [0.5, 0.25, 0.25].
>>
>> As a result, some of the algorithms are not applicable to the
>> architecture of octave's present statistical functions.
>>
>
>I think you may have misunderstood what P is. P is *not* the probability
>distribution for X. P is a scalar or a vector of cumulative probability
>values for determining the quantiles (e.g., P = 0.5 will cause the median to
>be output). Try this example: X = rand(1, 1000); P = [0.1, 0.3, 0.95];
>(You'll have to use 100*P with MATLAB's prctile function.)
>
>-Miguel
>
Miguel,
I wasn't clear ...
I was referring to Octave's statistics functions, specifically discrete_inv.m
heloctave:1> help discrete_inv
-- Function File: discrete_inv (X, V, P)
For each component of X, compute the quantile (the inverse of the
CDF) at X of the univariate distribution which assumes the values
in V with probabilities P.
/sw/share/octave/3.0.0+/m/statistics/distributions/discrete_inv.m
Octave's present algorithms calculate the quantiles from the specified probabilities, P. Thus, it may not always be possible to find a proper algorithm that works for varied probabilities that is consistent with a pre-exiting algorithm that works for constant probabilities.
Ben
More information about the Bug-octave
mailing list