[CHANGESET]: Statistics function incorrectly computing median

Ben Abbott bpabbott at mac.com
Wed Mar 5 20:44:25 CST 2008


On Mar 5, 2008, at 4:50 PM, John W. Eaton wrote:

> On 28-Feb-2008, Ben Abbott wrote:
>
> | changeset is attached.
>
> | +2008-02-28  Ben Abbott <bpabbott at mac.com>
> | +
> | +	* statistics/base/statistics.m: Modified to calculate median and
> | +	  quantiles in a manner consistent with method #7 used by GNU's R.
> | +	* statistics/base/__quantile__.m: New function.
> | +	* statistics/base/quantile.m: New function. Matlab compatible.
> | +	* statistics/base/prctile.m: New function. Matlab compatible.
> | +	* miscellaneous/dimfunc.m: New function. Operate on a specific
> | +	  dimension of an N-d array.
>
> The part of this patch that I'm not sure about is dimfunc.  Is that
> really necessary?  If I understand the way it works, it seems that it
> will be really slow to have nested loops and calling a function
> repeatedly instead of working on the full array.  Is there no way to
> avoid this using permute/ipermute to rearrange the data before/after
> processing?
>
> jwe

Ok, I spent some time with permute, and did manage a cleaner  
implementation. However, it still relies on a similar concepts ...  
meaning I couldn't find an method to directly work on the full array.

The problem lies in two details regarding "func"

(1) "func" is assumed to only operate on vectors.
(2) "func" is assumed to return a vector, whose length is not  
generally known ahead of time.

I could eliminate the dimfunc.m, but that would only result in placing  
the loop in __quantile__m. In the future if another script requires  
such functionality, duplication of similar code will be needed.

John or anyone else, any ideas for advice? Is there a better approach?

An updated changeset is attached.

Ben


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: changeset-statistics.txt
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080305/8c66878b/attachment-0001.txt 
-------------- next part --------------



More information about the Bug-octave mailing list