A generalized Pareto continuous random variable.
Continuous random variables are defined from a standard form and may require some shape parameters to complete its specification. Any optional keyword parameters can be passed to the methods of the RV object as given below:
Random variates.
Probability density function.
Log of the probability density function.
Cumulative density function.
Log of the cumulative density function.
Survival function (1-cdf --- sometimes more accurate).
Log of the survival function.
Percent point function (inverse of cdf --- percentiles).
Inverse survival function (inverse of sf).
Non-central moment of order n
Mean('m'), variance('v'), skew('s'), and/or kurtosis('k').
(Differential) entropy of the RV.
Parameter estimates for generic data.
Expected value of a function (of one argument) with respect to the distribution.
Median of the distribution.
Mean of the distribution.
Variance of the distribution.
Standard deviation of the distribution.
Endpoints of the range that contains alpha percent of the distribution
Parameters: |
|
---|
Notes
The probability density function for genpareto is:
genpareto.pdf(x, c) = (1 + c * x)**(-1 - 1/c)
for c != 0, and for x >= 0 for all c, and x < 1/abs(c) for c < 0.
Examples
>>> from scipy.stats import genpareto
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots(1, 1)
Calculate a few first moments:
>>> c = 0.1
>>> mean, var, skew, kurt = genpareto.stats(c, moments='mvsk')
Display the probability density function (pdf):
>>> x = np.linspace(genpareto.ppf(0.01, c),
... genpareto.ppf(0.99, c), 100)
>>> ax.plot(x, genpareto.pdf(x, c),
... 'r-', lw=5, alpha=0.6, label='genpareto pdf')
Alternatively, freeze the distribution and display the frozen pdf:
>>> rv = genpareto(c)
>>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
Check accuracy of cdf and ppf:
>>> vals = genpareto.ppf([0.001, 0.5, 0.999], c)
>>> np.allclose([0.001, 0.5, 0.999], genpareto.cdf(vals, c))
True
Generate random numbers:
>>> r = genpareto.rvs(c, size=1000)
And compare the histogram:
>>> ax.hist(r, normed=True, histtype='stepfilled', alpha=0.2)
>>> ax.legend(loc='best', frameon=False)
>>> plt.show()