[Scipy-tickets] [SciPy] #1502: lognorm pdf produces incorrect values
SciPy Trac
scipy-tickets@scipy....
Thu Aug 25 14:50:29 CDT 2011
#1502: lognorm pdf produces incorrect values
--------------------------+-------------------------------------------------
Reporter: rgrout | Owner: somebody
Type: defect | Status: new
Priority: high | Milestone: Unscheduled
Component: scipy.stats | Version: 0.9.0
Keywords: lognorm, pdf |
--------------------------+-------------------------------------------------
In looking at the code for the lognorm pdf (in scipy.stats), it appears as
though the pdf is incorrectly calculated.
We have checked the results of scipy's lognorm pdf against the results
from MATLAB and Octave. After looking at the function
scipy.stats.lognorm._pdf, we see that the mean is not being subtracted
from the log of (x)
Scipy's function (currently in .90)
{{{
def _pdf(self, x, s):
Px = exp(-log(x)**2 / (2*s**2))
return Px / (s*x*sqrt(2*pi))
}}}
How the pdf should be calculated (note that the mean is subtracted from
log(x) and then squared. This is in agreement with various forms of the
lognormal pdf equation found online and also agrees with values calculated
in MATLAB and Octave.
{{{
def _pdf(self, x, m, s):
Px = exp(-(log(x)-m)**2 / (2*s**2))
return Px / (s*x*sqrt(2*pi))
}}}
References for lognorm pdf equation
[http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000208980.htm]
[http://www.weibull.com/LifeDataWeb/lognormal_probability_density_function.htm]
[http://en.wikipedia.org/wiki/Lognormal_distribution]
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1502>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list