Statistics function incorrectly computing median
Ben Abbott
bpabbott at mac.com
Fri Jan 18 22:58:11 CST 2008
On Jan 14, 2008, at 7:17 PM, John W. Eaton wrote:
> On 13-Jan-2008, Ben Abbott wrote:
>
> | I took another look and found a method that is more consistent with
> | the original algorithm. The original calculates the CDF from left to
> | right. So I added an equivalent calculation form right to left, and
> | averaged the two results.
> |
> | I expect the result will be the same calculated by GNU's R.
>
> Why not look at the R code for this function and see what it is doing?
>
> jwe
I looked at the routines in R and Maxima and have concluded that they
assume the probability of each sample is a constant; i.e. 1/(# of
samples).
The routine "discrete_inv (x, v, p)" permits the user the specify the
probability of each sample.
Thus, it took some time to determine a method that was consistent with
constant probability and variable probability.
Before, submitting a formal patch, I thought it wise to attach a
script for testing.
The equivalent commands in Octave, R, and Maxima are
Octave: discrete_inv ([1/4 2/4 3/4], <v>, ones (size (<v>)) / numel
(<v>))
GNU R: summary ( c( <v> ) )
Maxima: load( discriptive )$
quantile ( <v>, 1/4), numer;
quantile ( <v>, 2/4), numer;
quantile ( <v>, 3/4), numer;
Where <v> is to be replaced by a sequence like; [1, 2, 3, 4].
I've compared the result for a few examples. It appears to now be
working properly. However, I've been wrong before, so ....
Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080118/44fe9a5c/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: discrete_inv.m
Type: application/octet-stream
Size: 2893 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080118/44fe9a5c/attachment.obj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080118/44fe9a5c/attachment-0001.html
More information about the Bug-octave
mailing list