{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _levy_stable / levy_stable_gen

class

scipy.stats._levy_stable:levy_stable_gen

source: /scipy/stats/_levy_stable/__init__.py :638

Signature

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

Members

Summary

A Levy-stable continuous random variable.

Extended Summary

%(before_notes)s

Notes

The distribution for levy_stable has characteristic function:

where

  • is the stability parameter (),

  • is the skewness parameter (),

  • is the scale parameter (),

  • is the location parameter ().

Two parameterizations of are supported.

The parameterization (default):

The parameterization:

The probability density function for levy_stable is:

where . This integral does not have a known closed form.

levy_stable generalizes several distributions. Where possible, they should be used instead. Specifically, when the shape parameters assume the values in the table below, the corresponding equivalent distribution should be used.

=========  ========  ===========
``alpha``  ``beta``   Equivalent
=========  ========  ===========
 1/2       -1        `levy_l`
 1/2       1         `levy`
 1         0         `cauchy`
 2         any       `norm` (with ``scale=sqrt(2)``)
=========  ========  ===========

Evaluation of the pdf uses Nolan's piecewise integration approach with the Zolotarev parameterization by default. There is also the option to use direct numerical integration of the standard parameterization of the characteristic function or to evaluate by taking the FFT of the characteristic function.

The default method can changed by setting the class variable levy_stable.pdf_default_method to one of 'piecewise' for Nolan's approach, 'dni' for direct numerical integration, or 'fft-simpson' for the FFT based approach. For the sake of backwards compatibility, the methods 'best' and 'zolotarev' are equivalent to 'piecewise' and the method 'quadrature' is equivalent to 'dni'.

The parameterization can be changed by setting the class variable levy_stable.parameterization to either 'S0' or 'S1'. The default is 'S1'.

To improve performance of piecewise and direct numerical integration one can specify levy_stable.quad_eps (defaults to 1.2e-14). This is used as both the absolute and relative quadrature tolerance for direct numerical integration and as the relative quadrature tolerance for the piecewise method. One can also specify levy_stable.piecewise_x_tol_near_zeta (defaults to 0.005) for how close x is to zeta before it is considered the same as x [NO]. The exact check is abs(x0 - zeta) < piecewise_x_tol_near_zeta*alpha**(1/alpha). One can also specify levy_stable.piecewise_alpha_tol_near_one (defaults to 0.005) for how close alpha is to 1 before being considered equal to 1.

To increase accuracy of FFT calculation one can specify levy_stable.pdf_fft_grid_spacing (defaults to 0.001) and pdf_fft_n_points_two_power (defaults to None which means a value is calculated that sufficiently covers the input range).

Further control over FFT calculation is available by setting pdf_fft_interpolation_degree (defaults to 3) for spline order and pdf_fft_interpolation_level for determining the number of points to use in the Newton-Cotes formula when approximating the characteristic function (considered experimental).

Evaluation of the cdf uses Nolan's piecewise integration approach with the Zolatarev parameterization by default. There is also the option to evaluate through integration of an interpolated spline of the pdf calculated by means of the FFT method. The settings affecting FFT calculation are the same as for pdf calculation. The default cdf method can be changed by setting levy_stable.cdf_default_method to either 'piecewise' or 'fft-simpson'. For cdf calculations the Zolatarev method is superior in accuracy, so FFT is disabled by default.

Fitting estimate uses quantile estimation method in [MC]. MLE estimation of parameters in fit method uses this quantile estimate initially. Note that MLE doesn't always converge if using FFT for pdf calculations; this will be the case if alpha <= 1 where the FFT approach doesn't give good approximations.

Any non-missing value for the attribute levy_stable.pdf_fft_min_points_threshold will set levy_stable.pdf_default_method to 'fft-simpson' if a valid default method is not otherwise set.

The probability density above is defined in the "standardized" form. To shift and/or scale the distribution use the loc and scale parameters. Generally %(name)s.pdf(x, %(shapes)s, loc, scale) is identically equivalent to %(name)s.pdf(y, %(shapes)s) / scale with y = (x - loc) / scale, except in the S1 parameterization if alpha == 1. In that case %(name)s.pdf(x, %(shapes)s, loc, scale) is identically equivalent to %(name)s.pdf(y, %(shapes)s) / scale with y = (x - loc - 2 * beta * scale * np.log(scale) / np.pi) / scale. See [NO2] Definition 1.8 for more information. Note that shifting the location of a distribution does not make it a "noncentral" distribution.

See also

cauchy
levy
levy_l
norm

Aliases

  • scipy.stats._levy_stable.levy_stable_gen