# [Scipy-tickets] [SciPy] #835: nan propagation in stats.distribution

SciPy scipy-tickets@scipy....
Sun Jan 4 13:55:08 CST 2009

```#835: nan propagation in stats.distribution
-----------------------+----------------------------------------------------
Reporter:  josefpktd  |       Owner:  somebody
Type:  defect     |      Status:  new
Priority:  normal     |   Milestone:  0.8.0
Component:  Other      |     Version:  devel
Severity:  normal     |    Keywords:
-----------------------+----------------------------------------------------
stats.distribution methods, cdf,sf and pdf don't propagate NaN, instead
zero is returned. This is misleading for cdf and sf. For pdf, pmf this is
not as misleading, if nans are interpreted as not a number in the support
of the distribution.

example where nan propagation is necessary is for calculating pvalues e.g.
with stats.t.sf

continuous distribution
{{{
>>> stats.t.cdf([0,np.nan,1],10)
array([ 0.5       ,  0.        ,  0.82955343])
>>> stats.t.sf([0,np.nan,1],10)
array([ 0.5       ,  0.        ,  0.17044657])
>>> stats.t.pdf([0,np.nan,1],10)
array([ 0.38910838,  0.        ,  0.23036199])
>>> stats.t.ppf([0,np.nan,1],10)
array([-Inf,  NaN,  Inf])
>>> stats.t.isf([0,np.nan,1],10)
array([ Inf,  NaN, -Inf])
}}}

discrete distribution
{{{
>>> stats.bernoulli.pmf([0,np.nan,1],0.4)
array([ 0.6,  0. ,  0.4])
>>> stats.bernoulli.cdf([0,np.nan,1],0.4)
array([ 0.6,  0. ,  1. ])
>>> stats.bernoulli.sf([0,np.nan,1],0.4)
array([ 0.4,  0. ,  0. ])
>>> stats.bernoulli.ppf([0,np.nan,1],0.4)
array([ -1.,  NaN,   1.])
>>> stats.bernoulli.isf([0,np.nan,1],0.4)
array([  1.,  NaN,  -1.])
}}}

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