bugGNU Octave - Bugs: bug #59410, [octave forge] (statistics)...

 
 

bug #59410: [octave forge] (statistics) geomean with NaN

Submitted by:  Armin Müller <arm_in>
Submitted on:  Tue 03 Nov 2020 07:45:07 PM UTC  
 
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  5.2.0 Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Fri 13 Nov 2020 09:04:20 PM UTC, comment #7: 

Matlab r2020b:

>> format compact
>> geomean([+Inf 1 2 3])
ans =
   Inf
>> geomean([-Inf 1 2 3])
Error using geomean (line 27)
X may not contain negative values or complex values.
>> geomean([NaN 1 2 3])
ans =
   NaN
>> geomean([NaN 1 2 3], 'omitnan')
ans =
    1.8171
>>

Philip Nienhuis <philipnienhuis>
Project Member
Fri 13 Nov 2020 04:47:55 PM UTC, comment #6: 

It looks like matlab mean function that has a omitnan flag [1]

[1] https://www.mathworks.com/help/matlab/ref/mean.html#buql3m_

John Donoghue <lostbard>
Project Member
Fri 13 Nov 2020 01:56:33 PM UTC, comment #5: 

Thanks for testing.
I understand that this is a change in behavior. But reading their documentation, it looks like this is compatible behavior (at least for `geomean`).
I don't have access to the statistics toolbox in Matlab. So it would be nice if someone could verify that this is the case.

The 'g' switch is an Octave extension to the `mean` function. There are arguments in favor of and against failing on NaN input. But I'd argue that if mean without the 'g' switch doesn't fail for NaN input, it shouldn't fail with the 'g' switch either...

Markus Mützel <mmuetzel>
Project Member
Fri 13 Nov 2020 01:48:48 PM UTC, comment #4: 

With the patch:

mean([NaN 1 2 3], 'g')
ans = NaN

geomean([NaN 1 2 3])
ans = NaN

John Donoghue <lostbard>
Project Member
Thu 12 Nov 2020 01:49:33 PM UTC, comment #3: 

Or maybe simpler like this.

(file #50258)

Markus Mützel <mmuetzel>
Project Member
Thu 12 Nov 2020 01:45:23 PM UTC, comment #2: 

If I correctly understand the MathWork's documentation for `geomean`, it doesn't fail on NaN values.
If `mean (x, "g")` should behave the same way as `geomean (x)`, we could use the attached change.

(file #50257)

Markus Mützel <mmuetzel>
Project Member
Thu 12 Nov 2020 01:05:30 PM UTC, comment #1: 

The geomean function is just calling octave mean function in its geomean mode and displaying its message, which is what the docs say it does.

octave:1> mean([NaN 1 2 3], 'g')
error: mean: X must not contain any negative values
error: called from
    mean at line 158 column 9

The documentation could perhaps update to say that, or the octave mean documentation?

John Donoghue <lostbard>
Project Member
Tue 03 Nov 2020 07:45:07 PM UTC, original submission:  

Octave 5.2.0
statistics 1.4.1

>> geomean([0 1 2 3])
ans = 0

=> looks OK

>> geomean([+Inf 1 2 3])
ans =  Inf

=> looks OK

>> geomean([-Inf 1 2 3])
error: mean: X must not contain any negative values
error: called from
    mean at line 158 column 9
    geomean at line 28 column 7

=> correct error message

>> geomean([NaN 1 2 3])
error: mean: X must not contain any negative values
error: called from
    mean at line 158 column 9
    geomean at line 28 column 7

=> Misleading. There is no negative value.

Armin Müller <arm_in>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50257:  bug59410_geomean.patch added by mmuetzel (741B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by arm_in (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-11-12 mmuetzel Attached File- => Added bug59410_geomean_v2.patch, #50258
    2020-11-12 mmuetzel Attached File- => Added bug59410_geomean.patch, #50257
    2020-11-12 lostbard Operating SystemMicrosoft Windows => Any
    2020-11-04 siko1056 Summarygeomean with NaN => [octave forge] (statistics) geomean with NaN

    Back to the top


    Powered by Savane 3.5