bugGNU Octave - Bugs: bug #65802, (statistics) nanmin and nanmax...

 
 

bug #65802: (statistics) nanmin and nanmax throw error when requesting a mutual comparison (two parameter)

Submitter:  None
Submitted:  Tue 28 May 2024 11:42:14 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 21 Jul 2024 09:17:06 PM UTC, comment #8: 

closing as fixed at maintainers request.

Nicholas Jankowski <nrjank>
Group Member
Sun 21 Jul 2024 09:48:40 AM UTC, comment #7: 

This issue can be closed. It has been resolved as of statistics latest release.

Andreas Bertsatos <pr0m1th3as>
Thu 30 May 2024 01:06:31 AM UTC, comment #6: 

I just pushed a commit fixing this bug and also updated the functionality to support VECDIM and 'all' options. It still requires some work to update the texinfo to reflect the updated functionality and BISTs to ensure that it works the way it is supposed to. Anybody with MATLAB access is welcome to contribute to further testing. From MATLAB's documentation, it requires "linear" option in order to return second output when VECDIM is supplied, but I am not sure how this is supposed to work, so I just return the second argument forced through ipermute (similarily to v).

Andreas Bertsatos <pr0m1th3as>
Tue 28 May 2024 07:49:38 PM UTC, comment #5: 

I believe the nanmin and nanmax functions were introduced because the base functions did not not support flexible nan handling.  even matlab's help entries discourage use of the functions [1] recommending min/max and the 'omitnan' flag instead. They added 'omitnan' functionality to many functions, but Octave has yet to implement that flag for most of its compiled functions. I think Andreas was just expressing a similar preference for octave's functions.

Two somewhat separate issues here:

1 - As markus pointed out, matlab does not support
[v, idx] = nanmax (X, Y)
Was this just unintentional function definition copy/paste? Nanmax is just a wrapper to max so that should always fail since there's no definition for that in max.  Whether or not it is expected, idx should be documented.

2 - Even without calling for idx, `nanmin([1,2,NaN, 3],[2,1,NaN, 2])` is calling min for a second output anyway. the logic sholud be changed so it only calls for a second output with (X) or (X, [], dim) formats.





[1] https://www.mathworks.com/help/stats/nanmax.html

Nicholas Jankowski <nrjank>
Group Member
Tue 28 May 2024 05:54:47 PM UTC, comment #4: 

Noticed the full error message hasn't been shown yet.
For completeness:

>> pkg load statistics
>> pkg list statistics
Package Name  | Version | Installation directory
--------------+---------+-----------------------
  statistics *|   1.6.5 | C:\Program Files\GNU Octave\Octave-9.1.90\mingw64\share\octave\packages\statistics-1.6.5
>> nanmin([1,2,NaN, 3],[2,1,NaN, 2])
error: element number 2 undefined in return list
error: called from
    nanmin at line 54 column 16


Markus Mützel <mmuetzel>
Group administrator
Tue 28 May 2024 05:52:23 PM UTC, comment #3: 

Afaict, the issue is that `min(A,B)` doesn't return a second output argument if B is non-empty (same for `max`). I'm not sure what that second output argument should be set to in that case. So, I have no idea which change in core Octave would help. Could you please elaborate?

Also, the current behavior of `max` and `min` is compatible to Matlab R2024a:

>> [v,idx]=min(ones(1,4),zeros(1,4))
Error using min
Two output arguments are not supported for two input arrays.


Markus Mützel <mmuetzel>
Group administrator
Tue 28 May 2024 05:44:09 PM UTC, comment #2: 

Yep, this is a bug. I will look into this and try update the functionality to catch up with the latest changes introduced in the mean and median functions. Although, the best approach would be to update the min max sum functions in libinterp/corefcn/max.cc and libinterp/corefcn/data.cc files of core Octave.

Andreas Bertsatos <pr0m1th3as>
Tue 28 May 2024 12:00:16 PM UTC, comment #1: 

CC'ing package maintainer.

Markus Mützel <mmuetzel>
Group administrator
Tue 28 May 2024 11:42:14 AM UTC, original submission:  

According to the nanmin/nanmax documentation
(https://gnu-octave.github.io/statistics/nanmax.html):

[v, idx] = nanmax (X)
[v, idx] = nanmax (X, Y)

Find the maximal element while ignoring NaN values.
nanmax is identical to the max function except that NaN values are ignored.

Or this does not work when giving two parameter to nanmin/nanmax, which should provide the pairwise minimum/maximum but the functions throw an error instead.

nanmin([1,2,NaN, 3],[2,1,NaN, 2])
error: element number 2 undefined in return list


Pairwise minimum/maximum works for the octave standard min/max function (and by NaN comparison rules already provide the expected result...)

min([1,2,NaN, 3],[2,1,10, NaN])
ans =

    1    1   10    3


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by pr0m1th3as (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by mmuetzel
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-07-21 nrjank StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2024-05-28 mmuetzel StatusNone Need Info
    2024-05-28 mmuetzel Operating SystemGNU/Linux Any
        Summarynanmin and nanmax throw error when requesting a mutual comparison (two parameter) (statistics) nanmin and nanmax throw error when requesting a mutual comparison (two parameter)
        Carbon-Copy- Added pr0m1th3as

    Back to the top

    Powered by Savane 3.14-04e1.
    Corresponding source code