bugGNU Octave - Bugs: bug #42062, normrnd returns NaN for sigma=0

 
 

bug #42062: normrnd returns NaN for sigma=0

Submitted by:  None
Submitted on:  Sun 06 Apr 2014 11:09:25 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: MattOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.4
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 09 Apr 2014 03:16:50 AM UTC, comment #4:

I fixed this on the development branch in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/ac75140f2c97). It will be a part of the 4.2 release. If you want to see the change earlier you can grab the m-file from the online Mercurial repository and replace your local copy of normrnd.m with the newer one.

Rik <rik5>
Project Administrator
Tue 08 Apr 2014 03:57:38 AM UTC, comment #3:

Sorry for the missing info.
Compatibility testing was done on both R2010b and R2011, and both return:

+Verbatim+

>> normrnd(1,0)


ans =

1
-Verbatim-

Matlab R2010b and R2011 return

+Verbatim+

>> normpdf(1,1,0)


ans =

NaN
-Verbatim-

I agree that normpdf should behave this way, but still think normrnd should not. I could be persuaded it is only a compatibility issue (and I have sanitized inputs to work around compatibility issues for the moment).

Matt <oconnmat>
Mon 07 Apr 2014 03:54:50 PM UTC, comment #2:

Matlab r2009b returns NaN
but I think they have changed that in
more recent versions...

Michael Godfrey <godfrey>
Project Member
Mon 07 Apr 2014 03:00:25 PM UTC, comment #1:

Which version of Matlab are you using for compatibility testing?

Also, what does the following return under your version of Matlab?

I had compatibility testing done for a lot of corner cases during the overhaul of the statistical functions between 3.4.X and 3.6.X. But, Matlab is a moving target and they may have changed things once again for certain boundary cases.

Rik <rik5>
Project Administrator
Sun 06 Apr 2014 11:09:25 PM UTC, original submission:

Can reproduce by using command:

normrnd should return mu when sigma=0, not NaN

Output expected:

This is inconsistent with the definition of the normal distribution, and also inconsistent with Matlab's results.

I think the problem is in the normrnd.m file when testing whether sigma has a valid value. It does not include 0, only >0.

Specifically the parts of the code below

and

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by oconnmat (Posted a comment)
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 09 Apr 2014 03:16:50 AM UTCrik5Item GroupIncorrect Result=>Matlab Compatibility
      StatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Mon 07 Apr 2014 03:00:25 PM UTCrik5StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1