[Scipy-tickets] [SciPy] #1628: stats.gamma.pdf(0, 1) returns nan, but it should be 1.

SciPy Trac scipy-tickets@scipy....
Sat Mar 24 22:47:41 CDT 2012


#1628: stats.gamma.pdf(0, 1) returns nan, but it should be 1.
------------------------------+---------------------------------------------
 Reporter:  warren.weckesser  |       Owner:  somebody   
     Type:  defect            |      Status:  new        
 Priority:  normal            |   Milestone:  Unscheduled
Component:  scipy.stats       |     Version:  devel      
 Keywords:  gamma             |  
------------------------------+---------------------------------------------
 stats.gamma.pdf(x, 1) should be equivalent to exp(-x).  In particular,
 stats.gamma.pdf(0, 1) should be 1.  Currently it returns nan:
 {{{
 In [1]: import scipy

 In [2]: scipy.__version__
 Out[2]: '0.11.0.dev-9ee2d9b'

 In [3]: from scipy.stats import gamma

 In [4]: gamma.pdf([0.0, 0.0001], 1.0)
 /Users/warren/local_scipy/lib/python2.7/site-
 packages/scipy/stats/distributions.py:3353: RuntimeWarning: divide by zero
 encountered in log
   return (a-1)*log(x) - x - gamln(a)
 /Users/warren/local_scipy/lib/python2.7/site-
 packages/scipy/stats/distributions.py:3353: RuntimeWarning: invalid value
 encountered in multiply
   return (a-1)*log(x) - x - gamln(a)
 Out[4]: array([    nan,  0.9999])
 }}}

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


More information about the Scipy-tickets mailing list