[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51059] hist3 function doesn't handle NaN inpu
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #51059] hist3 function doesn't handle NaN inputs properly |
Date: |
Thu, 18 May 2017 10:11:49 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?51059>
Summary: hist3 function doesn't handle NaN inputs properly
Project: GNU Octave
Submitted by: None
Submitted on: Thu 18 May 2017 02:11:47 PM UTC
Category: Octave Forge Package
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Alastair Harrison
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.2.1
Operating System: Any
_______________________________________________________
Details:
In statistics 1.3.0, hist3 doesn't appear to do the right thing for inputs
containing NaN values. The code appears to try to ignore input rows containing
NaN values, but instead it ends up turning the input matrix into a column
vector with NaNs removed.
Reproduce like this:
>> X = [1 1; nan 2; 3 1; 3 3; 1 nan; 3 1]
X =
1 1
NaN 2
3 1
3 3
1 NaN
3 1
>> result = hist3(X)
error: inits(2): out of bound 1
error: called from
hist3>edges_from_nbins at line 190 column 11
hist3 at line 121 column 24
I think the problem is on line 97:
94: if (! ismatrix (X) || columns (X) != 2)
95: error ("hist3: X must be a 2 columns matrix");
96: endif
97: X(any (isnan (X), 2)) = [];
-verbatim+
Should be:
94: if (! ismatrix (X) || columns (X) != 2)
95: error ("hist3: X must be a 2 columns matrix");
96: endif
97: X(any (isnan (X), 2), :) = [];
-verbatim+
Here's a unit test that exercises the NaN-suppression code:
%!test
%! D = [1 1; nan 2; 3 1; 3 3; 1 nan; 3 1];
%! [c, nn] = hist3 (D, {0:4, 0:4});
%! exp_c = zeros (5);
%! exp_c([7 9 19]) = [1 2 1];
%! assert (c, exp_c);
%! assert (nn, {0:4, 0:4});
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51059>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #51059] hist3 function doesn't handle NaN inputs properly,
anonymous <=