[Scipy-tickets] [SciPy] #1881: Binomial and Bernoulli in scipy.stats.distributions do not accept probability 0 or 1

SciPy Trac scipy-tickets@scipy....
Fri Mar 29 09:55:30 CDT 2013


#1881: Binomial and Bernoulli in scipy.stats.distributions do not accept
probability 0 or 1
--------------------+-------------------------------------------------------
 Reporter:  Sytse   |       Owner:  somebody   
     Type:  defect  |      Status:  new        
 Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  0.11.0     
 Keywords:          |  
--------------------+-------------------------------------------------------
 The _argcheck function allows for parameter values pr=0 and pr=1. In
 practice these values lead to runtime warnings. Therefore either the
 parameter values 0 and 1 should not be allowed or special attention should
 be given to these cases in the code (which I prefer).

 Warning messages:

 In [1]: import scipy.stats.distributions as dist[[BR]]
 In [2]: bn=dist.binom(10,0)[[BR]]
 In [3]: print(bn.pmf(0),bn.pmf(10),bn.stats())

 /usr/lib/python3/dist-packages/scipy/stats/distributions.py:5669:
 RuntimeWarning: divide by zero encountered in log
   return combiln + k*np.log(pr) + (n-k)*np.log(1-pr)
 /usr/lib/python3/dist-packages/scipy/stats/distributions.py:5669:
 RuntimeWarning: invalid value encountered in multiply
   return combiln + k*np.log(pr) + (n-k)*np.log(1-pr)
 /usr/lib/python3/dist-packages/scipy/stats/distributions.py:5688:
 RuntimeWarning: divide by zero encountered in double_scalars
   g1 = (q-pr) / sqrt(n*pr*q)
 /usr/lib/python3/dist-packages/scipy/stats/distributions.py:5689:
 RuntimeWarning: divide by zero encountered in double_scalars
   g2 = (1.0-6*pr*q)/(n*pr*q)
 /usr/lib/python3/dist-packages/scipy/stats/distributions.py:5399:
 RuntimeWarning: invalid value encountered in double_scalars
   mu3 = g1*(mu2**1.5)
 nan 0.0 (array(0.0), array(0.0))

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


More information about the Scipy-tickets mailing list