[Scipy-tickets] [SciPy] #1436: stats.poisson.logpmf(k, loc) numeric overflow

SciPy Trac scipy-tickets@scipy....
Thu May 5 09:48:15 CDT 2011


#1436: stats.poisson.logpmf(k, loc) numeric overflow
-------------------------+--------------------------------------------------
 Reporter:  kairit       |       Owner:  somebody
     Type:  enhancement  |      Status:  new     
 Priority:  normal       |   Milestone:          
Component:  scipy.stats  |     Version:  0.9.0   
 Keywords:               |  
-------------------------+--------------------------------------------------
 stats.poisson.logpmf produces numeric overflow with unexpectedly "big"
 probabilities. For example:

 >>> scipy.stats.poisson.logpmf(1, 1)
 -1.0
 >>> scipy.stats.poisson.logpmf(100, 1)
 -364.73937555556347
 >>> scipy.stats.poisson.logpmf(200, 1)
 -inf

 As the logarithmic scale is used to manipulate probabilities that are very
 small then one would expect that methods implementing logprobs would not
 suffer numeric overflows with that "big" probabilites.

 In comparison I implemented a simple function to calculate the logprob of
 Poisson distribution:

 import math

 def logpoisson(x, mean):
     return -mean + x*math.log(mean) - math.log(math.factorial(x))

 >>> logpoisson(1, 1)
 -1.0
 >>> logpoisson(100, 1)
 -364.7393755555635
 >>> logpoisson(200, 1)
 -864.2319871924054
 >>> logpoisson(1500, 200)
 -1726.9301350957012

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


More information about the Scipy-tickets mailing list