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

SciPy Trac scipy-tickets@scipy....
Sat Apr 9 09:30:36 CDT 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:               |  

Comment(by josefpktd):

 Besides using numpy.random.poisson, in your case you could just create
 random variables for the non-zero pixels, something like (not tested)

 mask = source_image > 0

 obs = np.zeros_like(source_image)
 obs[mask] = poisson.rvs(source_image[mask])

 That would save on calculating degenerate random variables.
 This is easy enough to do with rvs, but if we change _argcheck to allow
 for the degenerate case mu=0, we would have to patch all methods for this
 in a similar way.

 That's possible, and there are similar corner cases for other
 distributions. However, I worry that this will slow down the standard case
 for these distributions.

 A patch with performance timing would be useful for these cases, since I
 never checked what the performance penalty for including and special
 casing corner cases is.
 (My guess is that the reduction in speed might be large for distributions
 that rely on generic calculations, which need to call the _* methods
 thousands of times, but maybe not so high for distributions that have
 explicit formulas for all the main methods.)

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

More information about the Scipy-tickets mailing list