[Scipy-tickets] [SciPy] #519: Valid args give NaN on PPC for stats.norm.cdf, special.ndtr, special.erf

SciPy scipy-tickets@scipy....
Mon Oct 22 15:09:26 CDT 2007


#519: Valid args give NaN on PPC for stats.norm.cdf, special.ndtr, special.erf
---------------------------+------------------------------------------------
 Reporter:  tloredo        |       Owner:  somebody
     Type:  defect         |      Status:  new     
 Priority:  normal         |   Milestone:  0.7     
Component:  scipy.special  |     Version:          
 Severity:  major          |    Keywords:          
---------------------------+------------------------------------------------
 Hello-

 I traced a bug revealed in a test of some new code that uses
 stats.norm to this erroneous behavior of special.ndtr (which
 itself relies on cephes' erf and erfc).

 On Intel machines (I've tried OS X and Linux EL5) all is fine:

 In [1]: from scipy.special import ndtr

 In [2]: ndtr(1.)
 Out[2]: 0.841344746069

 In [3]: arg=(1.2-1.)/.2

 In [4]: arg
 Out[4]: 0.99999999999999978

 In [5]: ndtr(arg)
 Out[5]: 0.841344746069

 Here is the (incorrect) behavior on PPC (OS 10.4.10, Python 2.4.4,
 numpy 1.0.3.1, scipy 0.5.2.1):

 In [1]: from scipy.special import ndtr

 In [2]: ndtr(1.)
 Out[2]: 0.841344746069

 In [3]: arg = (1.2-1.)/.2

 In [4]: arg
 Out[4]: 0.99999999999999978

 In [5]: ndtr(arg)
 Out[5]: nan

 In [6]: ndtr(arg+1.e-16)
 Out[6]: nan

 In [7]: ndtr(arg+2.e-16)
 Out[7]: 0.841344746069

 In [8]: ndtr(arg-1.e-10)
 Out[8]: nan

 In [9]: ndtr(arg-1.e-9)
 Out[9]: 0.841344745827

 I.e, there is a sliver of arguments near (but not at) 1.0 where ndtr
 (or perhaps erf or erfc, which it relies on) misbehaves (giving nan), but
 only on PPC.  Despite the range being very narrow, it's easy to hit as
 simple expressions that are equal to 1.0 truncate to values in the range.

 On scipy-dev, another user has acknowledge problems with erf on PPC,
 in response to a report of the problem above, but without and
 description of the problem.  I haven't explored whether there are
 other "special" problem ranges.

 -Tom

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


More information about the Scipy-tickets mailing list