[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #48690] basic statistics functions should retu
From: |
Joel Dahne |
Subject: |
[Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input |
Date: |
Thu, 20 Jul 2017 04:19:51 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0 |
Follow-up Comment #23, bug #48690 (project octave):
I think this is related to bug #51333. All of the functions you are refering
to here can be considered reductions I think.
>From my testing I seen the following rules regarding the dimension from
Matlab.
1. If no specific dimension is specified and the input is not 0x0: set the
first non-singleton dimension to 1 and keep the rest.
This is for example consistent with your example:
>> mean(ones(1,2,2,0,2))
ans =
Empty array: 1-by-1-by-2-by-0-by-2
>> mean(ones(1,0,2,0,2))
ans =
Empty array: 1-by-1-by-2-by-0-by-2
>> mean(ones(1,0,2,1,2))
ans(:,:,1,1,1) =
NaN
ans(:,:,2,1,1) =
NaN
ans(:,:,1,1,2) =
NaN
ans(:,:,2,1,2) =
NaN
2. If no dimension is specified and the input is 0x0: Treat the input as size
0x1 (which means it returs NaN in your cases)
In Matlab
> mean ([])
ans = NaN
> mean (ones (0, 1))
ans = NaN
3. If a dimension is specified: Always set that dimension to one and keep the
rest. NOTE that this means that 0x0 is not handled separately
> mean ([], 1)
ans = Empty matrix: 1-by-0
> mean ([], 2)
ans = Empty matrix: 0-by-1
> mean ([], 3)
ans = Empty matrix: 0-by-0
In the last example it, as usual, chops trailing singleton dimensions
So I think the only things that needs to be changed is that if no dimension is
given it should set the dimension to the first non-singelton dimension (not
the first >1 as it currently is) and also if the input is 0x0 change it
to 0x1 (doing this with resize should respect the input type right?).
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?48690>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input,
Joel Dahne <=
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26
- [Octave-bug-tracker] [bug #48690] basic statistics functions should return NaN on empty input, Nicholas Jankowski, 2017/07/26