Sat 20 Feb 2016 05:29:58 AM UTC, comment #9:
I fixed bug #33523 which also solves the problem reported in this bug's summary. Closing report.
|
Thu 21 Jan 2016 07:19:05 AM UTC, comment #8:
Thanks Markus.
For many of those functions, the correct answer is not simply the input. For example, the interquartile range (iqr) is zero if the input is finite, or NaN otherwise.
I'll prepare a patch based on jwe's template in bug #33523.
|
Sun 21 Sep 2014 05:54:27 AM UTC, comment #7:
I've reviewed and reworked sevaral statistic functions (center, iqr, kurtosis, mean, meansq, median, mode) and attached a patch.
There are some functions left with exactly the same if clause. But I even don't know what they are exactly doing, so it's not easy to update the error and assert parts. They are still untouched. This are the files with their issueing line.
histc.m:77: if (!(isscalar (dim) && dim == fix (dim))
moment.m:164: if (!(isscalar (dim) && dim == fix (dim)) ||
prctile.m:65: if (!(isscalar (dim) && dim == fix (dim))
quantile.m:131: if (!(isscalar (dim) && dim == fix (dim))
ranks.m:50: if (!(isscalar (dim) && dim == fix (dim))
run_count.m:53: if (!(isscalar (dim) && dim == fix (dim))
skewness.m:105: if (!(isscalar (dim) && dim == fix (dim)) || !(1 <= dim && dim <= nd))
statistics.m:51: if (!(isscalar (dim) && dim == fix (dim))
std.m:87: if (!(isscalar (dim) && dim == fix (dim))
var.m:87: if (!(isscalar (dim) && dim == fix (dim))
zscore.m:66: if (!(isscalar (dim) && dim == fix (dim))
(file #32152)
|
Sun 14 Sep 2014 02:33:52 PM UTC, comment #6:
I added a file to Attachments.
Unfortunately statistics functions in matlab return not only input array if dimmension is greater than size of array.
For example: function iqr returns zeros array.
I'll try to find and fix some functions.
|
Tue 09 Sep 2014 05:10:51 PM UTC, comment #5:
Thanks for your patch. Please post patches or changesets as attachments to the tracker, otherwise savannah can mangle the meaningful content of your patch.
Also note as I said in comment #1, it would be really nice to fix mean along with other statistics functions that this change also applies to. We try to use consistent idioms and syntax, so it should be easy to find all instances of this dimension error checking in Octave, and check the Matlab documentation to see which functions should also be fixed the same way.
|
Tue 09 Sep 2014 01:27:22 PM UTC, comment #4:
Hi, hear is diff file to fix this:
# HG changeset patch
# User Dmitrey Salnikov <mr.dimas@meta.ua>
# Date 1410269118 -10800
# Tue Sep 09 16:25:18 2014 +0300
# Node ID c40955104bdede20e8d3b31cb99e1273c9e63fd5
# Parent 4630a18757b319688ce52d06917a49063ee3721f
mean fix
diff -r 4630a18757b3 -r c40955104bde scripts/statistics/base/mean.m
--- a/scripts/statistics/base/mean.m Tue Aug 26 15:48:02 2014 -0700
+++ b/scripts/statistics/base/mean.m Tue Sep 09 16:25:18 2014 +0300
@@ -103,8 +103,13 @@
(dim = find (sz > 1, 1)) || (dim = 1);
else
if (!(isscalar (dim) && dim == fix (dim))
- || !(1 <= dim && dim <= nd))
- error ("mean: DIM must be an integer and a valid dimension");
+ || !(1 <= dim))
+ error ("mean: DIM must be an integer and a valid dimension @@ lamazavr");
+ endif
+
+ if (!(dim <= nd))
+ y = x;
+ return;
endif
endif
@@ -155,4 +160,3 @@
%!error mean (1, 0)
%!error mean (1, 3)
%!error mean (1, "b")
-
|
Mon 08 Sep 2014 12:34:07 AM UTC, comment #3:
If you want to contribute to Octave, please read the manual section about contributing, in particular:
https://www.gnu.org/software/octave/doc/interpreter/Basics-of-Generating-a-Changeset.html
|
Sun 07 Sep 2014 10:19:33 AM UTC, comment #2:
Hi, matlab simply returns an input array if dimension is greater than it has.
I want to fix this in code. How can I commit code to repository ?
|
Thu 21 Aug 2014 02:58:36 AM UTC, comment #1:
Thanks for your bug report. Do you have access to Matlab to demonstrate what the expected behavior should be?
According to my reading of the Matlab documentation for mean, it says "mean returns A if dim is greater than ndims(A)". And referring to the help for ndims, trailing singleton dimensions are dropped. Based on that, I would expect the same behavior that you suggest. It would be good to confirm the actual Matlab behavior.
It would also be good to check which other statistical functions that take a dimension argument this would apply to.
|
Thu 21 Aug 2014 02:41:34 AM UTC, original submission:
Dear Octave developers,
Thanks a million for the fantastic software. I just ran across the following error:
>> a = rand(2,2,1);
>> mean(a,3);
error: mean: DIM must be an integer and a valid dimension
error: called from:
error: /usr/share/octave/3.8.1/m/statistics/base/mean.m at line 107, column 7
What happens is that the trailing singleton dimension is removed, and the variable 'a' has only two dimensions, so the error message is in essence correct.
However, this is causing trouble in the code I am currently working on: in my code, in general the third dimension is not a singleton, and the code works fine. But if the third dimension happens to be a singleton (in my case, it codes for the number of parameters I am testing in a simulation), I get an error. I would find it logical for mean(a,3) to return a, instead of an error. Actually, this behaviour would make sense for mean(a,n), with n greater than the number of dimensions of a.
What do you think ? Am I missing a potential issue with the suggested behaviour ?
Best,
Pierre
|