Vous êtes un professionnel et vous avez besoin d'une formation ?
Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé
Module « scipy.stats »
Signature de la fonction dpareto_lognorm
def dpareto_lognorm(*args, **kwds)
Description
help(scipy.stats.dpareto_lognorm)
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 <https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.fit.html#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:
.. math::
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 :math:`R(t) = \frac{1 - \Phi(t)}{\phi(t)}`,
:math:`\phi` and :math:`\Phi` are the normal PDF and CDF, respectively,
:math:`y_1 = \alpha \sigma - \frac{\log x - \mu}{\sigma}`,
and :math:`y_2 = \beta \sigma + \frac{\log x - \mu}{\sigma}`
for real numbers :math:`x` and :math:`\mu`, :math:`\sigma > 0`,
:math:`\alpha > 0`, and :math:`\beta > 0` [1]_.
`dpareto_lognorm` takes
``u`` as a shape parameter for :math:`\mu`,
``s`` as a shape parameter for :math:`\sigma`,
``a`` as a shape parameter for :math:`\alpha`, and
``b`` as a shape parameter for :math:`\beta`.
A random variable :math:`X` distributed according to the PDF above
can be represented as :math:`X = U \frac{V_1}{V_2}` where :math:`U`,
:math:`V_1`, and :math:`V_2` are independent, :math:`U` is lognormally
distributed such that :math:`\log U \sim N(\mu, \sigma^2)`, and
:math:`V_1` and :math:`V_2` follow Pareto distributions with parameters
:math:`\alpha` and :math:`\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()
Vous êtes un professionnel et vous avez besoin d'une formation ?
Calcul scientifique
avec Python
Voir le programme détaillé
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :