[SciPy-User] Confusion about lognormal distribution functions

Robert Kern robert.kern at gmail.com
Sun Nov 27 12:39:04 EST 2011


On Sat, Nov 26, 2011 at 16:52, tazz_ben <tazz_ben at wsu.edu> wrote:
> Hi Group -
>
> So, what I'm trying to do is draw a firm size from a lognormal
> distribution in a simulation (I'm using a fortuna RNG outside of the scope
> of this question -- why instead of twister deals with my research
> question, for this purposes it is just important to say using the built in
> random draw from a specific distribution wouldn't work).
>
> But when I do something like this:
>
> from scipy.stats import lognorm
>
> lognorm.ppf(.5,1,50,50)
>
> The numbers that come out make no sense (I'm right in believing "loc" =
> "mean" and "scale" = "standard deviation"?). I've tried logging the
> numbers, un-logging the numbers, etc.  I'm very confused on what it is
> doing.

No, loc and scale mean exactly the same thing for every distribution.
loc translates the distribution linearly and scale scales it.

  lognorm.pdf(x, s, loc=loc, scale=scale) == lognorm.pdf((x-loc)/scale, s)/scale

They don't always map to particular parameters in standard
parameterizations. However, they often do, so doing this lets us share
the code for shifting and scaling in the base class rather than
implementing it slightly differently for every distribution.

In this case, you want to ignore the loc parameter entirely. The scale
parameter corresponds to exp(mu) where mu is the mean of the
underlying normal distribution. The shape parameter is the standard
deviation of the underlying normal distribution.

log(lognorm.ppf(p, s, scale=scale)) == norm.ppf(p, loc=log(scale), scale=s)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the SciPy-User mailing list