PATCH: Statistics function incorrectly computing median
Ben Abbott
bpabbott at mac.com
Mon Jan 28 21:52:38 CST 2008
Here's the ChangeLog, patch, and new files (I've zipped them with
their directory structure in place).
2008-01-23 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.
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 29 Jan 2008 03:42:57 -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 29 Jan 2008 03:42:57 -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: scripts.zip
Type: application/zip
Size: 9575 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080128/b4ece416/attachment.zip
-------------- next part --------------
More information about the Bug-octave
mailing list