# [Scipy-tickets] [SciPy] #1614: logcdf function of normal distribution (scipy.stats) can not handle a wide enough range of values

SciPy Trac scipy-tickets@scipy....
Fri Mar 2 13:13:05 CST 2012

```#1614: logcdf function of normal distribution (scipy.stats) can not handle a wide
enough range of values
-------------------------------------+--------------------------------------
Reporter:  andrewschein             |       Owner:  somebody
Type:  defect                   |      Status:  new
Priority:  normal                   |   Milestone:  Unscheduled
Component:  scipy.stats              |     Version:  devel
Keywords:  normal distribution cdf  |
-------------------------------------+--------------------------------------
The R version of this functionality can handle a much much wider range of
negative values which is critical in implementing some features.

Here is an example:

In R:

> pnorm(-50,log.P=TRUE)
Error in pnorm(-50, log.P = TRUE) : unused argument(s) (log.P = TRUE)
> pnorm(-50,log.p=TRUE)
[1] -1254.831
> pnorm(-10,log.p=TRUE)
[1] -53.23129
> pnorm(-100,log.p=TRUE)
[1] -5005.524
> pnorm(-1000,log.p=TRUE)
[1] -500007.8
> pnorm(-10000,log.p=TRUE)
[1] -50000010
> pnorm(-10000000000,log.p=TRUE)
[1] -5e+19

However in scipy:

>>> from scipy.stats import norm
>>> n = norm()
>>> n.logcdf(-30)
-454.32124395634327
>>> n.logcdf(-40)
Warning: divide by zero encountered in log
-inf
>>> n.logcdf(-100)
Warning: divide by zero encountered in log
-inf
>>>

etc.  Note that the R documentation for pnorm provides a reference for the
algorithm that is implemented.

I am sure this affects a wide variety of things, but one simple example
where having the wider range is critical is in implementation of a
censored regression log-likelihood.

Andrew Schein

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1614>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```