[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #46238] normrnd() produces NaN for 0 in standa
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #46238] normrnd() produces NaN for 0 in standard deviation vector |
Date: |
Sat, 17 Oct 2015 15:36:04 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0 |
URL:
<http://savannah.gnu.org/bugs/?46238>
Summary: normrnd() produces NaN for 0 in standard deviation
vector
Project: GNU Octave
Submitted by: None
Submitted on: Sat 17 Oct 2015 03:36:02 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Robert
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0
Operating System: Any
_______________________________________________________
Details:
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.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?46238>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #46238] normrnd() produces NaN for 0 in standard deviation vector,
anonymous <=