{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _continuous_distns / lognorm_gen

class

scipy.stats._continuous_distns:lognorm_gen

source: /scipy/stats/_continuous_distns.py :6815

Signature

class   lognorm_gen ( momtype = 1 a = None b = None xtol = 1e-14 badvalue = None name = None longname = None shapes = None seed = None )

Members

Summary

A lognormal continuous random variable.

Extended Summary

%(before_notes)s

Notes

The probability density function for lognorm is:

for , .

lognorm takes s as a shape parameter for .

%(after_notes)s

Suppose a normally distributed random variable X has mean mu and standard deviation sigma. Then Y = exp(X) is lognormally distributed with s = sigma and scale = exp(mu).

%(example)s

The logarithm of a log-normally distributed random variable is normally distributed:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy import stats
>>> fig, ax = plt.subplots(1, 1)
>>> mu, sigma = 2, 0.5
>>> X = stats.norm(loc=mu, scale=sigma)
>>> Y = stats.lognorm(s=sigma, scale=np.exp(mu))
>>> x = np.linspace(*X.interval(0.999))
>>> y = Y.rvs(size=10000)
>>> ax.plot(x, X.pdf(x), label='X (pdf)')
>>> ax.hist(np.log(y), density=True, bins=x, label='log(Y) (histogram)')
>>> ax.legend()
>>> plt.show()

Aliases

  • scipy.stats._continuous_distns.lognorm_gen