Tk Library Source Code

View Ticket
Login
Ticket UUID: 1838703
Title: cdf-normal gives div-by-zero for arg = 0
Type: Bug Version: None
Submitter: erickb Created on: 2007-11-26 13:42:57
Subsystem: math :: statistics Assigned To: arjenmarkus
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-11-16 15:20:56
Resolution: Fixed Closed By: arjenmarkus
    Closed on: 2009-11-16 08:20:56
Description:
Hello,

The cdf-normal function gives a divide-by-zero error for the following call (which should return 0.5):

::math::statistics::cdf-normal 0 1 0

The problem appears to arise in Cdf-toms322, where the internal variables w and p become zero, and then one is divided by the other.

Eric
User Comments: arjenmarkus added on 2009-11-16 15:20:56:

allow_comments - 1

Closing this issue - the new method avoids this

erickb added on 2007-11-26 21:54:37:
Logged In: YES 
user_id=816411
Originator: YES

I can do the quick-and-dirty workaround no problem. Thanks! I just wanted to bring it to your attention.

Take care,
Eric

arjenmarkus added on 2007-11-26 21:29:18:
Logged In: YES 
user_id=400048
Originator: NO

No, I assumed it was because that is a common mistake with converting Fortran or C code to Tcl.
However, we are in some limit situation for the algorithm. The quick-and-dirty solution is treat 
x=0 as a special case.

erickb added on 2007-11-26 21:21:36:
Logged In: YES 
user_id=816411
Originator: YES

Apparently not an integer problem:

 ::math::statistics::cdf-normal 0.0 1.0 0.0

gives the same error.

arjenmarkus added on 2007-11-26 21:01:01:
Logged In: YES 
user_id=400048
Originator: NO

I will have a look at it - perhaps a problem with integer values (rather than floats)?