PATCH: Statistics function incorrectly computing median
Ben Abbott
bpabbott at mac.com
Fri Feb 1 16:15:52 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 attached the new files and the patch for statistics.m. The new
files now include the N-d array functionality. The only part I haven't
taken care of is where dimfunc.m belongs (which will result in
"dimfunc.m" being listed in the sources of the appropriate Makefile.in).
Ben
2008-02-01 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.
Index: Makefile.in
===================================================================
RCS file: /cvs/octave/scripts/statistics/base/Makefile.in,v
retrieving revision 1.14
diff -u -r1.14 Makefile.in
--- Makefile.in 12 Oct 2007 21:27:26 -0000 1.14
+++ Makefile.in 1 Feb 2008 22:05:28 -0000
@@ -32,11 +32,11 @@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
-SOURCES = center.m cloglog.m cor.m corrcoef.m cov.m cut.m gls.m \
- iqr.m kendall.m kurtosis.m logit.m mahalanobis.m mean.m meansq.m \
- median.m mode.m moment.m ols.m ppplot.m probit.m qqplot.m range.m \
- ranks.m run_count.m skewness.m spearman.m statistics.m std.m \
- studentize.m table.m values.m var.m
+SOURCES = __quantile__.m center.m cloglog.m cor.m corrcoef.m cov.m \
+ cut.m gls.m iqr.m kendall.m kurtosis.m logit.m mahalanobis.m mean.m \
+ meansq.m median.m mode.m moment.m ols.m ppplot.m prctile.m probit.m \
+ qqplot.m quantile.m range.m ranks.m run_count.m skewness.m
spearman.m \
+ statistics.m std.m studentize.m table.m values.m var.m
DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES))
Index: statistics.m
===================================================================
RCS file: /cvs/octave/scripts/statistics/base/statistics.m,v
retrieving revision 1.14
diff -u -r1.14 statistics.m
--- statistics.m 12 Oct 2007 21:27:27 -0000 1.14
+++ statistics.m 1 Feb 2008 22:05:28 -0000
@@ -74,7 +74,7 @@
endwhile
rng = [0 : c-1] * stride + offset + offset2 * stride * c;
rng2 = [0 : 2] * stride + offset + offset2 * stride * 3;
- emp_inv(rng2) = empirical_inv ([0.25; 0.5; 0.75], X(rng));
+ emp_inv(rng2) = __quantile__ ([0.25; 0.5; 0.75], X(rng), 7);
endfor
S = cat (dim, min (X, [], dim), emp_inv, max (X, [], dim), mean
(X, dim),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newfiles.tar.gz
Type: application/x-gzip
Size: 5558 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080201/609bdc49/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: statistics.ChangeLog
Type: application/octet-stream
Size: 448 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080201/609bdc49/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: statistics.patch
Type: application/octet-stream
Size: 1776 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080201/609bdc49/attachment-0001.obj
More information about the Bug-octave
mailing list