<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1628" rel="nofollow">http://projects.scipy.org/scipy/ticket/1628</a> on 2012-03-25 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/WarrenWeckesser/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/WarrenWeckesser">@WarrenWeckesser</a>, assigned to unknown.</em></p>
<p dir="auto">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:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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])"><pre class="notranslate"><code class="notranslate">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])
</code></pre></div>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/1326" rel="nofollow">http://projects.scipy.org/scipy/ticket/1326</a> on 2010-11-10 by trac user tpikonen, assigned to unknown.</em></p>
<p dir="auto">In [331]: scipy.stats.distributions.chi2.pdf(0.0, 2)</p>
<p dir="auto">Out[331]: nan</p>
<p dir="auto">The correct value is 0.5.</p>
<p dir="auto">Attached is a patch which fixes this.</p>