bugGNU Octave - Bugs: bug #46238, normrnd() produces NaN for 0 in...

 
 

bug #46238: normrnd() produces NaN for 0 in standard deviation vector

Submitter:  None
Submitted:  Sat 17 Oct 2015 03:36:02 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Robert Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Sat 17 Oct 2015 04:14:28 PM UTC, comment #1: 

Thanks for catching this.  Obviously the scalar and vector cases were meant to be the same, but a probable typo let in the error.

I've fixed this on the stable branch of Octave and it will be part of the next 4.0.1 bug fix release.  You can either wait until then, or use the m-file directly from the Mercurial stable repository.

Rik <rik5>
Group administrator
Sat 17 Oct 2015 03:36:02 PM UTC, original submission:  

When calling normrnd() with 0 standard deviation on scalar arguments, it (correctly) returns the given mean, e.g.

>> normrnd(10, 0)
ans =  10


However, when called with vector arguments, the elements where the standard deviation is 0 are replaced by NaN, e.g.

>> normrnd([10 10 10 10], [1 0 1 0])
ans =

   9.5101      NaN   7.9095      NaN


The issue is on line 93 or normrnd.m:

k = ! isfinite (mu) | !(sigma > 0) | !(sigma < Inf);

which should be

k = ! isfinite (mu) | !(sigma >= 0) | !(sigma < Inf);

similar to line 86, which deals with scalar arguments:

if (isfinite (mu) && (sigma >= 0) && (sigma < Inf))


Correcting this would make behaviour between scalar and vector operations consistent, and also make normrnd() behave the same way as Matlab.

Anonymous

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    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.

     

    History

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-10-17 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.16-ed84.
    Corresponding source code