scipy.stats.dpareto_lognorm#

scipy.stats.dpareto_lognorm = <scipy.stats._continuous_distns.dpareto_lognorm_gen object>[source]#

A double Pareto lognormal continuous random variable.

As an instance of the rv_continuous class, dpareto_lognorm object inherits from it a collection of generic methods (see below for the full list), and completes them with details specific for this particular distribution.

Methods

rvs(u, s, a, b, loc=0, scale=1, size=1, random_state=None)

Random variates.

pdf(x, u, s, a, b, loc=0, scale=1)

Probability density function.

logpdf(x, u, s, a, b, loc=0, scale=1)

Log of the probability density function.

cdf(x, u, s, a, b, loc=0, scale=1)

Cumulative distribution function.

logcdf(x, u, s, a, b, loc=0, scale=1)

Log of the cumulative distribution function.

sf(x, u, s, a, b, loc=0, scale=1)

Survival function (also defined as 1 - cdf, but sf is sometimes more accurate).

logsf(x, u, s, a, b, loc=0, scale=1)

Log of the survival function.

ppf(q, u, s, a, b, loc=0, scale=1)

Percent point function (inverse of cdf — percentiles).

isf(q, u, s, a, b, loc=0, scale=1)

Inverse survival function (inverse of sf).

moment(order, u, s, a, b, loc=0, scale=1)

Non-central moment of the specified order.

stats(u, s, a, b, loc=0, scale=1, moments=’mv’)

Mean(‘m’), variance(‘v’), skew(‘s’), and/or kurtosis(‘k’).

entropy(u, s, a, b, loc=0, scale=1)

(Differential) entropy of the RV.

fit(data)

Parameter estimates for generic data. See scipy.stats.rv_continuous.fit for detailed documentation of the keyword arguments.

expect(func, args=(u, s, a, b), loc=0, scale=1, lb=None, ub=None, conditional=False, **kwds)

Expected value of a function (of one argument) with respect to the distribution.

median(u, s, a, b, loc=0, scale=1)

Median of the distribution.

mean(u, s, a, b, loc=0, scale=1)

Mean of the distribution.

var(u, s, a, b, loc=0, scale=1)

Variance of the distribution.

std(u, s, a, b, loc=0, scale=1)

Standard deviation of the distribution.

interval(confidence, u, s, a, b, loc=0, scale=1)

Confidence interval with equal areas around the median.

Notes

The probability density function for dpareto_lognorm is:

\[f(x, \mu, \sigma, \alpha, \beta) = \frac{\alpha \beta}{(\alpha + \beta) x} \phi\left( \frac{\log x - \mu}{\sigma} \right) \left( R(y_1) + R(y_2) \right)\]

where \(R(t) = \frac{1 - \Phi(t)}{\phi(t)}\), \(phi\) and \(Phi\) are the normal PDF and CDF, respectively, \(y_1 = \alpha \sigma - \frac{\log x - \mu}{\sigma}\), and \(y_2 = \beta \sigma + \frac{\log x - \mu}{\sigma}\) for real numbers \(x\) and \(\mu\), \(\sigma > 0\), \(\alpha > 0\), and \(\beta > 0\) [1].

dpareto_lognorm takes u as a shape parameter for \(\mu\), s as a shape parameter for \(\sigma\), a as a shape parameter for \(\alpha\), and b as a shape parameter for \(\beta\).

A random variable \(X\) distributed according to the PDF above can be represented as \(X = U \frac{V_1}{V_2}\) where \(U\), \(V_1\), and \(V_2\) are independent, \(U\) is lognormally distributed such that \(\log U \sim N(\mu, \sigma^2)\), and \(V_1\) and \(V_2\) follow Pareto distributions with parameters \(\alpha\) and \(\beta\), respectively [2].

The probability density above is defined in the “standardized” form. To shift and/or scale the distribution use the loc and scale parameters. Specifically, dpareto_lognorm.pdf(x, u, s, a, b, loc, scale) is identically equivalent to dpareto_lognorm.pdf(y, u, s, a, b) / scale with y = (x - loc) / scale. Note that shifting the location of a distribution does not make it a “noncentral” distribution; noncentral generalizations of some distributions are available in separate classes.

References

[1]

Hajargasht, Gholamreza, and William E. Griffiths. “Pareto-lognormal distributions: Inequality, poverty, and estimation from grouped income data.” Economic Modelling 33 (2013): 593-604.

[2]

Reed, William J., and Murray Jorgensen. “The double Pareto-lognormal distribution - a new parametric model for size distributions.” Communications in Statistics - Theory and Methods 33.8 (2004): 1733-1753.

Examples

>>> import numpy as np
>>> from scipy.stats import dpareto_lognorm
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots(1, 1)

Calculate the first four moments:

>>> u, s, a, b = 3, 1.2, 1.5, 2
>>> mean, var, skew, kurt = dpareto_lognorm.stats(u, s, a, b, moments='mvsk')

Display the probability density function (pdf):

>>> x = np.linspace(dpareto_lognorm.ppf(0.01, u, s, a, b),
...                 dpareto_lognorm.ppf(0.99, u, s, a, b), 100)
>>> ax.plot(x, dpareto_lognorm.pdf(x, u, s, a, b),
...        'r-', lw=5, alpha=0.6, label='dpareto_lognorm pdf')

Alternatively, the distribution object can be called (as a function) to fix the shape, location and scale parameters. This returns a “frozen” RV object holding the given parameters fixed.

Freeze the distribution and display the frozen pdf:

>>> rv = dpareto_lognorm(u, s, a, b)
>>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

Check accuracy of cdf and ppf:

>>> vals = dpareto_lognorm.ppf([0.001, 0.5, 0.999], u, s, a, b)
>>> np.allclose([0.001, 0.5, 0.999], dpareto_lognorm.cdf(vals, u, s, a, b))
True

Generate random numbers:

>>> r = dpareto_lognorm.rvs(u, s, a, b, size=1000)

And compare the histogram:

>>> ax.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2)
>>> ax.set_xlim([x[0], x[-1]])
>>> ax.legend(loc='best', frameon=False)
>>> plt.show()
../../_images/scipy-stats-dpareto_lognorm-1.png