[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #42062] normrnd returns NaN for sigma=0
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #42062] normrnd returns NaN for sigma=0 |
Date: |
Sun, 06 Apr 2014 23:09:26 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:28.0) Gecko/20100101 Firefox/28.0 |
URL:
<http://savannah.gnu.org/bugs/?42062>
Summary: normrnd returns NaN for sigma=0
Project: GNU Octave
Submitted by: None
Submitted on: Sun 06 Apr 2014 11:09:25 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Matt
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 3.6.4
Operating System: Microsoft Windows
_______________________________________________________
Details:
Can reproduce by using command:
octave:1> normrnd(1,0)
ans = NaN
normrnd should return mu when sigma=0, not NaN
Output expected:
ans = 1
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
if (!isnan (mu) && !isinf (mu) && (sigma > 0) && (sigma < Inf))
should be
if (!isnan (mu) && !isinf (mu) && !(sigma < 0) && (sigma < Inf))
and
k = isnan (mu) | isinf (mu) | !(sigma > 0) | !(sigma < Inf);
should be
k = isnan (mu) | isinf (mu) | (sigma < 0) | !(sigma < Inf);
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?42062>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #42062] normrnd returns NaN for sigma=0,
anonymous <=