Log-Normal Distribution

Table of contents


Density Function

The density function of the log-Normal distribution:

\[f(x; \mu, \sigma) = \frac{1}{x} \frac{1}{\sqrt{2 \pi} \sigma} \exp \left( - \frac{(\ln x-\mu)^2}{2 \sigma^2} \right)\]

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.dlnorm(x: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float

Density function of the Log-Normal distribution.

Example

>>> pystats.dlnorm(2.0, 1.0, 2.0)
0.0985685803440131
Parameters
  • x (float) – A real-valued input.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

The density function evaluated at x.

List Input

pystats.dlnorm(x: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]

Density function of the Log-Normal distribution.

Example

>>> pystats.dlnorm([0.0, 1.0, 2.0], 1.0, 2.0)
[0.0, 0.17603266338214968, 0.0985685803440131]
Parameters
  • x (List[float]) – A standard list input.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

A list of density values corresponding to the elements of x.


Cumulative Distribution Function

The cumulative distribution function (CDF) of the log-Normal distribution:

\[F(x; \mu, \sigma) = \int_0^x f(z; \mu, \sigma) dz = \frac{1}{2} + \frac{1}{2} \times \text{erf} \left( \frac{\ln (x) - \mu}{\sigma} \right)\]

where \(\text{erf}(\cdot)\) denotes the Gaussian error function.

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.plnorm(p: float, mean: float = 0.0, sd: float = 1.0, log: bool = False) float

Distribution function of the Log-Normal distribution.

Example

>>> pystats.plnorm(2.0, 1.0, 2.0)
0.43903100974768944
Parameters
  • p (float) – A real-valued input.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

The cumulative distribution function evaluated at p.

List Input

pystats.plnorm(p: List[float], mean: float = 0.0, sd: float = 1.0, log: bool = False) List[float]

Distribution function of the Log-Normal distribution.

Example

>>> pystats.plnorm([0.0, 1.0, 2.0], 1.0, 2.0)
[0.0, 0.3085375387259869, 0.43903100974768944]
Parameters
  • p (List[float]) – A standard list input.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

  • log (bool) – Return the log-density or the true form.

Returns

A list of CDF values corresponding to the elements of p.


Quantile Function

The quantile function of the log-Normal distribution:

\[q(p; \mu, \sigma) = \exp \left( \mu + \sqrt{2} \sigma \times \text{erf}^{-1} \left( 2 p - 1 \right) \right)\]

where \(\text{erf}^{-1}(\cdot)\) denotes the inverse Gaussian error function.

Methods for scalar input, as well as for list input, are listed below.

Scalar Input

pystats.qlnorm(q: float, mean: float = 0.0, sd: float = 1.0) float

Quantile function of the Log-Normal distribution.

Example

>>> pystats.qlnorm(0.95, 1.0, 2.0)
72.94511097708158
Parameters
  • q (float) – A real-valued input.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

Returns

The quantile function evaluated at q.

List Input

pystats.qlnorm(q: List[float], mean: float = 0.0, sd: float = 1.0) List[float]

Quantile function of the Log-Normal distribution.

Example

>>> pystats.qlnorm([0.1, 0.5, 0.9], 1.0, 2.0)
[0.20948500212405705, 2.718281828459045, 35.27248263126183]
Parameters
  • q (List[float]) – A standard list input.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

Returns

A list of quantiles values corresponding to the elements of q.


Random Sampling

Random sampling for the log-Normal distribution is achieved by simulating \(X \sim N(\mu, \sigma^2)\), then returning

\[Z = \exp( X ) \sim \text{Lognormal} (\mu, \sigma^2)\]

Scalar Output

pystats.rlnorm(mean: float = 0.0, sd: float = 1.0) float

Random sampling function for the Log-Normal distribution.

Example

>>> pystats.rlnorm(1.0, 2.0)
0.7961734447160091
Parameters
  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

Returns

A pseudo-random draw from the Log-Normal distribution.

List Output

pystats.rlnorm(n: int, mean: float = 0.0, sd: float = 1.0) List[float]

Random sampling function for the Log-Normal distribution.

Example

>>> pystats.rlnorm(3, 1.0, 2.0)
[0.7889982649469498, 0.060477695435514324, 0.09150040197067903]
Parameters
  • n (int) – The number of output values.

  • mean (float) – The mean parameter, a real-valued input.

  • sd (float) – The standard deviation parameter, a real-valued input.

Returns

A list of pseudo-random draws from the Log-Normal distribution.