Statistics function incorrectly computing median

Ben Abbott bpabbott at mac.com
Wed Jan 30 08:10:37 CST 2008


On Jan 29, 2008, at 2:14 AM, John W. Eaton wrote:
>
> Shouldn't prctile and quantile work on N-d arrays?  The Matlab docs
> state that they work along the first non-singleton dimension.
>
> jwe


I've put together versions that respect N-d arrays.

I've attached the modified quantile script for testing.

Michael (others?), can you compare to Matlab?

TiA
Ben

octave:233> x = rand (3, 3, 3)
x =

ans(:,:,1) =

    0.680468   0.022382   0.224171
    0.077212   0.146276   0.058310
    0.066047   0.304877   0.802009

ans(:,:,2) =

    0.947847   0.325217   0.633529
    0.212279   0.048299   0.257263
    0.306260   0.548877   0.049451

ans(:,:,3) =

    0.88600   0.31381   0.62981
    0.13051   0.41215   0.41175
    0.66807   0.99439   0.89204

octave:234> quantile (x, [0.25, 0.50, 0.75], 2)
ans =

ans(:,:,1) =

    0.072829   0.224171   0.566393
    0.063036   0.077212   0.129010
    0.125755   0.304877   0.677726

ans(:,:,2) =

    0.402295   0.633529   0.869268
    0.089294   0.212279   0.246017
    0.113654   0.306260   0.488222

ans(:,:,3) =

    0.39281   0.62981   0.82195
    0.20082   0.41175   0.41205
    0.72406   0.89204   0.96880


-------------- next part --------------
A non-text attachment was scrubbed...
Name: dimfunc.m
Type: application/octet-stream
Size: 3798 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080130/d4276c64/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: quantile.m
Type: application/octet-stream
Size: 9047 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080130/d4276c64/attachment-0004.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: __quantile__.m
Type: application/octet-stream
Size: 4943 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080130/d4276c64/attachment-0005.obj 
-------------- next part --------------




More information about the Bug-octave mailing list