[Scipy-tickets] [SciPy] #1398: problem with numpy 0's in stats.poisson.rvs

SciPy Trac scipy-tickets@scipy....
Tue Mar 1 21:09:02 CST 2011


#1398: problem with numpy 0's in stats.poisson.rvs
-------------------------+--------------------------------------------------
 Reporter:  parejkoj     |       Owner:  somebody
     Type:  defect       |      Status:  new     
 Priority:  normal       |   Milestone:          
Component:  scipy.stats  |     Version:  0.8.0   
 Keywords:               |  
-------------------------+--------------------------------------------------
Changes (by josefpktd):

  * component:  Other => scipy.stats


Comment:

 Thanks, that looks like a bug and a bit strange

 {{{
 >>> stats.poisson.rvs([0], size=10)
 array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 >>> stats.poisson.rvs(np.array([0]), size=10)
 Traceback (most recent call last):
   File "<pyshell#26>", line 1, in <module>
     stats.poisson.rvs(np.array([0]), size=10)
   File
 "C:\Josef\_progs\Subversion\scipy_trunk_g09\dist\scipy-0.10.0.dev7027.win32\Programs\Python25\Lib
 \site-packages\scipy\stats\distributions.py", line 5014, in rvs
     return super(rv_discrete, self).rvs(*args, **kwargs)
   File
 "C:\Josef\_progs\Subversion\scipy_trunk_g09\dist\scipy-0.10.0.dev7027.win32\Programs\Python25\Lib
 \site-packages\scipy\stats\distributions.py", line 570, in rvs
     raise ValueError("Domain error in arguments.")
 ValueError: Domain error in arguments.
 >>> stats.poisson.rvs(0)
 Traceback (most recent call last):
   File "<pyshell#27>", line 1, in <module>
     stats.poisson.rvs(0)
   File
 "C:\Josef\_progs\Subversion\scipy_trunk_g09\dist\scipy-0.10.0.dev7027.win32\Programs\Python25\Lib
 \site-packages\scipy\stats\distributions.py", line 5014, in rvs
     return super(rv_discrete, self).rvs(*args, **kwargs)
   File
 "C:\Josef\_progs\Subversion\scipy_trunk_g09\dist\scipy-0.10.0.dev7027.win32\Programs\Python25\Lib
 \site-packages\scipy\stats\distributions.py", line 570, in rvs
     raise ValueError("Domain error in arguments.")
 ValueError: Domain error in arguments.
 }}}

 Poisson doesn't define an _argcheck, the generic argcheck requires
 strictly positive

 {{{
     def _argcheck(self, *args):
         cond = 1
         for arg in args:
             cond &= (arg > 0)
         return cond
 }}}

 but why does a list go through?

 namespaces - what's that ?

 {{{
         if not all(cond):
             raise ValueError("Domain error in arguments.")
 }}}

 what's all ?
 {{{
 from numpy import alltrue
 }}}
 and somewhere else
 {{{
 all = alltrue
 }}}


 However, independent of the array versus list issue, why to you need a
 degenerate Poisson with lambda/mu exactly equal zero?

 {{{
 >>> stats.poisson.rvs(np.array(1e-15), size=10)
 array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 >>> stats.poisson.rvs(1e-15, size=10)
 array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 }}}

 if mu=0, then pdf, cdf, ... will also be degenerate, and I'm not sure this
 makes sense in the example, and it might break other things. At least it
 needs testing for all methods.
 pmf would have 0*log0

 But I guess it could be made to work, with a probability(k=0)=1

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


More information about the Scipy-tickets mailing list