
    _Mh8                       d dl Z d dlmZ d dlmZmZ d dlZd dlZd dl	m
Z
 d dlmZ d dlmZmZmZ d dlmZ d dlmZ d d	lmZ d dlmZ d dlmc mZ d d
lmZmZ ddlm Z  ddl!m"Z#m$Z% ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ d dl0m1Z1 ddl2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z> ddl?m@Z@ d dlAmBZB d dlCmDZD d dlEmFZF d ZGd ZHddZI G d de+          ZJ eJddd          ZK G d de+          ZL eLd ddd !          ZM G d" d#e+          ZN eNdd$%          ZO ejP        d&ejQ        z            ZR ejS        eR          ZTd' ZUd( ZVd) ZWd* ZXd+ ZYd, ZZd- Z[d. Z\ G d/ d0e+          Z] e]d12          Z^ G d3 d4e+          Z_ e_dd5%          Z` G d6 d7e+          Za eaejQ         d8z  ejQ        d8z  d9          Zb G d: d;e+          Zc ecddd<          Zd G d= d>ee          Zf G d? d@eD          ZgdA ZhdB Zi G dC dDe+          Zj ejdddE          Zk G dF dGe+          Zl elddH%          Zm G dI dJe+          Zn endddK          Zo G dL dMe+          Zp epddN%          Zq G dO dPe+          Zr erddQ%          Zs G dR dSep          Zt etddT%          Zu G dU dVe+          Zv evdW2          Zw G dX dYe+          Zx exddZ%          Zy G d[ d\e+          Zz ezdd]%          Z{ G d^ d_e+          Z| e|ejQ         ejQ        d`          Z} G da dbe+          Z~ e~dc2          Z G dd dee+          Z ed df%          Z G dg dhe+          Z edi2          Z G dj dke+          Z eddl%          Z G dm dne+          Z edo2          Zdp Z G dq dre+          Z edds%          Z G dt due+          Z eddv%          Z G dw dxe+          Z eddy%          Z G dz d{e+          Z edd|%          Z G d} d~e+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z ed2          Zde_         G d de+          Z edd          Z G d de+          Z ed2          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z ed2          Zd Z G d de+          Z edd%          Z G d de          Z edd%          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z ed2          Z G d de+          Z edd%          Zd Z G d de+          Z ed2          Z G d de+          Z ed2          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z ed2          Z G d de+          Z eddd¬          Z G dÄ de+          Z eddŬ%          Z G dƄ de+          Z eddȬ%          Z G dɄ de+          Z eddˬ%          Z G d̄ de+          Z edά2          Z G dτ de+          Z ed dѬ%          Z G d҄ de+          Z edԬ2          Z G dՄ de+          Z eddd׬          Z G d؄ de+          Z edڬ2          Z G dۄ de+          Z edݬ2          Z G dބ de+          Z ed2          Z G d de+          Z ed2          Zd Z G d de+          Z edd%          Z G d de+          Z eddꬍ          Z G d de+          Z ed2          Z G d de+          Z ed2          Z G d de+          Z edd%          Zd Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z edd %          Z G d de+          Z ed2          Z G d de+          Z edd%          Z G d de+          Z ed	2          Z G d
 de+          Z edd%          Zd Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d de+          Z ed2          Z G d de+          Z ed2          Z G d de+          Z edd%          Z G d de+          Z edd%          Z G d  d!e+          Z ed"2          Z  G d# d$e+          Z eddd%          Z G d& d'e+          Z edd(%          Z G d) d*e+          Z ed+2          Z G d, d-e+          Z ed.dd/          Z G d0 d1e+          Z	 e	dd2%          Z
 G d3 d4e+          Z ed52          Z ed62          Zde_        de_         G d7 d8e+          Z edd9%          Z G d: d;e+          Z ed<2          Zd=e_         G d> d?e+          Z edd@%          Z G dA dBe+          Z ed.ddC          Z G dD dEe+          Z edF2          Z G dG dHe+          Z edI2          Z G dJ dKe+          ZdLZ G dM dNe          Z edddO          Z edddP          Zg dQZ G dR dS          Z eD ]Z! e"ee! e e!                      G dT dUe+          Z# e#dddV          Z$ G dW dXe+          Z% e%ddY%          Z&dZe&_        d[ Z'd\ Z(d] Z) G d^ d_e+          Z* e*d`da          Z+de+_         G db dce+          Z, e,ddd%          Z-dee-_         G df dge+          Z. e.dh2          Z/ G di djef          Z0 G dk dle+          Z1 e1dddm          Z2 G dn doe+          Z3 e3dp2          Z4 e3ejQ         ejQ        dq          Z5 G dr dse¦          Z6 e6ddt%          Z7 G du dve+          Z8 e8dd&ejQ        z  dw          Z9 G dx dye+          Z: e:dz2          Z; G d{ d|e+          Z< e<d d}%          Z= G d~ de+          Z> e>dd          Z?d Z@ G d de+          ZA eAdddd          ZB G d de+          ZC G d de+          ZD eDdd ejE                  ZF G d de+          ZG eGdd%          ZH eI eJ            K                                L                                          ZM e(eMe+          \  ZNZOeNeOz   dgz   ZPdS (      N)Iterable)wrapscached_property
Polynomial)BSpline)extend_notes_in_docstringreplace_notes_in_docstringinherit_docstring_from)LowLevelCallable)optimize)	integrate)_lazyselect
_lazywhere   )_stats)tukeylambda_variancetukeylambda_kurtosis)	_vectorize_rvs_over_shapesget_distribution_names	_kurtosis_isintegralrv_continuous_skew_get_fixed_fit_value_check_shape
_ShapeInfo)	_log1mexp)kolmognkolmognpkolmogni)_XMIN_LOGXMIN_EULER_ZETA3_SQRT_PI_SQRT_2_OVER_PI_LOG_PI_LOG_SQRT_2_OVER_PI)CensoredData)root_scalar)FitErrorc                     |                      dd           |                      dd           |                      dd           |                      dd           | rt          d|  d          dS )a  
    Remove the optimizer-related keyword arguments 'loc', 'scale' and
    'optimizer' from `kwds`.  Then check that `kwds` is empty, and
    raise `TypeError("Unknown arguments: %s." % kwds)` if it is not.

    This function is used in the fit method of distributions that override
    the default method and do not use the default optimization code.

    `kwds` is modified in-place.
    locNscale	optimizermethodzUnknown arguments: .)pop	TypeError)kwdss    ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/scipy/stats/_continuous_distns.py_remove_optimizer_parametersr7   '   s     	HHUDHHWdHH[$HHXt 75d5556667 7    c                 <     t                      fd            }|S )Nc                 B   |                     dd                                          }t          |t                    }|dk    s|rD|                                dk    r, t          t          |           |           j        |g|R i |S |r|j        } | |g|R i |S )Nr1   mlemmr   )	getlower
isinstancer*   num_censoredsupertypefit_uncensored)selfdataargsr5   r1   censoredfuns         r6   wrapperz _call_super_mom.<locals>.wrapper>   s    (E**0022dL11T>>h>4+<+<+>+>+B+B.5dT**.tCdCCCdCCC ( '3tT1D111D111r8   )r   )rI   rJ   s   ` r6   _call_super_momrK   :   s5     3ZZ2 2 2 2 Z2 Nr8   c                      |p|dz
  }||z
  } fd} |||          s;|dz  }||z
  }d}t          j        |          rt          |           |||          ;|S )Nr   c                 |    t          j         |                     t          j         |                    k    S Nnpsign)lbrackrbrackrI   s     r6   interval_contains_rootz1_get_left_bracket.<locals>.interval_contains_rootV   s2    wss6{{##rwss6{{';';;;r8      zVThe solver could not find a bracket containing a root to an MLE first order condition.)rP   isinfFitSolverError)rI   rS   rR   diffrT   msgs   `     r6   _get_left_bracketrZ   O   s    !vzFF?D< < < < < %$VV44 &	$78F 	& %%% %$VV44 & Mr8   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
	ksone_gena  Kolmogorov-Smirnov one-sided test statistic distribution.

    This is the distribution of the one-sided Kolmogorov-Smirnov (KS)
    statistics :math:`D_n^+` and :math:`D_n^-`
    for a finite sample size ``n >= 1`` (the shape parameter).

    %(before_notes)s

    See Also
    --------
    kstwobign, kstwo, kstest

    Notes
    -----
    :math:`D_n^+` and :math:`D_n^-` are given by

    .. math::

        D_n^+ &= \text{sup}_x (F_n(x) - F(x)),\\
        D_n^- &= \text{sup}_x (F(x) - F_n(x)),\\

    where :math:`F` is a continuous CDF and :math:`F_n` is an empirical CDF.
    `ksone` describes the distribution under the null hypothesis of the KS test
    that the empirical CDF corresponds to :math:`n` i.i.d. random variates
    with CDF :math:`F`.

    %(after_notes)s

    References
    ----------
    .. [1] Birnbaum, Z. W. and Tingey, F.H. "One-sided confidence contours
       for probability distribution functions", The Annals of Mathematical
       Statistics, 22(4), pp 592-596 (1951).

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

    Display the probability density function (``pdf``):

    >>> n = 1e+03
    >>> x = np.linspace(ksone.ppf(0.01, n),
    ...                 ksone.ppf(0.99, n), 100)
    >>> ax.plot(x, ksone.pdf(x, n),
    ...         'r-', lw=5, alpha=0.6, label='ksone 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 = ksone(n)
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()

    Check accuracy of ``cdf`` and ``ppf``:

    >>> vals = ksone.ppf([0.001, 0.5, 0.999], n)
    >>> np.allclose([0.001, 0.5, 0.999], ksone.cdf(vals, n))
    True

    c                 @    |dk    |t          j        |          k    z  S Nr   rP   roundrE   ns     r6   	_argcheckzksone_gen._argcheck       Q1+,,r8   c                 @    t          dddt          j        fd          gS Nrb   Tr   TFr   rP   infrE   s    r6   _shape_infozksone_gen._shape_info       3q"&k=AABBr8   c                 .    t          j        ||           S rN   )scu	_smirnovprE   xrb   s      r6   _pdfzksone_gen._pdf   s    a####r8   c                 ,    t          j        ||          S rN   )rn   	_smirnovcrp   s      r6   _cdfzksone_gen._cdf   s    }Q"""r8   c                 ,    t          j        ||          S rN   )scsmirnovrp   s      r6   _sfzksone_gen._sf   s    z!Qr8   c                 ,    t          j        ||          S rN   )rn   
_smirnovcirE   qrb   s      r6   _ppfzksone_gen._ppf   s    ~a###r8   c                 ,    t          j        ||          S rN   )rw   smirnovir|   s      r6   _isfzksone_gen._isf       {1a   r8   N)__name__
__module____qualname____doc__rc   rk   rr   ru   ry   r~   r    r8   r6   r\   r\   f   s        B BF- - -C C C$ $ $# # #     $ $ $! ! ! ! !r8   r\                 ?ksone)abnamec                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )	kstwo_genad  Kolmogorov-Smirnov two-sided test statistic distribution.

    This is the distribution of the two-sided Kolmogorov-Smirnov (KS)
    statistic :math:`D_n` for a finite sample size ``n >= 1``
    (the shape parameter).

    %(before_notes)s

    See Also
    --------
    kstwobign, ksone, kstest

    Notes
    -----
    :math:`D_n` is given by

    .. math::

        D_n = \text{sup}_x |F_n(x) - F(x)|

    where :math:`F` is a (continuous) CDF and :math:`F_n` is an empirical CDF.
    `kstwo` describes the distribution under the null hypothesis of the KS test
    that the empirical CDF corresponds to :math:`n` i.i.d. random variates
    with CDF :math:`F`.

    %(after_notes)s

    References
    ----------
    .. [1] Simard, R., L'Ecuyer, P. "Computing the Two-Sided
       Kolmogorov-Smirnov Distribution",  Journal of Statistical Software,
       Vol 39, 11, 1-18 (2011).

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

    Display the probability density function (``pdf``):

    >>> n = 10
    >>> x = np.linspace(kstwo.ppf(0.01, n),
    ...                 kstwo.ppf(0.99, n), 100)
    >>> ax.plot(x, kstwo.pdf(x, n),
    ...         'r-', lw=5, alpha=0.6, label='kstwo 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 = kstwo(n)
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()

    Check accuracy of ``cdf`` and ``ppf``:

    >>> vals = kstwo.ppf([0.001, 0.5, 0.999], n)
    >>> np.allclose([0.001, 0.5, 0.999], kstwo.cdf(vals, n))
    True

    c                 @    |dk    |t          j        |          k    z  S r^   r_   ra   s     r6   rc   zkstwo_gen._argcheck  rd   r8   c                 @    t          dddt          j        fd          gS rf   rh   rj   s    r6   rk   zkstwo_gen._shape_info	  rl   r8   c                 b    dt          |t                    s|nt          j        |          z  dfS N      ?r   )r?   r   rP   
asanyarrayra   s     r6   _get_supportzkstwo_gen._get_support  s4    jH55KQQ2=;K;KL 	r8   c                 "    t          ||          S rN   )r    rp   s      r6   rr   zkstwo_gen._pdf  s    1~~r8   c                 "    t          ||          S rN   r   rp   s      r6   ru   zkstwo_gen._cdf  s    q!}}r8   c                 &    t          ||d          S NFcdfr   rp   s      r6   ry   zkstwo_gen._sf  s    q!''''r8   c                 &    t          ||d          S )NTr   r!   r|   s      r6   r~   zkstwo_gen._ppf  s    1$''''r8   c                 &    t          ||d          S r   r   r|   s      r6   r   zkstwo_gen._isf  s    1%((((r8   N)r   r   r   r   rc   rk   r   rr   ru   ry   r~   r   r   r8   r6   r   r      s        A AD- - -C C C      ( ( (( ( () ) ) ) )r8   r   kstwo)momtyper   r   r   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	kstwobign_gena  Limiting distribution of scaled Kolmogorov-Smirnov two-sided test statistic.

    This is the asymptotic distribution of the two-sided Kolmogorov-Smirnov
    statistic :math:`\sqrt{n} D_n` that measures the maximum absolute
    distance of the theoretical (continuous) CDF from the empirical CDF.
    (see `kstest`).

    %(before_notes)s

    See Also
    --------
    ksone, kstwo, kstest

    Notes
    -----
    :math:`\sqrt{n} D_n` is given by

    .. math::

        D_n = \text{sup}_x |F_n(x) - F(x)|

    where :math:`F` is a continuous CDF and :math:`F_n` is an empirical CDF.
    `kstwobign`  describes the asymptotic distribution (i.e. the limit of
    :math:`\sqrt{n} D_n`) under the null hypothesis of the KS test that the
    empirical CDF corresponds to i.i.d. random variates with CDF :math:`F`.

    %(after_notes)s

    References
    ----------
    .. [1] Feller, W. "On the Kolmogorov-Smirnov Limit Theorems for Empirical
       Distributions",  Ann. Math. Statist. Vol 19, 177-189 (1948).

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zkstwobign_gen._shape_infoI      	r8   c                 ,    t          j        |           S rN   )rn   _kolmogprE   rq   s     r6   rr   zkstwobign_gen._pdfL  s    Qr8   c                 *    t          j        |          S rN   )rn   _kolmogcr   s     r6   ru   zkstwobign_gen._cdfO  s    |Ar8   c                 *    t          j        |          S rN   )rw   
kolmogorovr   s     r6   ry   zkstwobign_gen._sfR  s    }Qr8   c                 *    t          j        |          S rN   )rn   	_kolmogcirE   r}   s     r6   r~   zkstwobign_gen._ppfU  s    }Qr8   c                 *    t          j        |          S rN   )rw   kolmogir   s     r6   r   zkstwobign_gen._isfX  s    z!}}r8   N)
r   r   r   r   rk   rr   ru   ry   r~   r   r   r8   r6   r   r   $  sy        # #H                       r8   r   	kstwobign)r   r   rU   c                 H    t          j        | dz   dz            t          z  S NrU          @)rP   exp_norm_pdf_Crq   s    r6   	_norm_pdfr   h  s!    61a4%){**r8   c                 $    | dz   dz  t           z
  S r   )_norm_pdf_logCr   s    r6   _norm_logpdfr   l  s    qD53;''r8   c                 *    t          j        |           S rN   )rw   ndtrr   s    r6   	_norm_cdfr   p  s    71::r8   c                 *    t          j        |           S rN   )rw   log_ndtrr   s    r6   _norm_logcdfr   t  s    ;q>>r8   c                 *    t          j        |           S rN   )rw   ndtrir}   s    r6   	_norm_ppfr   x  s    8A;;r8   c                 "    t          |            S rN   r   r   s    r6   _norm_sfr   |  s    aR==r8   c                 "    t          |            S rN   r   r   s    r6   _norm_logsfr     s    r8   c                 "    t          |            S rN   r   r   s    r6   	_norm_isfr     s    aLL=r8   c                       e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Ze eed          d                         Zd ZdS )norm_gena  A normal continuous random variable.

    The location (``loc``) keyword specifies the mean.
    The scale (``scale``) keyword specifies the standard deviation.

    %(before_notes)s

    Notes
    -----
    The probability density function for `norm` is:

    .. math::

        f(x) = \frac{\exp(-x^2/2)}{\sqrt{2\pi}}

    for a real number :math:`x`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   znorm_gen._shape_info  r   r8   Nc                 ,    |                     |          S rN   )standard_normalrE   sizerandom_states      r6   _rvsznorm_gen._rvs  s    ++D111r8   c                      t          |          S rN   r   r   s     r6   rr   znorm_gen._pdf  s    ||r8   c                      t          |          S rN   r   r   s     r6   _logpdfznorm_gen._logpdf      Ar8   c                      t          |          S rN   r   r   s     r6   ru   znorm_gen._cdf      ||r8   c                      t          |          S rN   r   r   s     r6   _logcdfznorm_gen._logcdf  r   r8   c                      t          |          S rN   r   r   s     r6   ry   znorm_gen._sf  s    {{r8   c                      t          |          S rN   )r   r   s     r6   _logsfznorm_gen._logsf  s    1~~r8   c                      t          |          S rN   r   r   s     r6   r~   znorm_gen._ppf  r   r8   c                      t          |          S rN   r   r   s     r6   r   znorm_gen._isf  r   r8   c                     dS )N)r   r   r   r   r   rj   s    r6   r   znorm_gen._stats      !!r8   c                 P    dt          j        dt           j        z            dz   z  S Nr   rU   r   rP   logpirj   s    r6   _entropyznorm_gen._entropy  s     BF1RU7OOA%&&r8   a}          For the normal distribution, method of moments and maximum likelihood
        estimation give identical fits, and explicit formulas for the estimates
        are available.
        This function uses these explicit formulas for the maximum likelihood
        estimation of the normal distribution parameters, so the
        `optimizer` and `method` arguments are ignored.

notesc                    |                     dd           }|                     dd           }t          |           ||t          d          t          j        |          }t          j        |                                          st          d          ||                                }n|}|-t          j        ||z
  dz                                            }n|}||fS )Nflocfscale3All parameters fixed. There is nothing to optimize.$The data contains non-finite values.rU   )	r3   r7   
ValueErrorrP   asarrayisfiniteallmeansqrt)rE   rF   r5   r   r   r.   r/   s          r6   rC   znorm_gen.fit  s     xx%%(D))$T*** 2  ) * * * z${4  $$&& 	ECDDD<))++CCC>GdSj1_224455EEEEzr8   c                 p    |dk    rdS |dz  dk    r$t          j        t          |          dz
            S dS )z
        @returns Moments of standard normal distribution for integer n >= 0

        See eq. 16 of https://arxiv.org/abs/1209.4340v2
        r   r   rU   r   r   )rw   
factorial2intra   s     r6   _munpznorm_gen._munp  s>     662q5A::=Q!,,,2r8   NN)r   r   r   r   rk   r   rr   r   ru   r   ry   r   r~   r   r   r   rK   r
   r   rC   r  r   r8   r6   r   r     s,        ,  2 2 2 2                " " "' ' '  6? @ @ @ @ @ _<    r8   r   norm)r   c                   D    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd ZdS )		alpha_gena&  An alpha continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `alpha` ([1]_, [2]_) is:

    .. math::

        f(x, a) = \frac{1}{x^2 \Phi(a) \sqrt{2\pi}} *
                  \exp(-\frac{1}{2} (a-1/x)^2)

    where :math:`\Phi` is the normal CDF, :math:`x > 0`, and :math:`a > 0`.

    `alpha` takes ``a`` as a shape parameter.

    %(after_notes)s

    References
    ----------
    .. [1] Johnson, Kotz, and Balakrishnan, "Continuous Univariate
           Distributions, Volume 1", Second Edition, John Wiley and Sons,
           p. 173 (1994).
    .. [2] Anthony A. Salvia, "Reliability applications of the Alpha
           Distribution", IEEE Transactions on Reliability, Vol. R-34,
           No. 3, pp. 251-252 (1985).

    %(example)s

    c                 @    t          dddt          j        fd          gS Nr   Fr   FFrh   rj   s    r6   rk   zalpha_gen._shape_info      326{NCCDDr8   c                 ^    d|dz  z  t          |          z  t          |d|z  z
            z  S Nr   rU   )r   r   rE   rq   r   s      r6   rr   zalpha_gen._pdf   s0    AqDz)A,,&y3q5'9'999r8   c                     dt          j        |          z  t          |d|z  z
            z   t          j        t          |                    z
  S )Nr   )rP   r   r   r   r  s      r6   r   zalpha_gen._logpdf$  s>    "&))|l1SU7333bfYq\\6J6JJJr8   c                 L    t          |d|z  z
            t          |          z  S Nr   r   r  s      r6   ru   zalpha_gen._cdf'  s#    3q5!!IaLL00r8   c           
      p    dt          j        |t          |t          |          z            z
            z  S r  )rP   r   r   r   rE   r}   r   s      r6   r~   zalpha_gen._ppf*  s.    2:a)AillN";";;<<<<r8   c                 D    t           j        gdz  t           j        gdz  z   S NrU   rP   ri   nanrE   r   s     r6   r   zalpha_gen._stats-  s    xzRVHQJ&&r8   N)r   r   r   r   r   _open_support_mask_support_maskrk   rr   r   ru   r~   r   r   r8   r6   r  r    s         > "4ME E E: : :K K K1 1 1= = =' ' ' ' 'r8   r  alphac                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )

anglit_gena  An anglit continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `anglit` is:

    .. math::

        f(x) = \sin(2x + \pi/2) = \cos(2x)

    for :math:`-\pi/4 \le x \le \pi/4`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zanglit_gen._shape_infoH  r   r8   c                 0    t          j        d|z            S r  )rP   cosr   s     r6   rr   zanglit_gen._pdfK  s    vac{{r8   c                 P    t          j        |t           j        dz  z             dz  S N   r   rP   sinr   r   s     r6   ru   zanglit_gen._cdfO  s!    vaai  #%%r8   c                 P    t          j        |t           j        dz  z             dz  S r#  )rP   r!  r   r   s     r6   ry   zanglit_gen._sfR  s!    va"%!)m$$++r8   c                 n    t          j        t          j        |                    t           j        dz  z
  S Nr$  )rP   arcsinr   r   r   s     r6   r~   zanglit_gen._ppfU  s%    y$$RU1W,,r8   c                     dt           j        t           j        z  dz  dz
  ddt           j        dz  dz
  z  t           j        t           j        z  dz
  dz  z  fS )	Nr      r   r  r$  `      rU   rP   r   rj   s    r6   r   zanglit_gen._statsX  sH    BE"%KN3&RB-?ruQQR@R-RRRr8   c                 0    dt          j        d          z
  S Nr   rU   rP   r   rj   s    r6   r   zanglit_gen._entropy[      {r8   N)r   r   r   r   rk   rr   ru   ry   r~   r   r   r   r8   r6   r  r  4  s         &    & & &, , ,- - -S S S    r8   r  r$  anglitc                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	arcsine_gena  An arcsine continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `arcsine` is:

    .. math::

        f(x) = \frac{1}{\pi \sqrt{x (1-x)}}

    for :math:`0 < x < 1`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zarcsine_gen._shape_infov  r   r8   c                     t          j        d          5  dt           j        z  t          j        |d|z
  z            z  cd d d            S # 1 swxY w Y   d S )Nignoredivider   r   )rP   errstater   r   r   s     r6   rr   zarcsine_gen._pdfy  s    [))) 	. 	.ru9RWQ!W---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.   *AAAc                 n    dt           j        z  t          j        t          j        |                    z  S Nr   )rP   r   r*  r   r   s     r6   ru   zarcsine_gen._cdf~  s%    25y271::....r8   c                 P    t          j        t           j        dz  |z            dz  S r?  r%  r   s     r6   r~   zarcsine_gen._ppf  s!    vbeCik""C''r8   c                     d}d}d}d}||||fS )Nr   g      ?r         r   rE   mumu2g1g2s        r6   r   zarcsine_gen._stats  s$    3Br8   c                     dS )Ngοr   rj   s    r6   r   zarcsine_gen._entropy  s    &&r8   N
r   r   r   r   rk   rr   ru   r~   r   r   r   r8   r6   r6  r6  b  sx         &  . . .
/ / /( ( (  ' ' ' ' 'r8   r6  arcsinec                       e Zd ZdZd ZdS )FitDataErrorz=Raised when input data is inconsistent with fixed parameters.c                 *    d|d|d|df| _         d S )Nz>Invalid values in `data`.  Maximum likelihood estimation with z requires that z < (x - loc)/scale  < z for each x in `data`.rG   )rE   distrr>   uppers       r6   __init__zFitDataError.__init__  sH    B$B B7<B B"'B B B
			r8   Nr   r   r   r   rQ  r   r8   r6   rL  rL    s)        GG
 
 
 
 
r8   rL  c                       e Zd ZdZd ZdS )rW   zN
    Raised when a solver fails to converge while fitting a distribution.
    c                 L    d}||                     dd          z  }|f| _        d S )Nz1Solver for the MLE equations failed to converge: 
 )replacerG   )rE   mesgemsgs      r6   rQ  zFitSolverError.__init__  s,    BT2&&&G			r8   NrR  r   r8   r6   rW   rW     s-         
    r8   rW   c                 p    t          j        | |z             }||| t          j        |           z   z  z
  }|S rN   rw   psi)r   r   rb   s1psiabfuncs         r6   _beta_mle_ar`    s8     F1q5MMEeVbfQii'((DKr8   c                     | \  }}t          j        ||z             }||| t          j        |          z   z  z
  ||| t          j        |          z   z  z
  g}|S rN   r[  )thetarb   r]  s2r   r   r^  r_  s           r6   _beta_mle_abrd    sb     DAqF1q5MMEufrvayy())ufrvayy())+DKr8   c                        e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Z fdZe eed           fd                        Zd Z xZS )beta_gena  A beta continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `beta` is:

    .. math::

        f(x, a, b) = \frac{\Gamma(a+b) x^{a-1} (1-x)^{b-1}}
                          {\Gamma(a) \Gamma(b)}

    for :math:`0 <= x <= 1`, :math:`a > 0`, :math:`b > 0`, where
    :math:`\Gamma` is the gamma function (`scipy.special.gamma`).

    `beta` takes :math:`a` and :math:`b` as shape parameters.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``pdf``, ``cdf``, ``ppf``, ``sf`` and ``isf``
    methods. [1]_

    %(after_notes)s

    References
    ----------
    .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS Nr   Fr   r
  r   rh   rE   iaibs      r6   rk   zbeta_gen._shape_info  =    UQK@@UQK@@Bxr8   Nc                 0    |                     |||          S rN   beta)rE   r   r   r   r   s        r6   r   zbeta_gen._rvs  s      At,,,r8   c                     t          j        d          5  t          j        |||          cd d d            S # 1 swxY w Y   d S Nr9  over)rP   r<  rn   	_beta_pdfrE   rq   r   r   s       r6   rr   zbeta_gen._pdf  s     [h''' 	* 	*=Aq))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*   9= =c                     t          j        |dz
  |           t          j        |dz
  |          z   }|t          j        ||          z  }|S r  )rw   xlog1pyxlogybetaln)rE   rq   r   r   lPxs        r6   r   zbeta_gen._logpdf  sG    jS1"%%S!(<(<<ryA
r8   c                 .    t          j        |||          S rN   )rw   betaincru  s       r6   ru   zbeta_gen._cdf  s    z!Q"""r8   c                 .    t          j        |||          S rN   )rw   betainccru  s       r6   ry   zbeta_gen._sf  s    {1a###r8   c                 .    t          j        |||          S rN   )rw   betainccinvru  s       r6   r   zbeta_gen._isf  s    ~aA&&&r8   c                 .    t          j        |||          S rN   )rn   	_beta_ppfrE   r}   r   r   s       r6   r~   zbeta_gen._ppf  s    }Q1%%%r8   c                 &   ||z   }||z  }||z  |dz  |dz   z  z  }d||z
  z  t          j        |dz             z  |dz   t          j        ||z            z  z  }d||z
  dz  |dz   z  ||z  |dz   z  z
  z  }||z  |dz   z  |dz   z  }||z  }	||||	fS )NrU   r         rP   r   )
rE   r   r   a_plus_b
_beta_mean_beta_variance_beta_skewness_beta_kurtosis_excess_n_beta_kurtosis_excess_d_beta_kurtosis_excesss
             r6   r   zbeta_gen._stats  s    q5xZ
1!x!| <=A;A)>)>>$qLBGAENN:<"#AzX\'B'(1u1'=(> #?"#a%8a<"8HqL"I 7:Q Q!	# 	#r8   c                    t          |t                    r|                                }t          |          t	          |          fd}t          j        |d          \  }}t                                          |||f          S )Nc                 F   | \  }}d||z
  z  t          j        ||z   dz             z  ||z   dz   z  t          j        ||z            z  }|dz  |dz  d|z  dz
  z  z
  |dz  |dz   z  z   d|z  |z  |dz   z  z
  }|||z  ||z   dz   z  ||z   dz   z  z  }|dz  }|z
  |z
  gS )NrU   r   r  r  r  )rq   r   r   skkurF  rG  s        r6   r_  z beta_gen._fitstart.<locals>.func  s    DAqAaCQ+++q1uqy9BGAaCLLHBA1ac!e$q!tQqSz1AaCE1Q3K?B!A#qs1u+qs1u%%B!GBrE2b5>!r8   )r   r   rN  )	r?   r*   	_uncensorr   r   r   fsolverA   	_fitstart)rE   rF   r_  r   r   rF  rG  	__class__s        @@r6   r  zbeta_gen._fitstart  s    dL)) 	$>>##D4[[t__	" 	" 	" 	" 	" 	" tZ001ww  QF 333r8   z        In the special case where `method="MLE"` and
        both `floc` and `fscale` are given, a
        `ValueError` is raised if any value `x` in `data` does not satisfy
        `floc < x < floc + fscale`.

r   c           	         |                     dd           }|                     dd           }|| t                      j        |g|R i |S |                    dd            |                    dd            t	          |g d          }t	          |g d          }t          |           ||t          d          t          j        |          	                                st          d          t          j
        |          |z
  |z  }t          j        |dk              st          j        |dk              rt          d	|||z   
          |                                }||||}	d|z
  }d|z
  }n|}	|	|z  d|z
  z  }
t          j        t           |
|	t#          |          t          j        |                                          fd          \  }}}}|dk    rt)          |          |d         }
||	|
}	}
nt          j        |                                          }t+          j        |                                           }|d|z
  z  |                    d          z  dz
  }||z  }
d|z
  |z  }	t          j        t0          |
|	gt#          |          ||fd          \  }}}}|dk    rt)          |          |\  }
}	|
|	||fS )Nr   r   f0fafix_a)f1fbfix_br   r   r   r   ro  r>   rP  T)rG   full_output)rX  )ddof)r=   rA   rC   r3   r   r7   r   rP   r   r   ravelanyrL  r   r   r  r`  lenr   sumrW   rw   log1pvarrd  )rE   rF   rG   r5   r   r   r  r  xbarr   r   rb  infoierrX  r]  rc  facr  s                     r6   rC   zbeta_gen.fit#  s'    xx%%(D))<6>577;t3d333d333 	4   !$(=(=(=>>!$(=(=(=>>$T***>bn ) * * * {4  $$&& 	ECDDD %/6$!) 	Htqy 1 1 	HvTGGGGyy{{>R^ ~ 4x4x DAH%A &._QTBF4LL$4$4$6$67 & & &"E4d
 axx$$////aA~ !1 !!##B4%$$&&B !d(#dhhAh&6&66:Cs
ATS A &._q!f$iiR( & & &"E4d
 axx$$////DAq!T6!!r8   c                 
   d }d }d }d }|dk    r|dk    r |||          S |dk    r$||z
  dk    r| ||          k    r |||          S |dk    r$||z
  dk    r| ||          k    r |||          S  |||          S )Nc                     t          j        | |          | dz
  t          j        |           z  z
  |dz
  t          j        |          z  z
  | |z   dz
  t          j        | |z             z  z   S r1  )rw   rz  r\  r   r   s     r6   regularz"beta_gen._entropy.<locals>.regular  sf    IaOOq1uq		&99UbfQii'(+,q519q1u*EF Gr8   c                    | |z   }dt          j        dt           j        z            t          j        |           z   t          j        |          z   dt          j        |          z  z
  dz   z  }d|z  d|dz  z  z   |dz  z   d|d	z  z  z
  }d
| z  d| dz  z  z
  | dz  z
  | d	z  z   }d
|z  d|dz  z  z
  |dz  z
  |d	z  z   }|||z   |z   dz  z   S )Nr   rU   r  r   n                         i
   x   r   )r   r   sum_ablog_termt1t2t3s          r6   asymptotic_ab_largez.beta_gen._entropy.<locals>.asymptotic_ab_large  s    UFqw"&))+bfQii7!BF6NN:JJQNH Vbo-<q~MBQAtG#ag-47BQAtG#ag-47BrBw|s222r8   c                    | |z   }t          j        |           | dz
  t          j        |           z  z
  }dd|z  z  dd|z  z  z   |dz  dz  z
  |dz  dz  z
  |dz  dz  z   |d	z  d
z  z   |dz  d
z  z
  d|z  z   dd|z  z  z
  |dz  dz  z   |dz  dz  z   |dz  dz  z
  |d	z  d
z  z
  |dz  dz  z   }|t          j        | |z            z  t          j        |          z   dt          j        |          z  z
  }||z   |z   S )Nr   rU      r  r  r  r                 r  <   ~   )rw   gammalnr\  rP   r  r   )r   r   r  r  r  r  s         r6   asymptotic_b_largez-beta_gen._entropy.<locals>.asymptotic_b_large  sM   UFA!a%26!99!44BQqS	Ar!tH$q$wrz1AtGCK?!T'#+MT'#+ !4,./h79:BvIG$,q.!#)4<#346<dl2oF $,s"# &,T\#%56  bhqsmm+bfQii7!BF6NN:JJH7X%%r8   c                     | dk    rdS t          j        |           }t          |          }t          | d|z  z            dz   }|dd|z   z  z  S )Nr   i  r  rU      )rP   log10r  )vjdigitsds       r6   threshold_largez*beta_gen._entropy.<locals>.threshold_large  sU    CxxtAVVFAf$%%)AR!a%[= r8   g    RAg    (RAg    .Ar   )rE   r   r   r  r  r  r  s          r6   r   zbeta_gen._entropy  s    	G 	G 	G	3 	3 	3
	& 
	& 
	&	! 	! 	! ;;1;;&&q!,,,%ZZAESLLQ//!2D2D-D-D%%a+++%ZZAESLLQ//!2D2D-D-D%%a+++71a== r8   r  )r   r   r   r   rk   r   rr   r   ru   ry   r   r~   r   r  rK   r	   r   rC   r   __classcell__r  s   @r6   rf  rf    s.        >  
- - - -* * *  
# # #$ $ $' ' '& & &# # # 4 4 4 4 4" } 5+ , , ,
c" c" c" c", , _c"J+! +! +! +! +! +! +!r8   rf  ro  c                   R    e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 ZdS )betaprime_gena  A beta prime continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `betaprime` is:

    .. math::

        f(x, a, b) = \frac{x^{a-1} (1+x)^{-a-b}}{\beta(a, b)}

    for :math:`x >= 0`, :math:`a > 0`, :math:`b > 0`, where
    :math:`\beta(a, b)` is the beta function (see `scipy.special.beta`).

    `betaprime` takes ``a`` and ``b`` as shape parameters.

    The distribution is related to the `beta` distribution as follows:
    If :math:`X` follows a beta distribution with parameters :math:`a, b`,
    then :math:`Y = X/(1-X)` has a beta prime distribution with
    parameters :math:`a, b` ([1]_).

    The beta prime distribution is a reparametrized version of the
    F distribution.  The beta prime distribution with shape parameters
    ``a`` and ``b`` and ``scale = s`` is equivalent to the F distribution
    with parameters ``d1 = 2*a``, ``d2 = 2*b`` and ``scale = (a/b)*s``.
    For example,

    >>> from scipy.stats import betaprime, f
    >>> x = [1, 2, 5, 10]
    >>> a = 12
    >>> b = 5
    >>> betaprime.pdf(x, a, b, scale=2)
    array([0.00541179, 0.08331299, 0.14669185, 0.03150079])
    >>> f.pdf(x, 2*a, 2*b, scale=(a/b)*2)
    array([0.00541179, 0.08331299, 0.14669185, 0.03150079])

    %(after_notes)s

    References
    ----------
    .. [1] Beta prime distribution, Wikipedia,
           https://en.wikipedia.org/wiki/Beta_prime_distribution

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS rh  rh   ri  s      r6   rk   zbetaprime_gen._shape_info  rl  r8   Nc                     t                               |||          }t                               |||          }||z  S Nr   r   )gammarvs)rE   r   r   r   r   u1u2s          r6   r   zbetaprime_gen._rvs  s9    YYqt,Y??YYqt,Y??Bwr8   c                 T    t          j        |                     |||                    S rN   rP   r   r   ru  s       r6   rr   zbetaprime_gen._pdf  "    vdll1a++,,,r8   c                     t          j        |dz
  |          t          j        ||z   |          z
  t          j        ||          z
  S r  )rw   ry  rx  rz  ru  s       r6   r   zbetaprime_gen._logpdf  s<    xC##bjQ&:&::RYq!__LLr8   c                 :    t          |dk    |||gd d           S )Nr   c                 F    t                               dd| z   z  ||          S r^   ro  ry   x_a_b_s      r6   <lambda>z$betaprime_gen._cdf.<locals>.<lambda>  s    txx1R4"b99 r8   c                 F    t                               | d| z   z  ||          S r^   ro  ru   r  s      r6   r  z$betaprime_gen._cdf.<locals>.<lambda>  s    $))B"Ir2">"> r8   f2r   ru  s       r6   ru   zbetaprime_gen._cdf  s:     EAq!999>>@ @ @ 	@r8   c                 :    t          |dk    |||gd d           S )Nr   c                 F    t                               dd| z   z  ||          S r^   r  r  s      r6   r  z#betaprime_gen._sf.<locals>.<lambda>  s    tyyAbD2r:: r8   c                 F    t                               | d| z   z  ||          S r^   r  r  s      r6   r  z#betaprime_gen._sf.<locals>.<lambda>  s    $((2qt9b""="= r8   r  r  ru  s       r6   ry   zbetaprime_gen._sf  s4    EAq!9::==
 
 
 	
r8   c                    t          j        |||          \  }}}t          j                            |||          }t          j        d          5  |d|z
  z  }d d d            n# 1 swxY w Y   |dk    }t          j        |          r*|r'dt          j                            |||          z  dz
  }n<dt          j                            ||         ||         ||                   z  dz
  ||<   |S )Nr9  r:  r   gH.?)rP   broadcast_arraysstatsro  r~   r<  isscalarr   )rE   pr   r   routrnear1s          r6   r~   zbetaprime_gen._ppf  s$   %aA..1a JOOAq!$$[))) 	 	q1u+C	 	 	 	 	 	 	 	 	 	 	 	 	 	 	V;q>> 	Q 5
1a00014EJOOAfIqy!F)LLLqPCK
s   	A&&A*-A*c                 P    t          |k    ||ffdt          j                  S )Nc           	           t          j         fdt          dt                    dz             D             d          S )Nc                 ,    g | ]}|z   d z
  |z
  z  S r   r   ).0ir   r   s     r6   
<listcomp>z9betaprime_gen._munp.<locals>.<lambda>.<locals>.<listcomp>+  s)    !L!L!LA1Q3q51Q3-!L!L!Lr8   r   r   axis)rP   prodranger  )r   r   rb   s   ``r6   r  z%betaprime_gen._munp.<locals>.<lambda>+  sE    !L!L!L!L!Lq#a&&(9K9K!L!L!LSTUUU r8   	fillvaluer   rP   ri   )rE   rb   r   r   s    `  r6   r  zbetaprime_gen._munp(  s8    EAq6UUUUf   	r8   r  )r   r   r   r   r   r  r  rk   r   rr   r   ru   ry   r~   r  r   r8   r6   r  r    s        . .^ "4M  
   
- - -M M M@ @ @
 
 
  $    r8   r  	betaprimec                   8    e Zd ZdZd Zd Zd Zd Zd
dZd Z	d	S )bradford_genab  A Bradford continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `bradford` is:

    .. math::

        f(x, c) = \frac{c}{\log(1+c) (1+cx)}

    for :math:`0 <= x <= 1` and :math:`c > 0`.

    `bradford` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS NcFr   r
  rh   rj   s    r6   rk   zbradford_gen._shape_infoH  r  r8   c                 B    |||z  dz   z  t          j        |          z  S r  rw   r  rE   rq   r  s      r6   rr   zbradford_gen._pdfK  s!    AaC#I!,,r8   c                 Z    t          j        ||z            t          j        |          z  S rN   r  r  s      r6   ru   zbradford_gen._cdfO  s!    x!}}rx{{**r8   c                 Z    t          j        |t          j        |          z            |z  S rN   rw   expm1r  rE   r}   r  s      r6   r~   zbradford_gen._ppfR  s#    xBHQKK((1,,r8   mvc                 d   t          j        d|z             }||z
  ||z  z  }|dz   |z  d|z  z
  d|z  |z  |z  z  }d }d }d|v ryt          j        d          d|z  |z  d|z  |z  |dz   z  z
  d|z  |z  ||dz   z  dz   z  z   z  }|t          j        |||dz
  z  d|z  z   z            d|z  |dz
  z  d|z  z   z  z  }d	|v rj|dz  |dz
  z  |d|z  d
z
  z  dz   z  d|z  |z  |z  |dz
  z  |dz
  z  z   d|z  |z  |z  d|z  dz
  z  z   d|dz  z  z   }|d|z  ||dz
  z  d|z  z   dz  z  z  }||||fS )Nr   r   rU   sr  	   r  r  kr,     r$     )rP   r   r   )rE   r  momentsr  rD  rE  rF  rG  s           r6   r   zbradford_gen._statsU  s   F3q5MMcAaC[#qyQ1Qq)'>>RT!VAaCE1Q3K/!Aq!A#wqy0AABB"'!Q!WQqS[/**AaC1IacM::B'>>Q$!*a1Rjm,RT!VAXqs^QqS-AAA#a%'1Q3r6"#%'1W-B!A#q!A#wqs{Q&&&B3Br8   c                 j    t          j        d|z             }|dz  t          j        ||z            z
  S Nr   r   r2  )rE   r  r  s      r6   r   zbradford_gen._entropyd  s.    F1Q3KKurvac{{""r8   Nr  rI  r   r8   r6   r	  r	  2  s         *E E E- - -+ + +- - -   # # # # #r8   r	  bradfordc                   T    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )burr_gena  A Burr (Type III) continuous random variable.

    %(before_notes)s

    See Also
    --------
    fisk : a special case of either `burr` or `burr12` with ``d=1``
    burr12 : Burr Type XII distribution
    mielke : Mielke Beta-Kappa / Dagum distribution

    Notes
    -----
    The probability density function for `burr` is:

    .. math::

        f(x; c, d) = c d \frac{x^{-c - 1}}
                              {{(1 + x^{-c})}^{d + 1}}

    for :math:`x >= 0` and :math:`c, d > 0`.

    `burr` takes ``c`` and ``d`` as shape parameters for :math:`c` and
    :math:`d`.

    This is the PDF corresponding to the third CDF given in Burr's list;
    specifically, it is equation (11) in Burr's paper [1]_. The distribution
    is also commonly referred to as the Dagum distribution [2]_. If the
    parameter :math:`c < 1` then the mean of the distribution does not
    exist and if :math:`c < 2` the variance does not exist [2]_.
    The PDF is finite at the left endpoint :math:`x = 0` if :math:`c * d >= 1`.

    %(after_notes)s

    References
    ----------
    .. [1] Burr, I. W. "Cumulative frequency functions", Annals of
       Mathematical Statistics, 13(2), pp 215-232 (1942).
    .. [2] https://en.wikipedia.org/wiki/Dagum_distribution
    .. [3] Kleiber, Christian. "A guide to the Dagum distributions."
       Modeling Income Distributions and Lorenz Curves  pp 97-117 (2008).

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS Nr  Fr   r
  r  rh   rE   icids      r6   rk   zburr_gen._shape_info  rl  r8   c                 d    t          |dk    |||gd d           }|j        dk    r|d         S |S )Nr   c                 6    ||z  | ||z  dz
  z  z  d| |z  z   z  S r^   r   r  c_d_s      r6   r  zburr_gen._pdf.<locals>.<lambda>  s(    rBw"r"uQw-8ABJG r8   c                 @    ||z  | | dz
  z  z  d| | z  z   |dz   z  z  S Nr   r   r   r*  s      r6   r  zburr_gen._pdf.<locals>.<lambda>  s6    27bbS3Y.?#@%&_"s($C$E r8   r  r   r   ndimrE   rq   r  r  outputs        r6   rr   zburr_gen._pdf  sX    FQ1IGGF FG G G
 ;!":r8   c                 d    t          |dk    |||gd d           }|j        dk    r|d         S |S )Nr   c                     t          j        |          t          j        |          z   t          j        ||z  dz
  |           z   |dz   t          j        | |z            z  z
  S r^   )rP   r   rw   ry  r  r*  s      r6   r  z"burr_gen._logpdf.<locals>.<lambda>  sS    r

RVBZZ 7"(2b519b:Q:Q Q#%a428BH+=+="=!> r8   c                     t          j        |          t          j        |          z   t          j        | dz
  |           z   t          j        |dz   | | z            z
  S r^   rP   r   rw   ry  rx  r*  s      r6   r  z"burr_gen._logpdf.<locals>.<lambda>  sT    26"::r

#:%'XrcAgr%:%:$;%'Z1bB3i%@%@$A r8   r  r   r/  r1  s        r6   r   zburr_gen._logpdf  s\    FQ1I? ?B B	C C C ;!":r8   c                     d|| z  z   | z  S r^   r   rE   rq   r  r  s       r6   ru   zburr_gen._cdf  s    AGr""r8   c                 :    t          j        || z            | z  S rN   r  r8  s       r6   r   zburr_gen._logcdf  s    xQB  QB''r8   c                 T    t          j        |                     |||                    S rN   rP   r   r   r8  s       r6   ry   zburr_gen._sf  "    vdkk!Q**+++r8   c                 B    t          j        d|| z  z   | z             S r^   rP   r  r8  s       r6   r   zburr_gen._logsf  s&    x1qA2w;1"--...r8   c                 $    |d|z  z  dz
  d|z  z  S N      r   r   rE   r}   r  r  s       r6   r~   zburr_gen._ppf  s    DFa46**r8   c                 h    t          j        d|z  |           }t          j        |          d|z  z  S NrA  rw   rx  r  )rE   r}   r  r  _qs        r6   r   zburr_gen._isf  s0    Zq1"%%x||q))r8   c           	         t          j        dd                              dd          |z  }t          j        ||z   d|z
            |z  \  }}}}t          j        |dk    |t           j                  }||dz  z
  }	t          j        |dk    |	t           j                  }
t          |dk    |||||	fd t           j        	          }t          |d
k    ||||||	fd t           j        	          }t          j        |          dk    rN|	                                |
	                                |	                                |	                                fS ||
||fS )Nr      r$  r   rU   r         @c                 Z    |d|z  |z  z
  d|dz  z  z   t          j        |dz            z  S )Nr  rU   r  )r  e1e2e3mu2_if_cs        r6   r  z!burr_gen._stats.<locals>.<lambda>  s6    b1R47lQr1uW.D/1w1}/E/E.F r8   r        @c                 T    |d|z  |z  z
  d|z  |dz  z  z   d|dz  z  z
  |dz  z  dz
  S )Nr$  r  rU   r  r   )r  rK  rL  rM  e4rN  s         r6   r  z!burr_gen._stats.<locals>.<lambda>  sB    qtBw,2b!e+aAg51DI r8   r   )
rP   arangereshaperw   ro  wherer  r   r0  item)rE   r  r  ncrK  rL  rM  rQ  rD  rN  rE  rF  rG  s                r6   r   zburr_gen._stats  sS   Yq!__$$Qq))A-Rb11A5BBXa#gr26**A:hq3w"&11GBH%G Gf   GBB)K Kf   71::??7799chhjj"''))RWWYY>>3Br8   c                     d t          j        |          t          j        |          t          j        |          }}}t          ||k    ||k    z  ||k    z  |||ffdt           j                  S )Nc                 N    d| z  |z  }|t          j        d|z
  ||z             z  S r  rw   ro  rb   r  r  rV  s       r6   __munpzburr_gen._munp.<locals>.__munp  .    a!BrwsRxR0000r8   c                      || |          S rN   r   )r  r  rb   _burr_gen__munps      r6   r  z burr_gen._munp.<locals>.<lambda>  s    &&Aq// r8   )rP   r   r   r  )rE   rb   r  r  r^  s       @r6   r  zburr_gen._munp  s|    	1 	1 	1 *Q--A
1a11q5Q!V,Q7!Q9999&" " 	"r8   N)r   r   r   r   rk   rr   r   ru   r   ry   r   r~   r   r   r  r   r8   r6   r"  r"  l  s        + +`  
	 	 	
 
 
# # #( ( (, , ,/ / /+ + +* * *  ." " " " "r8   r"  burrc                   N    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )
burr12_gena}  A Burr (Type XII) continuous random variable.

    %(before_notes)s

    See Also
    --------
    fisk : a special case of either `burr` or `burr12` with ``d=1``
    burr : Burr Type III distribution

    Notes
    -----
    The probability density function for `burr12` is:

    .. math::

        f(x; c, d) = c d \frac{x^{c-1}}
                              {(1 + x^c)^{d + 1}}

    for :math:`x >= 0` and :math:`c, d > 0`.

    `burr12` takes ``c`` and ``d`` as shape parameters for :math:`c`
    and :math:`d`.

    This is the PDF corresponding to the twelfth CDF given in Burr's list;
    specifically, it is equation (20) in Burr's paper [1]_.

    %(after_notes)s

    The Burr type 12 distribution is also sometimes referred to as
    the Singh-Maddala distribution from NIST [2]_.

    References
    ----------
    .. [1] Burr, I. W. "Cumulative frequency functions", Annals of
       Mathematical Statistics, 13(2), pp 215-232 (1942).

    .. [2] https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/b12pdf.htm

    .. [3] "Burr distribution",
       https://en.wikipedia.org/wiki/Burr_distribution

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS r$  rh   r%  s      r6   rk   zburr12_gen._shape_info  rl  r8   c                 T    t          j        |                     |||                    S rN   r  r8  s       r6   rr   zburr12_gen._pdf"  r  r8   c                     t          j        |          t          j        |          z   t          j        |dz
  |          z   t          j        | dz
  ||z            z   S r^   r6  r8  s       r6   r   zburr12_gen._logpdf&  sN    vayy26!99$rxAq'9'99BJr!tQPQT<R<RRRr8   c                 V    t          j        |                     |||                     S rN   rw   r  r   r8  s       r6   ru   zburr12_gen._cdf)  %    Q1--....r8   c                 @    t          j        d||z  z   | z             S r^   r  r8  s       r6   r   zburr12_gen._logcdf,  s$    x!ad(qb))***r8   c                 T    t          j        |                     |||                    S rN   r;  r8  s       r6   ry   zburr12_gen._sf/  r<  r8   c                 4    t          j        | ||z            S rN   rw   rx  r8  s       r6   r   zburr12_gen._logsf2  s    z1"ad###r8   c                 h    t          j        d|z  t          j        |           z            d|z  z  S Nr  r   r  rB  s       r6   r~   zburr12_gen._ppf5  s0     x1rx||+,,qs33r8   c                 f    t          j        d|z  t          j        |          z            d|z  z  S rm  )rw   r  rP   r   )rE   r  r  r  s       r6   r   zburr12_gen._isf;  s,    x1rvayy())AaC00r8   c                 V    d }t          ||z  |k    |||f|t          j                  S )Nc                 N    d| z  |z  }|t          j        d|z   ||z
            z  S r  rY  rZ  s       r6   moment_if_existsz*burr12_gen._munp.<locals>.moment_if_exists?  r\  r8   r  r   rP   r  )rE   rb   r  r  rq  s        r6   r  zburr12_gen._munp>  sD    	1 	1 	1 !a%!)aAY0@$&F, , , 	,r8   N)r   r   r   r   rk   rr   r   ru   r   ry   r   r~   r   r  r   r8   r6   ra  ra    s        + +X  
- - -S S S/ / /+ + +, , ,$ $ $4 4 41 1 1, , , , ,r8   ra  burr12c                   Z    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )fisk_gena  A Fisk continuous random variable.

    The Fisk distribution is also known as the log-logistic distribution.

    %(before_notes)s

    See Also
    --------
    burr

    Notes
    -----
    The probability density function for `fisk` is:

    .. math::

        f(x, c) = \frac{c x^{c-1}}
                       {(1 + x^c)^2}

    for :math:`x >= 0` and :math:`c > 0`.

    Please note that the above expression can be transformed into the following
    one, which is also commonly used:

    .. math::

        f(x, c) = \frac{c x^{-c-1}}
                       {(1 + x^{-c})^2}

    `fisk` takes ``c`` as a shape parameter for :math:`c`.

    `fisk` is a special case of `burr` or `burr12` with ``d=1``.

    Suppose ``X`` is a logistic random variable with location ``l``
    and scale ``s``. Then ``Y = exp(X)`` is a Fisk (log-logistic)
    random variable with ``scale = exp(l)`` and shape ``c = 1/s``.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zfisk_gen._shape_infou  r  r8   c                 :    t                               ||d          S r  )r_  rr   r  s      r6   rr   zfisk_gen._pdfx  s    yyAs###r8   c                 :    t                               ||d          S r  )r_  ru   r  s      r6   ru   zfisk_gen._cdf|      yyAs###r8   c                 :    t                               ||d          S r  )r_  ry   r  s      r6   ry   zfisk_gen._sf  s    xx1c"""r8   c                 :    t                               ||d          S r  )r_  r   r  s      r6   r   zfisk_gen._logpdf  s    ||Aq#&&&r8   c                 :    t                               ||d          S r  )r_  r   r  s      r6   r   zfisk_gen._logcdf  s    ||Aq#&&&r8   c                 :    t                               ||d          S r  )r_  r   r  s      r6   r   zfisk_gen._logsf  s    {{1a%%%r8   c                 :    t                               ||d          S r  )r_  r~   r  s      r6   r~   zfisk_gen._ppf  ry  r8   c                 :    t                               ||d          S r  )r_  r   r  s      r6   r   zfisk_gen._isf  ry  r8   c                 :    t                               ||d          S r  )r_  r  rE   rb   r  s      r6   r  zfisk_gen._munp  s    zz!Q$$$r8   c                 8    t                               |d          S r  )r_  r   rE   r  s     r6   r   zfisk_gen._stats  s    {{1c"""r8   c                 0    dt          j        |          z
  S r  r2  r  s     r6   r   zfisk_gen._entropy      26!99}r8   N)r   r   r   r   rk   rr   ru   ry   r   r   r   r~   r   r  r   r   r   r8   r6   ru  ru  J  s        ) )TE E E$ $ $$ $ $# # #' ' '' ' '& & &$ $ $$ $ $% % %# # #    r8   ru  fiskc                   P    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZddZdS )
cauchy_gena  A Cauchy continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `cauchy` is

    .. math::

        f(x) = \frac{1}{\pi (1 + x^2)}

    for a real number :math:`x`.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``ppf` and ``isf`` methods. [1]_

    %(after_notes)s

    References
    ----------
    .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zcauchy_gen._shape_info  r   r8   c                     t          j        d          5  dt           j        z  d||z  z   z  cd d d            S # 1 swxY w Y   d S )Nr9  rr  r   )rP   r<  r   r   s     r6   rr   zcauchy_gen._pdf  s    [h''' 	' 	'ru9c!A#g&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   ;??c                 b    t          j        |          }t          |dk     |fd d           }|S )Nr   c                 B    t            t          j        | dz            z
  S r  )r(   rP   r  absxs    r6   r  z$cauchy_gen._logpdf.<locals>.<lambda>  s    wh$'1B1B&B r8   c                 x    t            dt          j        |           z  t          j        d| z  dz            z   z
  S NrU   r   )r(   rP   r   r  r  s    r6   r  z$cauchy_gen._logpdf.<locals>.<lambda>  s4    )*26$<<"(AdFQ;:O:O)O)Q r8   fr  )rP   absr   )rE   rq   r  ys       r6   r   zcauchy_gen._logpdf  sM     vayy tax$BBR RS S S r8   c                 H    t          j        d|           t           j        z  S r^   rP   arctan2r   r   s     r6   ru   zcauchy_gen._cdf  s    z!aR  &&r8   c                 .    t          j        |dd          S Nr   r   )rn   _cauchy_ppfr   s     r6   r~   zcauchy_gen._ppf      q!Q'''r8   c                 F    t          j        d|          t           j        z  S r^   r  r   s     r6   ry   zcauchy_gen._sf  s    z!Q%%r8   c                 .    t          j        |dd          S r  )rn   _cauchy_isfr   s     r6   r   zcauchy_gen._isf  r  r8   c                 ^    t           j        t           j        t           j        t           j        fS rN   rP   r  rj   s    r6   r   zcauchy_gen._stats      vrvrvrv--r8   c                 D    t          j        dt           j        z            S r)  r   rj   s    r6   r   zcauchy_gen._entropy      vagr8   Nc                     t          |t                    r|                                }t          j        |g d          \  }}}|||z
  dz  fS N   2   K   rU   r?   r*   r  rP   
percentilerE   rF   rG   p25p50p75s         r6   r  zcauchy_gen._fitstart  Q    dL)) 	$>>##DdLLL99S#S3YM!!r8   rN   )r   r   r   r   rk   rr   r   ru   r~   ry   r   r   r   r  r   r8   r6   r  r    s         4  ' ' '
   ' ' '( ( (& & &( ( (. . .  " " " " " "r8   r  cauchyc                   P    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )chi_gena  A chi continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `chi` is:

    .. math::

        f(x, k) = \frac{1}{2^{k/2-1} \Gamma \left( k/2 \right)}
                   x^{k-1} \exp \left( -x^2/2 \right)

    for :math:`x >= 0` and :math:`k > 0` (degrees of freedom, denoted ``df``
    in the implementation). :math:`\Gamma` is the gamma function
    (`scipy.special.gamma`).

    Special cases of `chi` are:

        - ``chi(1, loc, scale)`` is equivalent to `halfnorm`
        - ``chi(2, 0, scale)`` is equivalent to `rayleigh`
        - ``chi(3, 0, scale)`` is equivalent to `maxwell`

    `chi` takes ``df`` as a shape parameter.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS NdfFr   r
  rh   rj   s    r6   rk   zchi_gen._shape_info      4BF^DDEEr8   Nc                 `    t          j        t                              |||                    S r  )rP   r   chi2r  rE   r  r   r   s       r6   r   zchi_gen._rvs  s$    wtxxLxIIJJJr8   c                 R    t          j        |                     ||                    S rN   r  rE   rq   r  s      r6   rr   zchi_gen._pdf  s"     vdll1b))***r8   c                     t          j        d          dt          j        d          z  |z  z
  t          j        d|z            z
  }|t          j        |dz
  |          z   d|dz  z  z
  S )NrU   r   r   )rP   r   rw   r  ry  )rE   rq   r  ls       r6   r   zchi_gen._logpdf  s_    F1II26!99R'"*RU*;*;;28BGQ'''"QT'11r8   c                 >    t          j        d|z  d|dz  z            S Nr   rU   rw   gammaincr  s      r6   ru   zchi_gen._cdf  s     {2b5"QT'***r8   c                 >    t          j        d|z  d|dz  z            S r  rw   	gammainccr  s      r6   ry   zchi_gen._sf!  s     |BrE2ad7+++r8   c                 \    t          j        dt          j        d|z  |          z            S NrU   r   rP   r   rw   gammaincinvrE   r}   r  s      r6   r~   zchi_gen._ppf$  s'    wq2q111222r8   c                 \    t          j        dt          j        d|z  |          z            S r  rP   r   rw   gammainccinvr  s      r6   r   zchi_gen._isf'  s'    wqB222333r8   c                 p   t          j        d          t          j        d|z  d          z  }|||z  z
  }d|dz  z  |dd|z  z
  z  z   t          j        t          j        |d                    z  }d|z  d|z
  z  d|dz  z  z
  d|dz  z  d|z  dz
  z  z   }|t          j        |d	z            z  }||||fS )
NrU   r   rI  r         ?r   r  r$  r   )rP   r   rw   pochr   powerrE   r  rD  rE  rF  rG  s         r6   r   zchi_gen._stats*  s    WQZZ"'#(C0002b5jCi"a"f+%rz"(32D2D'E'EErT3r6]1RU7"Qr1uW"Q%77
bjc"""3Br8   c                 >    d }d }t          |dk     |f||          S )Nc                     t          j        d| z            d| t          j        d          z
  | dz
  t          j        d| z            z  z
  z  z   S r   )rw   r  rP   r   digammar  s    r6   regular_formulaz)chi_gen._entropy.<locals>.regular_formula5  sO    JrBw''R"&))^rAvC"H9M9M.MMNO Pr8   c                     dt          j        t           j                  dz  z   | dz  dz  z
  | dz  dz  z
  d| dz  z  z
  | dz  d	z  z   S )
Nr   rU   r  r  r  gll?   r   r  s    r6   asymptotic_formulaz,chi_gen._entropy.<locals>.asymptotic_formula9  sW    "&--/)RVQJ6"b&!CBFm$')2vrk2 3r8   g     r@r  r  )rE   r  r  r  s       r6   r   zchi_gen._entropy3  sK    	P 	P 	P	3 	3 	3 "s(RFO/1 1 1 	1r8   r  r   r   r   r   rk   r   rr   r   ru   ry   r~   r   r   r   r   r8   r6   r  r    s         <F F FK K K K+ + +2 2 2+ + +, , ,3 3 34 4 4  1 1 1 1 1r8   r  chic                   P    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )chi2_gena  A chi-squared continuous random variable.

    For the noncentral chi-square distribution, see `ncx2`.

    %(before_notes)s

    See Also
    --------
    ncx2

    Notes
    -----
    The probability density function for `chi2` is:

    .. math::

        f(x, k) = \frac{1}{2^{k/2} \Gamma \left( k/2 \right)}
                   x^{k/2-1} \exp \left( -x/2 \right)

    for :math:`x > 0`  and :math:`k > 0` (degrees of freedom, denoted ``df``
    in the implementation).

    `chi2` takes ``df`` as a shape parameter.

    The chi-squared distribution is a special case of the gamma
    distribution, with gamma parameters ``a = df/2``, ``loc = 0`` and
    ``scale = 2``.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zchi2_gen._shape_infof  r  r8   Nc                 .    |                     ||          S rN   )	chisquarer  s       r6   r   zchi2_gen._rvsi  s    %%b$///r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zchi2_gen._pdfl  s     vdll1b))***r8   c                     t          j        |dz  dz
  |          |dz  z
  t          j        |dz            z
  t          j        d          |z  dz  z
  S )Nr   r   rU   )rw   ry  r  rP   r   r  s      r6   r   zchi2_gen._logpdfp  sO    x2a##ad*RZ2->->>"&))B,PRARRRr8   c                 ,    t          j        ||          S rN   )rw   chdtrr  s      r6   ru   zchi2_gen._cdfs      xAr8   c                 ,    t          j        ||          S rN   )rw   chdtrcr  s      r6   ry   zchi2_gen._sfv      yQr8   c                 ,    t          j        ||          S rN   )rw   chdtrirE   r  r  s      r6   r   zchi2_gen._isfy  r  r8   c                 8    dt          j        |dz  |          z  S r  rw   r  r  s      r6   r~   zchi2_gen._ppf|  s    1a((((r8   c                 Z    |}d|z  }dt          j        d|z            z  }d|z  }||||fS )NrU   r         (@r  r  s         r6   r   zchi2_gen._stats  s=    drws2v"W3Br8   c                 H    d|z  }d }d }t          |dk     |f||          S )Nr   c                     | t          j        d          z   t          j        |           z   d| z
  t          j        |           z  z   S r  )rP   r   rw   r  r\  )half_dfs    r6   r  z*chi2_gen._entropy.<locals>.regular_formula  s?    bfQii'"*W*=*==[BF7OO34 5r8   c                     t          j        d          ddt          j        dt           j        z            z   z  z   }d| z  }|d|d|d|dz  z   z  z   z  z   z  dt          j        |           z  z   |z   S )NrU   r   r   gUUUUUUUUUUUUտgllg      @r   )r  r  hs      r6   r  z-chi2_gen._entropy.<locals>.asymptotic_formula  s}     q		CRVAbeG__!455AGAta51S5=(9!9::;w'(*+, -r8   }   r  r  )rE   r  r  r  r  s        r6   r   zchi2_gen._entropy  sR    (	5 	5 	5		- 		- 		- 'C-')/1 1 1 	1r8   r  )r   r   r   r   rk   r   rr   r   ru   ry   r   r~   r   r   r   r8   r6   r  r  D  s           BF F F0 0 0 0+ + +S S S            ) ) )  1 1 1 1 1r8   r  r  c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )
cosine_gena\  A cosine continuous random variable.

    %(before_notes)s

    Notes
    -----
    The cosine distribution is an approximation to the normal distribution.
    The probability density function for `cosine` is:

    .. math::

        f(x) = \frac{1}{2\pi} (1+\cos(x))

    for :math:`-\pi \le x \le \pi`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zcosine_gen._shape_info  r   r8   c                 P    dt           j        z  dt          j        |          z   z  S Nr   r   rP   r   r!  r   s     r6   rr   zcosine_gen._pdf  s    RU{AbfQiiK((r8   c                 r    t          j        |          }t          |dk    |fd t           j                   S )Nr  c                 n    t          j        |           t          j        dt           j        z            z
  S r  )rP   r  r   r   r  s    r6   r  z$cosine_gen._logpdf.<locals>.<lambda>  s!    BHQKK"&25//$A r8   r  )rP   r!  r   ri   r  s      r6   r   zcosine_gen._logpdf  s=    F1II!r'A4AA%'VG- - - 	-r8   c                 *    t          j        |          S rN   rn   _cosine_cdfr   s     r6   ru   zcosine_gen._cdf  s    q!!!r8   c                 ,    t          j        |           S rN   r  r   s     r6   ry   zcosine_gen._sf  s    r"""r8   c                 *    t          j        |          S rN   rn   _cosine_invcdfrE   r  s     r6   r~   zcosine_gen._ppf  s    !!$$$r8   c                 ,    t          j        |           S rN   r  r
  s     r6   r   zcosine_gen._isf  s    "1%%%%r8   c                     t           j        t           j        z  dz  dz
  }dt           j        dz  dz
  z  dt           j        t           j        z  dz
  dz  z  z  }d	|d	|fS )
NrI  r   r  r$  Z         @r  rU   r   r/  )rE   r  r  s      r6   r   zcosine_gen._stats  sW    URU]S C'BE1HrM"cRURU]Q->,B&BCAsA~r8   c                 J    t          j        dt           j        z            dz
  S )Nr$  r   r   rj   s    r6   r   zcosine_gen._entropy  s    vags""r8   Nr   r   r   r   rk   rr   r   ru   ry   r~   r   r   r   r   r8   r6   r  r    s         (  ) ) )- - -" " "# # #% % %& & &  
# # # # #r8   r  cosinec                   P    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )
dgamma_gena  A double gamma continuous random variable.

    The double gamma distribution is also known as the reflected gamma
    distribution [1]_.

    %(before_notes)s

    Notes
    -----
    The probability density function for `dgamma` is:

    .. math::

        f(x, a) = \frac{1}{2\Gamma(a)} |x|^{a-1} \exp(-|x|)

    for a real number :math:`x` and :math:`a > 0`. :math:`\Gamma` is the
    gamma function (`scipy.special.gamma`).

    `dgamma` takes ``a`` as a shape parameter for :math:`a`.

    %(after_notes)s

    References
    ----------
    .. [1] Johnson, Kotz, and Balakrishnan, "Continuous Univariate
           Distributions, Volume 1", Second Edition, John Wiley and Sons
           (1994).

    %(example)s

    c                 @    t          dddt          j        fd          gS r	  rh   rj   s    r6   rk   zdgamma_gen._shape_info  r  r8   Nc                     |                     |          }t                              |||          }|t          j        |dk    dd          z  S Nr   r  r   r   r  )uniformr  r  rP   rT  )rE   r   r   r   ugms         r6   r   zdgamma_gen._rvs  sL      d ++YYqt,Y??BHQ#Xq"----r8   c                     t          |          }ddt          j        |          z  z  ||dz
  z  z  t          j        |           z  S r  )r  rw   r  rP   r   rE   rq   r   axs       r6   rr   zdgamma_gen._pdf  s@    VVAbhqkkM"2#;.<<r8   c                     t          |          }t          j        |dz
  |          |z
  t          j        d          z
  t          j        |          z
  S r  )r  rw   ry  rP   r   r  r  s       r6   r   zdgamma_gen._logpdf  sB    VVxC$$r)BF1II5
1EEr8   c           	          t          j        |dk    ddt          j        ||          z  z   dt          j        ||           z            S Nr   r   )rP   rT  rw   r  r  r  s      r6   ru   zdgamma_gen._cdf  sK    xAc"+a"3"333BLQB///1 1 	1r8   c           
          t          j        |dk    dt          j        ||          z  ddt          j        ||           z  z             S r   )rP   rT  rw   r  r  r  s      r6   ry   zdgamma_gen._sf  sK    xABLA...c"+a!"4"4446 6 	6r8   c                 j    t           j                            |          t          j        d          z
  S Nr   )r  r  r   rP   r   r  s     r6   r   zdgamma_gen._entropy  s%    {##A&&44r8   c           	          t          j        |dk    t          j        |d|z  dz
            t          j        |d|z                       S r   rP   rT  rw   r  r  r  s      r6   r~   zdgamma_gen._ppf  sI    xCq!A#'22AaC0002 2 	2r8   c           	          t          j        |dk    t          j        |d|z  dz
             t          j        |d|z                      S r   r%  r  s      r6   r   zdgamma_gen._isf  sI    xC1Q373331Q3//1 1 	1r8   c                 <    ||dz   z  }d|d|dz   |dz   z  |z  dz
  fS )Nr   r   r   rI  r   )rE   r   rE  s      r6   r   zdgamma_gen._stats"  s4    3iCququoc1#555r8   r  )r   r   r   r   rk   r   rr   r   ru   ry   r   r~   r   r   r   r8   r6   r  r    s         >E E E. . . .
= = =
F F F1 1 1
6 6 6
5 5 52 2 2
1 1 1
6 6 6 6 6r8   r  dgammac                       e Zd ZdZej        Zej        Zej	        Z
ej        Zej        Zej        Zd Zd Zd Zd ZddZd Zd	 Zd
 Z	d Zd Zd Zd ZdS )dpareto_lognorm_gena  A double Pareto lognormal continuous random variable.

    %(before_notes)s

    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]_.

    %(after_notes)s

    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.

    %(example)s

    c                 X    |                      |          |                     |          z  S rN   )_Phic_phirE   zs     r6   _Rzdpareto_lognorm_gen._Rc  s!    zz!}}tyy||++r8   c                 X    |                      |          |                     |          z
  S rN   )_logPhic_logphir.  s     r6   _logRzdpareto_lognorm_gen._logRf  s#    }}Q$,,q//11r8   c           	         t          ddt          j         t          j        fd          t          dddt          j        fd          t          dddt          j        fd          t          dddt          j        fd          gS )Nr  Fr
  r  r   r   r   rh   rj   s    r6   rk   zdpareto_lognorm_gen._shape_infoi  so    3'8.II326{NCC326{NCC326{NCCE 	Er8   c                 *    |dk    |dk    z  |dk    z  S Nr   r   )rE   r  r  r   r   s        r6   rc   zdpareto_lognorm_gen._argchecko  s    A!a% AE**r8   Nc                     |                     |||          }|                    |          }|                    |          }	t          j        |||z  z   |	|z  z
            S Nr  )normalstandard_exponentialrP   r   )
rE   r  r  r   r   r   r   ZE1E2s
             r6   r   zdpareto_lognorm_gen._rvsr  sk     1400..D.99..D.99va"q&j26)***r8   c                 t   t          j        dd          5  t          j        |          |}}||z
  |z  }||z  |z
  }	||z  |z   }
t          j        t          j        |          t          j        |          z   t          j        ||z             z
  |z
            }||                     |          z  }|t          j        |                     |	          |                     |
                    z  }d d d            n# 1 swxY w Y   t           j         ||dk    t          j        |          z  <   |d         S )Nr9  invalidr;  r   r   )	rP   r<  r   r   r3  	logaddexpr4  ri   rV   )rE   rq   r  r  r   r   log_ymr/  x1x2r  s               r6   r   zdpareto_lognorm_gen._logpdf{  sW   [(;;; 	@ 	@vayy!1EaAQBQB*RVAYY2RVAE]]BUJKKC4<<??"C2<

2

2???C	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ (*vgQ!Vrx{{"#2ws   CC>>DDc           	         t          j        dd          5  t          j        |          |}}||z
  |z  }||z  |z
  }	||z  |z   }
|                     |          }|                     |          }t          j        |          |                     |	          z   }t          j        |          |                     |
          z   }t          j        ||||d          \  }}}}}t          j        ||g|| gdd          \  }}|||z   t          j        ||z             z
  g}t          j	        t          j        ||| |z  gd                    }d d d            n# 1 swxY w Y   t           j
         ||dk    <   |d         S )	Nr9  r@  r   r   T)r   r  return_sign)r   r  r   )rP   r<  r   _logPhir3  r4  r  rw   	logsumexpr   ri   )rE   rq   r  r  r   r   rC  rD  r/  rE  rF  r  r  r  t4onet5rQ   tempr  s                       r6   r   zdpareto_lognorm_gen._logcdf  s   [(;;; 	M 	Mvayy!1EaAQBQBaBaB&))djjnn,B&))djjnn,B"$"5b"b"a"H"HBBC b"X#t1RVWWWHBR"&Q--/0D*R\$3T	2BKKKLLC	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M  vgAF2ws   D9EE #E c           	      N    t          |                     |||||                    S rN   )r   r   rE   rq   r  r  r   r   s         r6   r   zdpareto_lognorm_gen._logsf  s$    aAq!44555r8   c           	      X    t          j        |                     |||||                    S rN   r  rP  s         r6   rr   zdpareto_lognorm_gen._pdf  &    vdll1aAq11222r8   c           	      X    t          j        |                     |||||                    S rN   rP   r   r   rP  s         r6   ru   zdpareto_lognorm_gen._cdf  rR  r8   c           	      X    t          j        |                     |||||                    S rN   r;  rP  s         r6   ry   zdpareto_lognorm_gen._sf  s&    vdkk!Q1a00111r8   c                     |t          |          }}||z  ||z
  ||z   z  z  t          j        ||z  |dz  |dz  z  dz  z             z  }t          j        |          }t          j        |||k    <   |S r  )floatrP   r   r   r  )	rE   rb   r  r  r   r   rD  r  r  s	            r6   r  zdpareto_lognorm_gen._munp  sv    %((11u!a%AE*+bfQUQ!Va1f_q=P5P.Q.QQjoofAF
r8   r  )r   r   r   r   r  r   r3  r   rI  r   r2  rr   r-  ru   _Phiry   r,  r0  r4  rk   rc   r   r  r   r8   r6   r*  r*  *  s       0 0b lGlG{H9D9DHE, , ,2 2 2E E E+ + ++ + + +
 
 
  (6 6 6
3 3 33 3 32 2 2    r8   r*  dpareto_lognormc                   V    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd ZdS )dweibull_genav  A double Weibull continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `dweibull` is given by

    .. math::

        f(x, c) = c / 2 |x|^{c-1} \exp(-|x|^c)

    for a real number :math:`x` and :math:`c > 0`.

    `dweibull` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zdweibull_gen._shape_info  r  r8   Nc                     |                     |          }t                              |||          }|t          j        |dk    dd          z  S r  )r  weibull_minr  rP   rT  )rE   r  r   r   r  ws         r6   r   zdweibull_gen._rvs  sL      d ++OOAD|ODDBHQ#Xq"--..r8   c                 r    t          |          }|dz  ||dz
  z  z  t          j        ||z             z  }|S Nr   r   )r  rP   r   )rE   rq   r  r  Pxs        r6   rr   zdweibull_gen._pdf  s;    VVWrAcE{"RVRUF^^3	r8   c                     t          |          }t          j        |          t          j        d          z
  t          j        |dz
  |          z   ||z  z
  S ra  )r  rP   r   rw   ry  )rE   rq   r  r  s       r6   r   zdweibull_gen._logpdf  sF    VVvayy26#;;&!c'2)>)>>QFFr8   c                     dt          j        t          |          |z             z  }t          j        |dk    d|z
  |          S Nr   r   r   )rP   r   r  rT  )rE   rq   r  Cx1s       r6   ru   zdweibull_gen._cdf  s>    BFCFFAI:&&&xAq3w,,,r8   c                     dt          j        |dk    |d|z
            z  }t          j        t          j        |           d|z            }t          j        |dk    ||           S Nr   r   r   )rP   rT  r  r   )rE   r}   r  r  s       r6   r~   zdweibull_gen._ppf  s[    28AHaa000hs|S1W--xCsd+++r8   c                     dt           j                            t          j        |          |          z  }t          j        |dk    |d|z
            S re  )r  r^  ry   rP   r  rT  )rE   rq   r  half_weibull_min_sfs       r6   ry   zdweibull_gen._sf  sG    !E$5$9$9"&))Q$G$GGxA2A8K4KLLLr8   c                     dt          j        |dk    |d|z
            z  }t          j                            ||          }t          j        |dk    | |          S rh  )rP   rT  r  r^  r   )rE   r}   r  double_qweibull_min_isfs        r6   r   zdweibull_gen._isf  sU    c1b1f555+001==xC/!1?CCCr8   c                 N    d|dz  z
  t          j        dd|z  |z  z             z  S )Nr   rU   r   rw   r  r  s      r6   r  zdweibull_gen._munp  s,    QUrxcAgk(9::::r8   c                     dS N)r   Nr   Nr   r  s     r6   r   zdweibull_gen._stats      r8   c                 n    t           j                            |          t          j        d          z
  }|S r#  )r  r^  r   rP   r   )rE   r  r  s      r6   r   zdweibull_gen._entropy  s*    &&q))BF3KK7r8   r  )r   r   r   r   rk   r   rr   r   ru   r~   ry   r   r  r   r   r   r8   r6   r[  r[    s         *E E E/ / / /
  G G G- - -, , ,
M M MD D D
; ; ;         r8   r[  dweibullc                       e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Ze eed          d                         ZdS )	expon_genaE  An exponential continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `expon` is:

    .. math::

        f(x) = \exp(-x)

    for :math:`x \ge 0`.

    %(after_notes)s

    A common parameterization for `expon` is in terms of the rate parameter
    ``lambda``, such that ``pdf = lambda * exp(-lambda * x)``. This
    parameterization corresponds to using ``scale = 1 / lambda``.

    The exponential distribution is a special case of the gamma
    distributions, with gamma shape parameter ``a = 1``.

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zexpon_gen._shape_info  r   r8   Nc                 ,    |                     |          S rN   )r;  r   s      r6   r   zexpon_gen._rvs  s    00666r8   c                 ,    t          j        |           S rN   rP   r   r   s     r6   rr   zexpon_gen._pdf   s    vqbzzr8   c                     | S rN   r   r   s     r6   r   zexpon_gen._logpdf$  	    r	r8   c                 .    t          j        |            S rN   rw   r  r   s     r6   ru   zexpon_gen._cdf'      !}r8   c                 .    t          j        |            S rN   r  r   s     r6   r~   zexpon_gen._ppf*  r  r8   c                 ,    t          j        |           S rN   rz  r   s     r6   ry   zexpon_gen._sf-  s    vqbzzr8   c                     | S rN   r   r   s     r6   r   zexpon_gen._logsf0  r|  r8   c                 ,    t          j        |           S rN   r2  r   s     r6   r   zexpon_gen._isf3      q		zr8   c                     dS )N)r   r   r         @r   rj   s    r6   r   zexpon_gen._stats6  r   r8   c                     dS r  r   rj   s    r6   r   zexpon_gen._entropy9      sr8   z        When `method='MLE'`,
        this function uses explicit formulas for the maximum likelihood
        estimation of the exponential distribution parameters, so the
        `optimizer`, `loc` and `scale` keyword arguments are
        ignored.

r   c                 b   t          |          dk    rt          d          |                    dd           }|                    dd           }t          |           ||t	          d          t          j        |          }t          j        |                                          st	          d          |	                                }||}n$|}||k     rt          d|t
          j                  ||                                |z
  }n|}t          |          t          |          fS )	Nr   Too many arguments.r   r   r   r   exponr  )r  r4   r3   r7   r   rP   r   r   r   minrL  ri   r   rW  )	rE   rF   rG   r5   r   r   data_minr.   r/   s	            r6   rC   zexpon_gen.fit<  s,    t99q==1222xx%%(D))$T*** 2 ) * * * z${4  $$&& 	ECDDD88::<CCC#~~"7$bfEEEE>IIKK#%EEE Szz5<<''r8   r  )r   r   r   r   rk   r   rr   r   ru   r~   ry   r   r   r   r   rK   r
   r   rC   r   r8   r6   rv  rv    s	        4  7 7 7 7              " " "    6   &( &(  _&( &( &(r8   rv  r  c                   >    e Zd ZdZd Zd
dZd Zd Zd Zd Z	d	 Z
dS )exponnorm_gena  An exponentially modified Normal continuous random variable.

    Also known as the exponentially modified Gaussian distribution [1]_.

    %(before_notes)s

    Notes
    -----
    The probability density function for `exponnorm` is:

    .. math::

        f(x, K) = \frac{1}{2K} \exp\left(\frac{1}{2 K^2} - x / K \right)
                  \text{erfc}\left(-\frac{x - 1/K}{\sqrt{2}}\right)

    where :math:`x` is a real number and :math:`K > 0`.

    It can be thought of as the sum of a standard normal random variable
    and an independent exponentially distributed random variable with rate
    ``1/K``.

    %(after_notes)s

    An alternative parameterization of this distribution (for example, in
    the Wikipedia article [1]_) involves three parameters, :math:`\mu`,
    :math:`\lambda` and :math:`\sigma`.

    In the present parameterization this corresponds to having ``loc`` and
    ``scale`` equal to :math:`\mu` and :math:`\sigma`, respectively, and
    shape parameter :math:`K = 1/(\sigma\lambda)`.

    .. versionadded:: 0.16.0

    References
    ----------
    .. [1] Exponentially modified Gaussian distribution, Wikipedia,
           https://en.wikipedia.org/wiki/Exponentially_modified_Gaussian_distribution

    %(example)s

    c                 @    t          dddt          j        fd          gS )NKFr   r
  rh   rj   s    r6   rk   zexponnorm_gen._shape_info  r  r8   Nc                 f    |                     |          |z  }|                    |          }||z   S rN   )r;  r   )rE   r  r   r   expvalgvals         r6   r   zexponnorm_gen._rvs  s7    224881<++D11}r8   c                 R    t          j        |                     ||                    S rN   r  )rE   rq   r  s      r6   rr   zexponnorm_gen._pdf       vdll1a(()))r8   c                 v    d|z  }|d|z  |z
  z  }|t          ||z
            z   t          j        |          z
  S Nr   r   r   rP   r   )rE   rq   r  invKexpargs        r6   r   zexponnorm_gen._logpdf  sA    Qwta(QX...::r8   c                     d|z  }|d|z  |z
  z  }|t          ||z
            z   }t          |          t          j        |          z
  S r  r   r   rP   r   rE   rq   r  r  r  logprods         r6   ru   zexponnorm_gen._cdf  sL    Qwta(<D111||bfWoo--r8   c                     d|z  }|d|z  |z
  z  }|t          ||z
            z   }t          |           t          j        |          z   S r  r  r  s         r6   ry   zexponnorm_gen._sf  sN    Qwta(<D111!}}rvg..r8   c                 Z    ||z  }d|z   }d|dz  z  |dz  z  }d|z  |z  |dz  z  }||||fS )Nr   rU   r  rB  r  r  r   )rE   r  K2opK2skwkrts         r6   r   zexponnorm_gen._stats  sO    URx!Q$h%BhmdRj($S  r8   r  )r   r   r   r   rk   r   rr   r   ru   ry   r   r   r8   r6   r  r  o  s        ( (RE E E   
* * *; ; ;
. . ./ / /! ! ! ! !r8   r  	exponnormc                 P    t          j        t          j        ||                     S )a'  
    Compute (1 + x)**y - 1.

    Uses expm1 and xlog1py to avoid loss of precision when
    (1 + x)**y is close to 1.

    Note that the inverse of this function with respect to x is
    ``_pow1pm1(x, 1/y)``.  That is, if

        t = _pow1pm1(x, y)

    then

        x = _pow1pm1(t, 1/y)
    )rP   r  rw   rx  rq   r  s     r6   _pow1pm1r    s       8BJq!$$%%%r8   c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
exponweib_gena  An exponentiated Weibull continuous random variable.

    %(before_notes)s

    See Also
    --------
    weibull_min, numpy.random.Generator.weibull

    Notes
    -----
    The probability density function for `exponweib` is:

    .. math::

        f(x, a, c) = a c [1-\exp(-x^c)]^{a-1} \exp(-x^c) x^{c-1}

    and its cumulative distribution function is:

    .. math::

        F(x, a, c) = [1-\exp(-x^c)]^a

    for :math:`x > 0`, :math:`a > 0`, :math:`c > 0`.

    `exponweib` takes :math:`a` and :math:`c` as shape parameters:

    * :math:`a` is the exponentiation parameter,
      with the special case :math:`a=1` corresponding to the
      (non-exponentiated) Weibull distribution `weibull_min`.
    * :math:`c` is the shape parameter of the non-exponentiated Weibull law.

    %(after_notes)s

    References
    ----------
    https://en.wikipedia.org/wiki/Exponentiated_Weibull_distribution

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS Nr   Fr   r
  r  rh   rE   rj  r&  s      r6   rk   zexponweib_gen._shape_info  rl  r8   c                 T    t          j        |                     |||                    S rN   r  rE   rq   r   r  s       r6   rr   zexponweib_gen._pdf	  $     vdll1a++,,,r8   c                     ||z   }t          j        |           }t          j        |          t          j        |          z   t          j        |dz
  |          z   |z   t          j        |dz
  |          z   }|S r  )rw   r  rP   r   ry  )rE   rq   r   r  negxcexm1clogps          r6   r   zexponweib_gen._logpdf	  sq    A% q		BF1II%S%(@(@@S!,,-r8   c                 >    t          j        ||z              }||z  S rN   r~  )rE   rq   r   r  r  s        r6   ru   zexponweib_gen._cdf	  s!    1a4% axr8   c                 j    t          j        |d|z  z              t          j        d|z            z  S r  )rw   r  rP   r   )rE   r}   r   r  s       r6   r~   zexponweib_gen._ppf	  s2    1s1u:+&&&CE):):::r8   c                 R    t          t          j        ||z              |           S rN   )r  rP   r   r  s       r6   ry   zexponweib_gen._sf	  s%    "&!Q$--++++r8   c                 ^    t          j        t          | d|z                        d|z  z  S r^   )rP   r   r  )rE   r  r   r  s       r6   r   zexponweib_gen._isf	  s1    1"ac***+++qs33r8   Nr   r   r   r   rk   rr   r   ru   r~   ry   r   r   r8   r6   r  r    s        ' 'P  
- - -
    ; ; ;, , ,4 4 4 4 4r8   r  	exponweibc                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
exponpow_gena  An exponential power continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `exponpow` is:

    .. math::

        f(x, b) = b x^{b-1} \exp(1 + x^b - \exp(x^b))

    for :math:`x \ge 0`, :math:`b > 0`.  Note that this is a different
    distribution from the exponential power distribution that is also known
    under the names "generalized normal" or "generalized Gaussian".

    `exponpow` takes ``b`` as a shape parameter for :math:`b`.

    %(after_notes)s

    References
    ----------
    http://www.math.wm.edu/~leemis/chart/UDR/PDFs/Exponentialpower.pdf

    %(example)s

    c                 @    t          dddt          j        fd          gS Nr   Fr   r
  rh   rj   s    r6   rk   zexponpow_gen._shape_info:	  r  r8   c                 R    t          j        |                     ||                    S rN   r  rE   rq   r   s      r6   rr   zexponpow_gen._pdf=	       vdll1a(()))r8   c                     ||z  }dt          j        |          z   t          j        |dz
  |          z   |z   t          j        |          z
  }|S Nr   r   )rP   r   rw   ry  r   )rE   rq   r   xbr  s        r6   r   zexponpow_gen._logpdfA	  sH    Tq		MBHQWa00025r

Br8   c                 X    t          j        t          j        ||z                        S rN   r~  r  s      r6   ru   zexponpow_gen._cdfF	  s#    "(1a4..))))r8   c                 V    t          j        t          j        ||z                       S rN   rP   r   rw   r  r  s      r6   ry   zexponpow_gen._sfI	  s     vrx1~~o&&&r8   c                 \    t          j        t          j        |                     d|z  z  S r  rw   r  rP   r   r  s      r6   r   zexponpow_gen._isfL	  s%    "&))$$1--r8   c                 t    t          t          j        t          j        |                      d|z            S r  powrw   r  rE   r}   r   s      r6   r~   zexponpow_gen._ppfO	  s,    28RXqb\\M**CE222r8   N)r   r   r   r   rk   rr   r   ru   ry   r   r~   r   r8   r6   r  r  	  s         6E E E* * *  
* * *' ' '. . .3 3 3 3 3r8   r  exponpowc                   X    e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 Zd ZdS )fatiguelife_gena0  A fatigue-life (Birnbaum-Saunders) continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `fatiguelife` is:

    .. math::

        f(x, c) = \frac{x+1}{2c\sqrt{2\pi x^3}} \exp(-\frac{(x-1)^2}{2x c^2})

    for :math:`x >= 0` and :math:`c > 0`.

    `fatiguelife` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    References
    ----------
    .. [1] "Birnbaum-Saunders distribution",
           https://en.wikipedia.org/wiki/Birnbaum-Saunders_distribution

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zfatiguelife_gen._shape_infos	  r  r8   Nc                     |                     |          }d|z  |z  }||z  }dd|z  z   d|z  t          j        d|z             z  z   }|S )Nr   r   rU   r   )r   rP   r   )rE   r  r   r   r/  rq   rF  ts           r6   r   zfatiguelife_gen._rvsv	  sW    ((..E!GqS!B$J1RWQV__,,r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zfatiguelife_gen._pdf}	  s"     vdll1a(()))r8   c                    t          j        |dz             |dz
  dz  d|z  |dz  z  z  z
  t          j        d|z            z
  dt          j        dt           j        z            dt          j        |          z  z   z  z
  S )Nr   rU   r   r   r  r   r  s      r6   r   zfatiguelife_gen._logpdf	  sq    qsqsQh#a%1*55qsCRVAbeG__q{234 	5r8   c                     t          d|z  t          j        |          dt          j        |          z  z
  z            S r  )r   rP   r   r  s      r6   ru   zfatiguelife_gen._cdf	  s2    qBGAJJRWQZZ$?@AAAr8   c                 l    |t          |          z  }d|t          j        |dz  dz             z   dz  z  S N      ?rU   r$  r   rP   r   rE   r}   r  tmps       r6   r~   zfatiguelife_gen._ppf	  s9    )A,,sRWS!VaZ0001444r8   c                     t          d|z  t          j        |          dt          j        |          z  z
  z            S r  )r   rP   r   r  s      r6   ry   zfatiguelife_gen._sf	  s2    a271::BGAJJ#>?@@@r8   c                 n    | t          |          z  }d|t          j        |dz  dz             z   dz  z  S r  r  r  s       r6   r   zfatiguelife_gen._isf	  s;    b9Q<<sRWS!VaZ0001444r8   c                     ||z  }|dz  dz   }d|z  dz   }||z  dz  }d|z  d|z  dz   z  t          j        |d          z  }d	|z  d
|z  dz   z  |dz  z  }||||fS )Nr   r   r  rO  r$     r  r  r  ]   g      D@rP   r  )rE   r  c2rD  denrE  rF  rG  s           r6   r   zfatiguelife_gen._stats	  s     qS#X^BhnfslUbeck"RXc3%7%77Vr"ut|$sCx/3Br8   r  )r   r   r   r   r   r  r  rk   r   rr   r   ru   r~   ry   r   r   r   r8   r6   r  r  V	  s         4 "4ME E E   * * *
5 5 5B B B5 5 5A A A5 5 5    r8   r  fatiguelifec                   >    e Zd ZdZd Zd Zd
dZd Zd Zd Z	d	 Z
dS )foldcauchy_genao  A folded Cauchy continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `foldcauchy` is:

    .. math::

        f(x, c) = \frac{1}{\pi (1+(x-c)^2)} + \frac{1}{\pi (1+(x+c)^2)}

    for :math:`x \ge 0` and :math:`c \ge 0`.

    `foldcauchy` takes ``c`` as a shape parameter for :math:`c`.

    %(example)s

    c                     |dk    S r7  r   r  s     r6   rc   zfoldcauchy_gen._argcheck	      Avr8   c                 @    t          dddt          j        fd          gS Nr  Fr   rg   rh   rj   s    r6   rk   zfoldcauchy_gen._shape_info	      326{MBBCCr8   Nc                 V    t          t                              |||                    S )Nr.   r   r   )r  r  r  rE   r  r   r   s       r6   r   zfoldcauchy_gen._rvs	  s0    6::!$+7  9 9 : : 	:r8   c                 \    dt           j        z  dd||z
  dz  z   z  dd||z   dz  z   z  z   z  S Nr   r   rU   r/  r  s      r6   rr   zfoldcauchy_gen._pdf	  s:    25y#q!A#z*S!QqS1H*-==>>r8   c                     dt           j        z  t          j        ||z
            t          j        ||z             z   z  S r  rP   r   arctanr  s      r6   ru   zfoldcauchy_gen._cdf	  s0    25y")AaC..29QqS>>9::r8   c                 ~    t          j        d||z
            t          j        d||z             z   t           j        z  S r^   r  r  s      r6   ry   zfoldcauchy_gen._sf	  s6    
 
1a!e$$rz!QU';';;RUBBr8   c                 ^    t           j        t           j        t           j        t           j        fS rN   r  r  s     r6   r   zfoldcauchy_gen._stats	  r  r8   r  r   r   r   r   rc   rk   r   rr   ru   ry   r   r   r8   r6   r  r  	  s         &  D D D: : : :? ? ?; ; ;C C C. . . . .r8   r  
foldcauchyc                   J    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd ZdS )f_gena  An F continuous random variable.

    For the noncentral F distribution, see `ncf`.

    %(before_notes)s

    See Also
    --------
    ncf

    Notes
    -----
    The F distribution with :math:`df_1 > 0` and :math:`df_2 > 0` degrees of freedom is
    the distribution of the ratio of two independent chi-squared distributions with
    :math:`df_1` and :math:`df_2` degrees of freedom, after rescaling by
    :math:`df_2 / df_1`.

    The probability density function for `f` is:

    .. math::

        f(x, df_1, df_2) = \frac{df_2^{df_2/2} df_1^{df_1/2} x^{df_1 / 2-1}}
                                {(df_2+df_1 x)^{(df_1+df_2)/2}
                                 B(df_1/2, df_2/2)}

    for :math:`x > 0`.

    `f` accepts shape parameters ``dfn`` and ``dfd`` for :math:`df_1`, the degrees of
    freedom of the chi-squared distribution in the numerator, and :math:`df_2`, the
    degrees of freedom of the chi-squared distribution in the denominator, respectively.

    %(after_notes)s

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )NdfnFr   r
  dfdrh   )rE   idfnidfds      r6   rk   zf_gen._shape_info	  s>    %BF^DD%BF^DDd|r8   Nc                 0    |                     |||          S rN   )r  )rE   r  r  r   r   s        r6   r   z
f_gen._rvs
  s    ~~c3---r8   c                 T    t          j        |                     |||                    S rN   r  rE   rq   r  r  s       r6   rr   z
f_gen._pdf
  s$     vdll1c3//000r8   c                 <   d|z  }d|z  }|dz  t          j        |          z  |dz  t          j        |          z  z   t          j        |dz  dz
  |          z   ||z   dz  t          j        |||z  z             z  t          j        |dz  |dz            z   z
  }|S Nr   rU   r   )rP   r   rw   ry  rz  )rE   rq   r  r  rb   rD  r{  s          r6   r   zf_gen._logpdf
  s    #I#IsRVAYY1rvayy028AaC!GQ3G3GGaC7bfQ1Woo-	!A#qs0C0CCE
r8   c                 .    t          j        |||          S rN   )rw   fdtrr  s       r6   ru   z
f_gen._cdf
  s    wsC###r8   c                 .    t          j        |||          S rN   )rw   fdtrcr  s       r6   ry   z	f_gen._sf
      xS!$$$r8   c                 .    t          j        |||          S rN   )rw   fdtri)rE   r}   r  r  s       r6   r~   z
f_gen._ppf
  r
  r8   c                    d|z  d|z  }}|dz
  |dz
  |dz
  |dz
  f\  }}}}t          |dk    ||fd t          j                  }	t          |dk    ||||fd	 t          j                  }
t          |d
k    ||||fd t          j                  }|t          j        d          z  }t          |dk    |||fd t          j                  }|dz  }|	|
||fS )Nr   r   rO  r         @rU   c                     | |z  S rN   r   )v2v2_2s     r6   r  zf_gen._stats.<locals>.<lambda>"
  s
    R$Y r8   r$  c                 6    d|z  |z  | |z   z  | |dz  z  |z  z  S r  r   )v1r  r  v2_4s       r6   r  zf_gen._stats.<locals>.<lambda>'
  s-    FRK29%dAg)<= r8   r  c                 T    d| z  |z   |z  t          j        || | |z   z  z            z  S r  r  )r  r  r  v2_6s       r6   r  zf_gen._stats.<locals>.<lambda>-
  s4    Vd]d"RWTR295E-F%G%GG r8   r.  c                     d| | z  |z  z   |z  S )Nr.  r   )rF  r  v2_8s      r6   r  zf_gen._stats.<locals>.<lambda>4
  s    AR$$6$#> r8   r  )r   rP   ri   r  r   )rE   r  r  r  r  r  r  r  r  rD  rE  rF  rG  s                r6   r   zf_gen._stats
  s   c28B!#b"r'27BG!CdD$FRJ&&F 
 FRT4(> >F	  FRtT*H HF	 
 	bgbkkFRt$>>F  	g3Br8   c                 @   d|z  }d|z  }d||z   z  }t          j        |          t          j        |          z
  t          j        ||          z   d|z
  t          j        |          z  z   d|z   t          j        |          z  z
  |t          j        |          z  z   S r  )rP   r   rw   rz  r\  )rE   r  r  half_dfnhalf_dfdhalf_sums         r6   r   zf_gen._entropy:
  s     99#)$sbfSkk)BIh,I,IIX!1!11256\x  5!!#+bfX.>.>#>? 	@r8   r  )r   r   r   r   rk   r   rr   r   ru   ry   r~   r   r   r   r8   r6   r  r  	  s        # #H  
. . . .1 1 1  $ $ $% % %% % %  <
@ 
@ 
@ 
@ 
@r8   r  r  c                   >    e Zd ZdZd Zd Zd
dZd Zd Zd Z	d	 Z
dS )foldnorm_genaz  A folded normal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `foldnorm` is:

    .. math::

        f(x, c) = \sqrt{2/\pi} cosh(c x) \exp(-\frac{x^2+c^2}{2})

    for :math:`x \ge 0` and :math:`c \ge 0`.

    `foldnorm` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                     |dk    S r7  r   r  s     r6   rc   zfoldnorm_gen._argcheckh
  r  r8   c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zfoldnorm_gen._shape_infok
  r  r8   Nc                 L    t          |                    |          |z             S rN   r  r   r  s       r6   r   zfoldnorm_gen._rvsn
  s#    <//559:::r8   c                 L    t          ||z             t          ||z
            z   S rN   r   r  s      r6   rr   zfoldnorm_gen._pdfq
  s#    Q)AaC..00r8   c                     t          j        d          }dt          j        ||z
  |z            t          j        ||z   |z            z   z  S r  )rP   r   rw   erf)rE   rq   r  sqrt_twos       r6   ru   zfoldnorm_gen._cdfu
  sE    71::bfa!eX-..Q8H1I1IIJJr8   c                 L    t          ||z
            t          ||z             z   S rN   r   r  s      r6   ry   zfoldnorm_gen._sfy
  s!    A!a%00r8   c                    ||z  }t          j        d|z            t          j        dt           j        z            z  }d|z  |t	          j        |t          j        d          z            z  z   }|dz   ||z  z
  }d||z  |z  ||z  z
  |z
  z  }|t          j        |d          z  }||dz   z  dz   d|z  |z  z   }|d|d	z
  z  d	|dz  z  z
  |dz  z  z  }||dz  z  d	z
  }||||fS )
N      r   rU   r   r  r  r  r  rI  )rP   r   r   r   rw   r%  r  )rE   r  r  expfacrD  rE  rF  rG  s           r6   r   zfoldnorm_gen._stats|
  s
    qSR272be8#4#44YRVAbgajjL11111fr"un2b58be#f,-
bhsC   27^a"V)B,.
rR"W~RU
*b!e33#s(]R3Br8   r  r  r   r8   r6   r  r  R
  s         *  D D D; ; ; ;1 1 1K K K1 1 1    r8   r  foldnormc                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z eed           fd            Z xZS )weibull_min_gena  Weibull minimum continuous random variable.

    The Weibull Minimum Extreme Value distribution, from extreme value theory
    (Fisher-Gnedenko theorem), is also often simply called the Weibull
    distribution. It arises as the limiting distribution of the rescaled
    minimum of iid random variables.

    %(before_notes)s

    See Also
    --------
    weibull_max, numpy.random.Generator.weibull, exponweib

    Notes
    -----
    The probability density function for `weibull_min` is:

    .. math::

        f(x, c) = c x^{c-1} \exp(-x^c)

    for :math:`x > 0`, :math:`c > 0`.

    `weibull_min` takes ``c`` as a shape parameter for :math:`c`.
    (named :math:`k` in Wikipedia article and :math:`a` in
    ``numpy.random.weibull``).  Special shape values are :math:`c=1` and
    :math:`c=2` where Weibull distribution reduces to the `expon` and
    `rayleigh` distributions respectively.

    Suppose ``X`` is an exponentially distributed random variable with
    scale ``s``. Then ``Y = X**k`` is `weibull_min` distributed with shape
    ``c = 1/k`` and scale ``s**k``.

    %(after_notes)s

    References
    ----------
    https://en.wikipedia.org/wiki/Weibull_distribution

    https://en.wikipedia.org/wiki/Fisher-Tippett-Gnedenko_theorem

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zweibull_min_gen._shape_info
  r  r8   c                 v    |t          ||dz
            z  t          j        t          ||                     z  S r^   r  rP   r   r  s      r6   rr   zweibull_min_gen._pdf
  s1    Q!}RVSAYYJ////r8   c                 ~    t          j        |          t          j        |dz
  |          z   t	          ||          z
  S r^   rP   r   rw   ry  r  r  s      r6   r   zweibull_min_gen._logpdf
  s2    vayy28AE1---Aq		99r8   c                 J    t          j        t          ||                      S rN   rw   r  r  r  s      r6   ru   zweibull_min_gen._cdf
  s    #a))$$$$r8   c                 P    t          t          j        |            d|z            S r  r  r  s      r6   r~   zweibull_min_gen._ppf
  s"    BHaRLL=#a%(((r8   c                 R    t          j        |                     ||                    S rN   r;  r  s      r6   ry   zweibull_min_gen._sf
       vdkk!Q''(((r8   c                 $    t          ||           S rN   r  r  s      r6   r   zweibull_min_gen._logsf
  s    Aq		zr8   c                 8    t          j        |           d|z  z  S r^   r2  r  s      r6   r   zweibull_min_gen._isf
  s    
ac""r8   c                 <    t          j        d|dz  |z  z             S r  ro  r  s      r6   r  zweibull_min_gen._munp
  s    xAcE!G$$$r8   c                 X    t            |z  t          j        |          z
  t           z   dz   S r^   r$   rP   r   r  s     r6   r   zweibull_min_gen._entropy
  %    w{RVAYY&/!33r8   a          If ``method='mm'``, parameters fixed by the user are respected, and the
        remaining parameters are used to match distribution and sample moments
        where possible. For example, if the user fixes the location with
        ``floc``, the parameters will only match the distribution skewness and
        variance to the sample skewness and variance; no attempt will be made
        to match the means or minimize a norm of the errors.
        

r   c           	         t          |t                    rJ|                                dk    r|                                }n t	                      j        |g|R i |S |                    dd          r t	                      j        |g|R i |S t          | |||          \  }}}}|                    dd          	                                }d t          j        |          d} |          }	|	k     r'|dk    r!||s t	                      j        |g|R i |S |dk    rd	\  }
}}nEt          |          r|d         nd }
|                    d
d           }|                    dd           }| |
t          fdd|gd          j        }
n||}
|d|bt          j        |          }t          j        |t%          j        dd|
z  z             t%          j        dd|
z  z             dz  z
  z            }n||}|7|5t          j        |          }||t%          j        dd|
z  z             z  z
  }n||}|dk    r|
||fS  t	                      j        ||
f||d|S )Nr   superfitFr1   r;   c                     t          j        dd| z  z             }t          j        dd| z  z             }t          j        dd| z  z             }d|dz  z  d|z  |z  z
  |z   }||dz  z
  dz  }||z  S )Nr   rU   r  r  ro  )r  gamma1gamma2gamma3numr  s         r6   skewz!weibull_min_gen.fit.<locals>.skew
  s|    Xa!e__FXa!e__FXa!e__Ffai-!F(6/1F:CFAI%-Cs7Nr8   g     @r<   NNNr.   r/   c                       |           z
  S rN   r   )r  r  rF  s    r6   r  z%weibull_min_gen.fit.<locals>.<lambda>  s    dd1ggk r8   g{Gz?bisect)bracketr1   r   rU   r.   r/   )r?   r*   r@   r  rA   rC   r3   _check_fit_input_parametersr=   r>   r  rF  r  r+   rootrP   r  r   rw   r  r   )rE   rF   rG   r5   fcr   r   r1   max_cs_minr  r.   r/   r  rD  r  rF  r  s                  @@r6   rC   zweibull_min_gen.fit
  s    dL)) 	8  ""a''~~''"uww{47$777$77788J&& 	4577;t3d333d333 "=T4=A4"I "Ib$(E**0022	 	 	 JtUu994BJtJ577;t3d333d333 T>>,MAsEEt99.Q$A((5$''CHHWd++E:!) 11111D%=#+- - --1 A^A>emtAGA!AaC%28AacE??A3E!EFGGEEE<CKAeBHQ1W----CCCT>>c5=  577;tQECuEEEEEr8   )r   r   r   r   rk   rr   r   ru   r~   ry   r   r   r  r   r	   r   rC   r  r  s   @r6   r-  r-  
  s       + +XE E E0 0 0: : :% % %) ) )) ) )  # # #% % %4 4 4 } 5   JF JF JF JF JF JF JF JF JFr8   r-  r^  c                   j     e Zd ZdZd Zd Z fdZd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Z xZS )truncweibull_min_gena9  A doubly truncated Weibull minimum continuous random variable.

    %(before_notes)s

    See Also
    --------
    weibull_min, truncexpon

    Notes
    -----
    The probability density function for `truncweibull_min` is:

    .. math::

        f(x, a, b, c) = \frac{c x^{c-1} \exp(-x^c)}{\exp(-a^c) - \exp(-b^c)}

    for :math:`a < x <= b`, :math:`0 \le a < b` and :math:`c > 0`.

    `truncweibull_min` takes :math:`a`, :math:`b`, and :math:`c` as shape
    parameters.

    Notice that the truncation values, :math:`a` and :math:`b`, are defined in
    standardized form:

    .. math::

        a = (u_l - loc)/scale
        b = (u_r - loc)/scale

    where :math:`u_l` and :math:`u_r` are the specific left and right
    truncation values, respectively. In other words, the support of the
    distribution becomes :math:`(a*scale + loc) < x <= (b*scale + loc)` when
    :math:`loc` and/or :math:`scale` are provided.

    %(after_notes)s

    References
    ----------

    .. [1] Rinne, H. "The Weibull Distribution: A Handbook". CRC Press (2009).

    %(example)s

    c                 *    |dk    ||k    z  |dk    z  S Nr   r   rE   r  r   r   s       r6   rc   ztruncweibull_min_gen._argcheckd  s    RAE"a"f--r8   c                     t          dddt          j        fd          }t          dddt          j        fd          }t          dddt          j        fd          }|||gS )Nr  Fr   r
  r   rg   r   rh   )rE   r&  rj  rk  s       r6   rk   z truncweibull_min_gen._shape_infog  sY    UQK@@UQK??UQK@@B|r8   c                 J    t                                          |d          S )N)r   r   r   rN  rA   r  rE   rF   r  s     r6   r  ztruncweibull_min_gen._fitstartm  s     ww  I 666r8   c                 
    ||fS rN   r   rU  s       r6   r   z!truncweibull_min_gen._get_supportq      !tr8   c                 
   t          j        t          ||                     t          j        t          ||                     z
  }|t          ||dz
            z  t          j        t          ||                     z  |z  S r^   rP   r   r  )rE   rq   r  r   r   denums         r6   rr   ztruncweibull_min_gen._pdft  sh    Q
##bfc!QiiZ&8&88C1Q3KK"&#a))"4"44==r8   c           	      6   t          j        t          j        t          ||                     t          j        t          ||                     z
            }t          j        |          t	          j        |dz
  |          z   t          ||          z
  |z
  S r^   )rP   r   r   r  rw   ry  )rE   rq   r  r   r   logdenums         r6   r   ztruncweibull_min_gen._logpdfx  ss    6"&#a)),,rvs1ayyj/A/AABBvayy28AE1---Aq		9HDDr8   c                 (   t          j        t          ||                     t          j        t          ||                     z
  }t          j        t          ||                     t          j        t          ||                     z
  }||z  S rN   r]  rE   rq   r  r   r   rE  r^  s          r6   ru   ztruncweibull_min_gen._cdf|  p    vs1ayyj!!BFC1II:$6$66Q
##bfc!QiiZ&8&88U{r8   c           	      p   t          j        t          j        t          ||                     t          j        t          ||                     z
            }t          j        t          j        t          ||                     t          j        t          ||                     z
            }||z
  S rN   rP   r   r   r  rE   rq   r  r   r   lognumr`  s          r6   r   ztruncweibull_min_gen._logcdf      Aq		z**RVSAYYJ-?-??@@6"&#a)),,rvs1ayyj/A/AABB  r8   c                 (   t          j        t          ||                     t          j        t          ||                     z
  }t          j        t          ||                     t          j        t          ||                     z
  }||z  S rN   r]  rb  s          r6   ry   ztruncweibull_min_gen._sf  rc  r8   c           	      p   t          j        t          j        t          ||                     t          j        t          ||                     z
            }t          j        t          j        t          ||                     t          j        t          ||                     z
            }||z
  S rN   re  rf  s          r6   r   ztruncweibull_min_gen._logsf  rh  r8   c                     t          t          j        d|z
  t          j        t          ||                     z  |t          j        t          ||                     z  z              d|z            S r^   r  rP   r   r   rE   r}   r  r   r   s        r6   r   ztruncweibull_min_gen._isf  e    VQUbfc!QiiZ0001rvs1ayyj7I7I3IIJJJAaC  	r8   c                     t          t          j        d|z
  t          j        t          ||                     z  |t          j        t          ||                     z  z              d|z            S r^   rl  rm  s        r6   r~   ztruncweibull_min_gen._ppf  rn  r8   c           	      v   t          j        ||z  dz             t          j        ||z  dz   t          ||                    t          j        ||z  dz   t          ||                    z
  z  }t	          j        t          ||                     t	          j        t          ||                     z
  }||z  S r  )rw   r  r  r  rP   r   )rE   rb   r  r   r   	gamma_funr^  s          r6   r  ztruncweibull_min_gen._munp  s    HQqS2X&&K!b#a)),,r{1Q38SAYY/O/OO	 Q
##bfc!QiiZ&8&885  r8   )r   r   r   r   rc   rk   r  r   rr   r   ru   r   ry   r   r   r~   r  r  r  s   @r6   rR  rR  7  s        + +X. . .  7 7 7 7 7  > > >E E E  
! ! !
  
! ! !
  
  
! ! ! ! ! ! !r8   rR  truncweibull_minr  c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )weibull_max_gena0  Weibull maximum continuous random variable.

    The Weibull Maximum Extreme Value distribution, from extreme value theory
    (Fisher-Gnedenko theorem), is the limiting distribution of rescaled
    maximum of iid random variables. This is the distribution of -X
    if X is from the `weibull_min` function.

    %(before_notes)s

    See Also
    --------
    weibull_min

    Notes
    -----
    The probability density function for `weibull_max` is:

    .. math::

        f(x, c) = c (-x)^{c-1} \exp(-(-x)^c)

    for :math:`x < 0`, :math:`c > 0`.

    `weibull_max` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    References
    ----------
    https://en.wikipedia.org/wiki/Weibull_distribution

    https://en.wikipedia.org/wiki/Fisher-Tippett-Gnedenko_theorem

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zweibull_max_gen._shape_info  r  r8   c                 z    |t          | |dz
            z  t          j        t          | |                     z  S r^   r0  r  s      r6   rr   zweibull_max_gen._pdf  s5    aR1~bfc1"ajj[1111r8   c                     t          j        |          t          j        |dz
  |           z   t	          | |          z
  S r^   r2  r  s      r6   r   zweibull_max_gen._logpdf  s6    vayy28AaC!,,,sA2qzz99r8   c                 J    t          j        t          | |                     S rN   r]  r  s      r6   ru   zweibull_max_gen._cdf  s    vsA2qzzk"""r8   c                 &    t          | |           S rN   r9  r  s      r6   r   zweibull_max_gen._logcdf  s    QB

{r8   c                 L    t          j        t          | |                      S rN   r4  r  s      r6   ry   zweibull_max_gen._sf  s!    #qb!**%%%%r8   c                 P    t          t          j        |           d|z             S r  )r  rP   r   r  s      r6   r~   zweibull_max_gen._ppf  s#    RVAYYJA&&&&r8   c                 t    t          j        d|dz  |z  z             }t          |          dz  rd}nd}||z  S )Nr   rU   r  r   )rw   r  r  )rE   rb   r  valsgns        r6   r  zweibull_max_gen._munp  sE    hs1S57{##q66A: 	CCCSyr8   c                 X    t            |z  t          j        |          z
  t           z   dz   S r^   r=  r  s     r6   r   zweibull_max_gen._entropy  r>  r8   N)r   r   r   r   rk   rr   r   ru   r   ry   r~   r  r   r   r8   r6   rt  rt    s        # #HE E E2 2 2: : :# # #  & & &' ' '  4 4 4 4 4r8   rt  weibull_max)r   r   c                   N    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )genlogistic_gena  A generalized logistic continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `genlogistic` is:

    .. math::

        f(x, c) = c \frac{\exp(-x)}
                         {(1 + \exp(-x))^{c+1}}

    for real :math:`x` and :math:`c > 0`. In literature, different
    generalizations of the logistic distribution can be found. This is the type 1
    generalized logistic distribution according to [1]_. It is also referred to
    as the skew-logistic distribution [2]_.

    `genlogistic` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    References
    ----------
    .. [1] Johnson et al. "Continuous Univariate Distributions", Volume 2,
           Wiley. 1995.
    .. [2] "Generalized Logistic Distribution", Wikipedia,
           https://en.wikipedia.org/wiki/Generalized_logistic_distribution

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zgenlogistic_gen._shape_info  r  r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zgenlogistic_gen._pdf  r  r8   c                     |dz
   |dk     z  dz
  }t          j        |          }t          j        |          ||z  z   |dz   t          j        t          j        |                     z  z
  S Nr   r   )rP   r  r   rw   r  r   )rE   rq   r  multr  s        r6   r   zgenlogistic_gen._logpdf  sc     Qx1q5!A%vayyvayy49$!rxu/F/F'FFFr8   c                 >    dt          j        |           z   | z  }|S r^   rz  )rE   rq   r  Cxs       r6   ru   zgenlogistic_gen._cdf   s!    r

lqb!	r8   c                 X    | t          j        t          j        |                     z  S rN   )rP   r  r   r  s      r6   r   zgenlogistic_gen._logcdf$  s#    rBHRVQBZZ((((r8   c                 X    t          j        t          j        |d|z                       S rD  )rP   r   rw   powm1r  s      r6   r~   zgenlogistic_gen._ppf'  s%    rx46**++++r8   c                 T    t          j        |                     ||                     S rN   rw   r  r   r  s      r6   ry   zgenlogistic_gen._sf*  #    a++,,,,r8   c                 4    |                      d|z
  |          S r^   r~   r  s      r6   r   zgenlogistic_gen._isf-  s    yyQ"""r8   c                    t           t          j        |          z   }t          j        t          j        z  dz  t          j        d|          z   }dt          j        d|          z  dt          z  z   }|t          j        |d          z  }t          j        dz  dz  dt          j        d|          z  z   }||d	z  z  }||||fS )
Nr  rU   r  r  r  r$        .@r  r   )r$   rw   r\  rP   r   zetar%   r  rE   r  rD  rE  rF  rG  s         r6   r   zgenlogistic_gen._stats0  s    bfQiieBEk#o1-1&(
bhsC   UAXd]Qrwq!}}_,
c3h3Br8   c                 6    t          |dk     |fd d           S )Ng    ^Ac                 r    t          j        |            t          j        | dz             z   t          z   dz   S r^   )rP   r   rw   r\  r$   r  s    r6   r  z*genlogistic_gen._entropy.<locals>.<lambda>;  s+    RVAYYJA$>$G!$K r8   c                 (    dd| z  z  t           z   dz   S r1  r$   r  s    r6   r  z*genlogistic_gen._entropy.<locals>.<lambda>A  s    q!a%y6'9A'= r8   r  r  r  s     r6   r   zgenlogistic_gen._entropy9  s1    !c'A5KK >=? ? ? 	?r8   N)r   r   r   r   rk   rr   r   ru   r   r~   ry   r   r   r   r   r8   r6   r  r    s         @E E E* * *G G G  ) ) ), , ,- - -# # #  ? ? ? ? ?r8   r  genlogisticc                   b    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZddZd Zd ZdS )genpareto_gena  A generalized Pareto continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `genpareto` is:

    .. math::

        f(x, c) = (1 + c x)^{-1 - 1/c}

    defined for :math:`x \ge 0` if :math:`c \ge 0`, and for
    :math:`0 \le x \le -1/c` if :math:`c < 0`.

    `genpareto` takes ``c`` as a shape parameter for :math:`c`.

    For :math:`c=0`, `genpareto` reduces to the exponential
    distribution, `expon`:

    .. math::

        f(x, 0) = \exp(-x)

    For :math:`c=-1`, `genpareto` is uniform on ``[0, 1]``:

    .. math::

        f(x, -1) = 1

    %(after_notes)s

    %(example)s

    c                 *    t          j        |          S rN   rP   r   r  s     r6   rc   zgenpareto_gen._argcheckk      {1~~r8   c                 V    t          ddt          j         t          j        fd          gS Nr  Fr
  rh   rj   s    r6   rk   zgenpareto_gen._shape_infon  $    3'8.IIJJr8   c                     t          j        |          }t          |dk     |fd t           j                  }t          j        |dk    | j        | j                  }||fS )Nr   c                     d| z  S rD  r   r  s    r6   r  z,genpareto_gen._get_support.<locals>.<lambda>t  s
    q r8   )rP   r   r   ri   rT  r   )rE   r  r   r   s       r6   r   zgenpareto_gen._get_supportq  sY    JqMMq1uqd((v  HQ!VTVTV,,!tr8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zgenpareto_gen._pdfy  r  r8   c                 D    t          ||k    |dk    z  ||fd |           S )Nr   c                 @    t          j        |dz   || z             |z  S r  rk  rq   r  s     r6   r  z'genpareto_gen._logpdf.<locals>.<lambda>  s"    
1r61Q3(?(?'?!'C r8   r  r  s      r6   r   zgenpareto_gen._logpdf}  s4    16a1f-1vCC"  	r8   c                 2    t          j        | |            S rN   )rw   inv_boxcox1pr  s      r6   ru   zgenpareto_gen._cdf  s    QB''''r8   c                 0    t          j        | |           S rN   )rw   
inv_boxcoxr  s      r6   ry   zgenpareto_gen._sf  s    }aR!$$$r8   c                 D    t          ||k    |dk    z  ||fd |           S )Nr   c                 8    t          j        || z             |z  S rN   r  r  s     r6   r  z&genpareto_gen._logsf.<locals>.<lambda>  s    1~'9 r8   r  r  s      r6   r   zgenpareto_gen._logsf  s4    16a1f-1v99"  	r8   c                 2    t          j        | |            S rN   )rw   boxcox1pr  s      r6   r~   zgenpareto_gen._ppf  s    QB####r8   c                 0    t          j        ||            S rN   )rw   boxcoxr  s      r6   r   zgenpareto_gen._isf  s    	!aR    r8   r  c                 V   d|vrd }n"t          |dk     |fd t          j                  }d|vrd }n"t          |dk     |fd t          j                  }d|vrd }n"t          |dk     |fd	 t          j                  }d
|vrd }n"t          |dk     |fd t          j                  }||||fS )NrD  r   c                     dd| z
  z  S r^   r   xis    r6   r  z&genpareto_gen._stats.<locals>.<lambda>  s    aRj r8   r  r   c                 *    dd| z
  dz  z  dd| z  z
  z  S r1  r   r  s    r6   r  z&genpareto_gen._stats.<locals>.<lambda>  s    a1r6A+oQrT&B r8   r  gUUUUUU?c                 Z    dd| z   z  t          j        dd| z  z
            z  dd| z  z
  z  S )NrU   r   r  r  r  s    r6   r  z&genpareto_gen._stats.<locals>.<lambda>  s5    qAF|bga!B$h6G6G'G()AbD(2 r8   r  r  c                 `    ddd| z  z
  z  d| dz  z  | z   dz   z  dd| z  z
  z  dd| z  z
  z  dz
  S )Nr  r   rU   r$  r   r  s    r6   r  z&genpareto_gen._stats.<locals>.<lambda>  sQ    qA"H~2q529I'J()AbD(2562X(?AB(C r8   r   rP   ri   r  )rE   r  r  rD  r  r  r  s          r6   r   zgenpareto_gen._stats  s    gAA1q51$006# #A gAA1s7QDBB6# #A gAA1s7QD3 36# #A gAA1s7QDD D6# #A !Qzr8   c           	      l    d t          |dk    |ffdt          j        dz                       S )Nc                    d}t          j        d| dz             }t          |t          j        | |                    D ]\  }}||d|z  z  d||z  z
  z  z   }t          j        || z  dk     |d|z  | z  z  t           j                  S )Nr   r   r   r  r   rA  )rP   rR  ziprw   combrT  ri   )rb   r  r}  r  kicnks         r6   r[  z#genpareto_gen._munp.<locals>.__munp  s    C	!QU##Aq"'!Q--00 > >CC2"*,a"f==8AEAIsdQh1_'<bfEEEr8   r   c                      |           S rN   r   )r  _genpareto_gen__munprb   s    r6   r  z%genpareto_gen._munp.<locals>.<lambda>  s    FF1aLL r8   r   )r   rw   r  )rE   rb   r  r  s    ` @r6   r  zgenpareto_gen._munp  sR    	F 	F 	F !q&1$00000(1q5//+ + 	+r8   c                     d|z   S r  r   r  s     r6   r   zgenpareto_gen._entropy  s    Avr8   Nr  )r   r   r   r   rc   rk   r   rr   r   ru   ry   r   r~   r   r   r  r   r   r8   r6   r  r  G  s        " "F  K K K  * * *  
( ( (% % %  
$ $ $! ! !   :	+ 	+ 	+    r8   r  	genparetoc                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
genexpon_gena!  A generalized exponential continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `genexpon` is:

    .. math::

        f(x, a, b, c) = (a + b (1 - \exp(-c x)))
                        \exp(-a x - b x + \frac{b}{c}  (1-\exp(-c x)))

    for :math:`x \ge 0`, :math:`a, b, c > 0`.

    `genexpon` takes :math:`a`, :math:`b` and :math:`c` as shape parameters.

    %(after_notes)s

    References
    ----------
    H.K. Ryu, "An Extension of Marshall and Olkin's Bivariate Exponential
    Distribution", Journal of the American Statistical Association, 1993.

    N. Balakrishnan, Asit P. Basu (editors), *The Exponential Distribution:
    Theory, Methods and Applications*, Gordon and Breach, 1995.
    ISBN 10: 2884491929

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }t          dddt          j        fd          }|||gS )Nr   Fr   r
  r   r  rh   )rE   rj  rk  r&  s       r6   rk   zgenexpon_gen._shape_info  sY    UQK@@UQK@@UQK@@B|r8   c           	          ||t          j        | |z             z  z   t          j        | |z
  |z  |t          j        | |z             z  |z  z             z  S rN   rw   r  rP   r   rE   rq   r   r   r  s        r6   rr   zgenexpon_gen._pdf  sl     A!A''!Aq01BHaRTNN?0CA0E1F *G *G G 	Gr8   c                     t          j        ||t          j        | |z             z  z             | |z
  |z  z   |t          j        | |z             z  |z  z   S rN   rP   r   rw   r  r  s        r6   r   zgenexpon_gen._logpdf  sZ    vaBHaRTNN?++,,1ax7BHaRTNN?8KA8MMMr8   c                 z    t          j        | |z
  |z  |t          j        | |z             z  |z  z              S rN   r~  r  s        r6   ru   zgenexpon_gen._cdf  s>    1"Q$A!A$7$99::::r8   c                     ||z   }||t          j        |           z  z
  |z  }|t          j        | |z  t          j        |           z            j        z   |z  S rN   )rP   r  rw   lambertwr   realrE   r  r   r   r  r  r  s          r6   r~   zgenexpon_gen._ppf  sZ    E28QB<<"BK1rvqbzz 12277::r8   c                 x    t          j        | |z
  |z  |t          j        | |z             z  |z  z             S rN   r  r  s        r6   ry   zgenexpon_gen._sf  s;    vr!tQhRXqbd^^O!4Q!66777r8   c                     ||z   }||t          j        |          z  z
  |z  }|t          j        | |z  t          j        |           z            j        z   |z  S rN   )rP   r   rw   r  r   r  r  s          r6   r   zgenexpon_gen._isf  sW    E26!99_aBK1rvqbzz 12277::r8   Nr  r   r8   r6   r  r    s         >  G G GN N N; ; ;; ; ;
8 8 8; ; ; ; ;r8   r  genexponc                   v     e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Z fdZd Zd Z xZS )genextreme_genaB  A generalized extreme value continuous random variable.

    %(before_notes)s

    See Also
    --------
    gumbel_r

    Notes
    -----
    For :math:`c=0`, `genextreme` is equal to `gumbel_r` with
    probability density function

    .. math::

        f(x) = \exp(-\exp(-x)) \exp(-x),

    where :math:`-\infty < x < \infty`.

    For :math:`c \ne 0`, the probability density function for `genextreme` is:

    .. math::

        f(x, c) = \exp(-(1-c x)^{1/c}) (1-c x)^{1/c-1},

    where :math:`-\infty < x \le 1/c` if :math:`c > 0` and
    :math:`1/c \le x < \infty` if :math:`c < 0`.

    Note that several sources and software packages use the opposite
    convention for the sign of the shape parameter :math:`c`.

    `genextreme` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                 *    t          j        |          S rN   r  r  s     r6   rc   zgenextreme_gen._argcheck,  r  r8   c                 V    t          ddt          j         t          j        fd          gS r  rh   rj   s    r6   rk   zgenextreme_gen._shape_info/  r  r8   c                 
   t          j        |dk    dt          j        |t                    z  t           j                  }t          j        |dk     dt          j        |t                     z  t           j                   }||fS Nr   r   )rP   rT  maximumr"   ri   minimum)rE   r  _b_as       r6   r   zgenextreme_gen._get_support2  sc    Xa!eS2:a#7#77@@Xa!eS2:a%#8#8826'BB2vr8   c                 D    t          ||k    |dk    z  ||fd |           S )Nr   c                 8    t          j        | | z            |z  S rN   r  r  s     r6   r  z+genextreme_gen._loglogcdf.<locals>.<lambda>:  s    rx1~~a'7 r8   r  r  s      r6   
_loglogcdfzgenextreme_gen._loglogcdf7  s3    16a1f-1v77!= = 	=r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zgenextreme_gen._pdf<  s"     vdll1a(()))r8   c                    t          ||k    |dk    z  ||fd d          }t          j        |           }|                     ||          }t	          j        |          }t	          j        ||dk    |t          j         k    z  d           t          |dk    |t          j         k    z   |||fd t          j                   }t	          j        ||dk    |dk    z  d           |S )Nr   c                     || z  S rN   r   r  s     r6   r  z(genextreme_gen._logpdf.<locals>.<lambda>C  s
    !A# r8   r   r   c                     |  |z   |z
  S rN   r   )pex2lpex2lex2s      r6   r  z(genextreme_gen._logpdf.<locals>.<lambda>K  s    teemd6J r8   r  )r   rw   r  r  rP   r   putmaskri   )rE   rq   r  cxlogex2logpex2r  logpdfs           r6   r   zgenextreme_gen._logpdfB  s    aAF+aV5E5EsKK2#//!Q''vg

7Q!VbfW5s;;;rQw2"&=9:!7F3JJ')vg/ / / 	
6AFqAv.444r8   c                 T    t          j        |                     ||                     S rN   )rP   r   r  r  s      r6   r   zgenextreme_gen._logcdfP  s#    tq!,,----r8   c                 R    t          j        |                     ||                    S rN   rT  r  s      r6   ru   zgenextreme_gen._cdfS  r  r8   c                 T    t          j        |                     ||                     S rN   r  r  s      r6   ry   zgenextreme_gen._sfV  r  r8   c                     t          j        t          j        |                      }t          ||k    |dk    z  ||fd |          S )Nr   c                 :    t          j        | | z             |z  S rN   r~  r  s     r6   r  z%genextreme_gen._ppf.<locals>.<lambda>\      !a(8(8'81'< r8   )rP   r   r   rE   r}   r  rq   s       r6   r~   zgenextreme_gen._ppfY  sP    VRVAYYJ16a1f-1v<<aA A 	Ar8   c                     t          j        t          j        |                       }t	          ||k    |dk    z  ||fd |          S )Nr   c                 :    t          j        | | z             |z  S rN   r~  r  s     r6   r  z%genextreme_gen._isf.<locals>.<lambda>a  r  r8   )rP   r   rw   r  r   r  s       r6   r   zgenextreme_gen._isf^  sR    VRXqb\\M"""16a1f-1v<<aA A 	Ar8   c                    fd} |d          } |d          } |d          } |d          }t          j        t                    dk     t           j        z  dz  dz  ||dz  z
            }d	 }t	          t                    dk    f|t           j        dz  dz  
          }	d}
d }t	          t                    |
k    f|t
           
          }t          j        dk     t           j        |           }t          j        dk     t           j        |dz  |	z            }d }dt          j        d          z  t          z  t           j        dz  z  }||||f}t	          t                    |
dz  k    f|z   ||
          }d }|||||f}t	          t                    |
dz  k    f|z   |d
          }||||fS )Nc                 8    t          j        | z  dz             S r^   ro  )rb   r  s    r6   gz genextreme_gen._stats.<locals>.gd  s    8AEAI&&&r8   r   rU   r  r$  gHz>r   r  c                     t          j        t          j        d| z  dz             dt          j        | dz             z  z
            | dz  z  S )Nr   r   rU   rw   r  r  r  s    r6   gam2k_fz&genextreme_gen._stats.<locals>.gam2k_fk  sE    8BJs1uSy11!BJq3w4G4G2GGHHCOOr8   r  r  +=c                 Z    t          j        t          j        | dz                       | z  S r^   r  r  s    r6   gamk_fz%genextreme_gen._stats.<locals>.gamk_fo  s%    8BJq1u--..q00r8   rA  r)  c                 R    d }t          | dk    | f|z   |t          j                  S )Nc                 V    t          j        |           | |d|z  z   |z  z   z  |dz  z  S NrU   r  rO   )r  rF  rG  g3g2mg12s        r6   
sk1_eval_fz;genextreme_gen._stats.<locals>.sk1_eval.<locals>.sk1_eval_f{  s2    wqzzB3"qx-);#;<VS[HHr8   r  r  rr  )r  rG   r  s      r6   sk1_evalz'genextreme_gen._stats.<locals>.sk1_evalz  s7    I I Ia5j1$t)zRVTTTTr8   r  r  g(\?c                 J    d }t          | dk    ||t          j                  S )Nc                 B    |d|z  d||z   z  | z  z   | z  z   |dz  z  dz
  S )Nr  r  rU   r   )rF  rG  r  g4r  s        r6   
ku1_eval_fz;genextreme_gen._stats.<locals>.ku1_eval.<locals>.ku1_eval_f  s6    beafob&88"<<faiG!KKr8   g      пr  rr  )r  rG   r  s      r6   ku1_evalz'genextreme_gen._stats.<locals>.ku1_eval  s1    L L La5j$
bfMMMMr8   gq=
ףp?333333@)	rP   rT  r  r   r   r$   r  r   r%   )rE   r  r  rF  rG  r  r
  r  r  gam2kepsr   gamkrD  r  r  sk_fillrG   r  r  r  s    `                   r6   r   zgenextreme_gen._statsc  s   	' 	' 	' 	' 	'QqTTQqTTQqTTQqTT#a&&4-!BE'C);RCZHH	P 	P 	P3q66T>A47beSjQTnUUU	1 	1 	1#a&&C-!F7KKK HQXrvu-- HQXrvr3wu}55	U 	U 	U
 RWQZZ-&ruax/BF#Ad*QDIWUUU	N 	N 	N
 BB'Ad*QDIXVVV!R|r8   c                     t          |t                    r|                                }t          |          }|dk     rd}nd}t	                                          ||f          S )Nr   r   r)  rN  r?   r*   r  r   rA   r  )rE   rF   r  r   r  s       r6   r  zgenextreme_gen._fitstart  sc    dL)) 	$>>##D$KKq55AAAww  QD 111r8   c                 &   t          j        d|dz             }d||z  z  t          j        t          j        ||          d|z  z  t          j        ||z  dz             z  d          z  }t          j        ||z  dk    |t           j                  S )Nr   r   r   r  r   )rP   rR  r  rw   r  r  rT  ri   )rE   rb   r  r  valss        r6   r  zgenextreme_gen._munp  s    Ia11a4x"&GAqMMR!G#bhqsQw&7&77    x!b$///r8   c                 "    t           d|z
  z  dz   S r^   r  r  s     r6   r   zgenextreme_gen._entropy  s    q1u~!!r8   )r   r   r   r   rc   rk   r   r  rr   r   r   ru   ry   r~   r   r   r  r  r   r  r  s   @r6   r  r    s       % %L  K K K  
= = =
* * *  . . .* * *- - -A A A
A A A
) ) )V	2 	2 	2 	2 	20 0 0" " " " " " "r8   r  
genextremec                 Z    d} fd} dk    r7t          j                   dz   } dk     rt          j        ||d          }|S n* dk    rt          j         d	z            d
z   }n	d  |z
  z  }t          j        ||dd          \  }}}}|dk    rt          d           |d         S )af  Inverse of the digamma function (real positive arguments only).

    This function is used in the `fit` method of `gamma_gen`.
    The function uses either optimize.fsolve or optimize.newton
    to solve `sc.digamma(x) - y = 0`.  There is probably room for
    improvement, but currently it works over a wide range of y:

    >>> import numpy as np
    >>> rng = np.random.default_rng()
    >>> y = 64*rng.standard_normal(1000000)
    >>> y.min(), y.max()
    (-311.43592651416662, 351.77388222276869)
    >>> x = [_digammainv(t) for t in y]
    >>> np.abs(sc.digamma(x) - y).max()
    1.1368683772161603e-13

    gox?c                 2    t          j        |           z
  S rN   )rw   r  r  s    r6   r_  z_digammainv.<locals>.func  s    z!}}q  r8   g      r   r  绽|=)tolr  g-@g뭁,?r   dy=T)xtolr  r   z _digammainv: fsolve failed, y = r   )rP   r   r   newtonr  RuntimeError)r  _emr_  x0valuer  r  rX  s   `       r6   _digammainvr#    s    $ &C! ! ! ! ! 	6zzVAYY_r66 OD"%888EL  
RVAeG__w&QBH%_T2E9=? ? ?E4d
axxCaCCDDD8Or8   c                        e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Z fdZ eed           fd            Z xZS )	gamma_gena  A gamma continuous random variable.

    %(before_notes)s

    See Also
    --------
    erlang, expon

    Notes
    -----
    The probability density function for `gamma` is:

    .. math::

        f(x, a) = \frac{x^{a-1} e^{-x}}{\Gamma(a)}

    for :math:`x \ge 0`, :math:`a > 0`. Here :math:`\Gamma(a)` refers to the
    gamma function.

    `gamma` takes ``a`` as a shape parameter for :math:`a`.

    When :math:`a` is an integer, `gamma` reduces to the Erlang
    distribution, and when :math:`a=1` to the exponential distribution.

    Gamma distributions are sometimes parameterized with two variables,
    with a probability density function of:

    .. math::

        f(x, \alpha, \beta) =
        \frac{\beta^\alpha x^{\alpha - 1} e^{-\beta x }}{\Gamma(\alpha)}

    Note that this parameterization is equivalent to the above, with
    ``scale = 1 / beta``.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r	  rh   rj   s    r6   rk   zgamma_gen._shape_info  r  r8   Nc                 .    |                     ||          S rN   standard_gamma)rE   r   r   r   s       r6   r   zgamma_gen._rvs  s    **1d333r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zgamma_gen._pdf  r  r8   c                 b    t          j        |dz
  |          |z
  t          j        |          z
  S r  )rw   ry  r  r  s      r6   r   zgamma_gen._logpdf  s*    x#q!!A%
155r8   c                 ,    t          j        ||          S rN   r  r  s      r6   ru   zgamma_gen._cdf  r   r8   c                 ,    t          j        ||          S rN   r  r  s      r6   ry   zgamma_gen._sf  s    |Aq!!!r8   c                 ,    t          j        ||          S rN   r  r  s      r6   r~   zgamma_gen._ppf  s    ~a###r8   c                 ,    t          j        ||          S rN   rw   r  r  s      r6   r   zgamma_gen._isf  s    q!$$$r8   c                 >    ||dt          j        |          z  d|z  fS )Nr   r  r  r  s     r6   r   zgamma_gen._stats  s!    !S^SU**r8   c                 ,    t          j        ||          S rN   rw   r  rE   rb   r   s      r6   r  zgamma_gen._munp  s    wq!}}r8   c                 >    d }d }t          |dk     |f||          S )Nc                 f    t          j        |           d| z
  z  | z   t          j        |           z   S r^   rw   r\  r  r   s    r6   r  z+gamma_gen._entropy.<locals>.regular_formula#  s+    6!99!$q(2:a==88r8   c                     ddt          j        dt           j        z            z   t          j        |           z   z  dd| z  z  z
  | dz  dz  z
  | dz  d	z  z
  | d
z  dz  z   S )Nr   r   rU   r   r  r  r  r  r  r  r  r   r8  s    r6   r  z.gamma_gen._entropy.<locals>.asymptotic_formula&  so    
 2qw/"&));<q!a%yH#vrk"%&VRK034c63,? @r8      r  r  )rE   r   r  r  s       r6   r   zgamma_gen._entropy!  sK    	9 	9 	9	@ 	@ 	@ !c'A5//1 1 1 	1r8   c                     t          |t                    r|                                }t          |          }dd|dz  z   z  }t	                                          ||f          S )Nr$  :0yE>rU   rN  r  )rE   rF   r  r   r  s       r6   r  zgamma_gen._fitstart1  sb     dL)) 	$>>##D4[[Aww  QD 111r8   a<          When the location is fixed by using the argument `floc`
        and `method='MLE'`, this
        function uses explicit formulas or solves a simpler numerical
        problem than the full ML optimization problem.  So in that case,
        the `optimizer`, `loc` and `scale` arguments are ignored.
        

r   c                 N   |                     dd           }|                     dd          }t          |t                    s|5|                                dk    r t	                      j        |g|R i |S |                    dd            t          |g d          }|                    dd           }t          |           |||t          d          t          j        |          }t          j        |                                          st          d          |                                dk    rt          j        |          }t          j        |          }	t          j        ||z
  d	z            }
|||}}}||
||
d
|	z  z  }||t          j        |	|z            }|
||	||z
  z  }|
||	|d
z  z  }|||z
  |z  }||||z  z
  }|||z
  |z  }|||fS t          j        ||k              rt%          d|t          j                  |dk    r||z
  }|                                }|||}nt          j        |          t          j        |                                          z
  d	z
  t          j        d	z
  d
z  dz  z             z   dz  z  }|dz  }|dz  }t+          j        fd||d          }||z  }nLt          j        |                                          t          j        |          z
  }t/          |          }|}|||fS )Nr   r1   r;   r<   r  r   r   r   r  rU   r  r  r   r  r  g333333?gffffff?c                 \    t          j        |           t          j        |           z
  z
  S rN   )rP   r   rw   r  )r   r  s    r6   r  zgamma_gen.fit.<locals>.<lambda>  s!    bfQii"*Q--.G!.K r8   )disp)r=   r?   r*   r>   rA   rC   r3   r   r7   r   rP   r   r   r   r   r  r   r  rL  ri   r   r   brentqr#  )rE   rF   rG   r5   r   r1   r  r   m1m2m3r   r.   r/   r  aestxar  r  r  r  s                      @r6   rC   zgamma_gen.fit=  sr    xx%%(E**t\** 	44!7!7 577;t3d333d333 	!$(=(=(=>>(D))$T***>d.63E  ) * * * z${4  $$&& 	ECDDD <<>>T!!BB$))**BfEsAyS[U]a"f{u}QyU]b3hyS[%1*%y#X&{1u9n}cQc5= 
 6$$, 	Bwd"&AAAA199 $;Dyy{{ >~ F4LL26$<<#4#4#6#66!bgqsQhAo6662a4@5\5\O$K$K$K$K$&4 4 4
 1HEE
 t!!##bfVnn4AAAE$~r8   r  )r   r   r   r   rk   r   rr   r   ru   ry   r~   r   r   r  r   r  r	   r   rC   r  r  s   @r6   r%  r%    s:       ' 'PE E E4 4 4 4* * *6 6 6! ! !" " "$ $ $% % %+ + +  1 1 1 
2 
2 
2 
2 
2 } 5   e e e e e e e e er8   r%  r  c                   ^     e Zd ZdZd Zd Z fdZ eed           fd            Z	 xZ
S )
erlang_gena  An Erlang continuous random variable.

    %(before_notes)s

    See Also
    --------
    gamma

    Notes
    -----
    The Erlang distribution is a special case of the Gamma distribution, with
    the shape parameter `a` an integer.  Note that this restriction is not
    enforced by `erlang`. It will, however, generate a warning the first time
    a non-integer value is used for the shape parameter.

    Refer to `gamma` for examples.

    c                     t          j        t          j        |          |k              }|s"d|d}t          j        |t
          d           |dk    S )NzRThe shape parameter of the erlang distribution has been given a non-integer value r2   r  
stacklevelr   )rP   r   floorwarningswarnRuntimeWarning)rE   r   allintmessages       r6   rc   zerlang_gen._argcheck  sd    q()) 	AD=>D D DGM'>a@@@@1ur8   c                 @    t          dddt          j        fd          gS )Nr   Tr   rg   rh   rj   s    r6   rk   zerlang_gen._shape_info  rl   r8   c                     t          |t                    r|                                }t          ddt	          |          dz  z   z            }t          t          |                               ||f          S )NrO  r<  rU   rN  )r?   r*   r  r  r   rA   r%  r  )rE   rF   r   r  s      r6   r  zerlang_gen._fitstart  sl     dL)) 	$>>##DteDkk1n,-..Y%%//A4/@@@r8   a          The Erlang distribution is generally defined to have integer values
        for the shape parameter.  This is not enforced by the `erlang` class.
        When fitting the distribution, it will generally return a non-integer
        value for the shape parameter.  By using the keyword argument
        `f0=<integer>`, the fit method can be constrained to fit the data to
        a specific integer shape parameter.r   c                 >     t                      j        |g|R i |S rN   )rA   rC   rE   rF   rG   r5   r  s       r6   rC   zerlang_gen.fit  s+     uww{4/$///$///r8   )r   r   r   r   rc   rk   r  r	   r   rC   r  r  s   @r6   rG  rG    s         &  C C CA A A A A } 5/ 0 0 00 0 0 00 00 0 0 0 0r8   rG  erlangc                   V    e Zd ZdZd Zd Zd Zd Zd ZddZ	d	 Z
d
 Zd Zd Zd ZdS )gengamma_gena  A generalized gamma continuous random variable.

    %(before_notes)s

    See Also
    --------
    gamma, invgamma, weibull_min

    Notes
    -----
    The probability density function for `gengamma` is ([1]_):

    .. math::

        f(x, a, c) = \frac{|c| x^{c a-1} \exp(-x^c)}{\Gamma(a)}

    for :math:`x \ge 0`, :math:`a > 0`, and :math:`c \ne 0`.
    :math:`\Gamma` is the gamma function (`scipy.special.gamma`).

    `gengamma` takes :math:`a` and :math:`c` as shape parameters.

    %(after_notes)s

    References
    ----------
    .. [1] E.W. Stacy, "A Generalization of the Gamma Distribution",
       Annals of Mathematical Statistics, Vol 33(3), pp. 1187--1192.

    %(example)s

    c                     |dk    |dk    z  S r7  r   )rE   r   r  s      r6   rc   zgengamma_gen._argcheck	      A!q&!!r8   c                     t          dddt          j        fd          }t          ddt          j         t          j        fd          }||gS r  rh   r  s      r6   rk   zgengamma_gen._shape_info  B    UQK@@UbfWbf$5~FFBxr8   c                 T    t          j        |                     |||                    S rN   r  r  s       r6   rr   zgengamma_gen._pdf  "    vdll1a++,,,r8   c                 `    t          |dk    |dk    z  ||ffdt          j                   S )Nr   c                     t          j        t          |                    t          j        |z  dz
  |           z   | |z  z
  t          j                  z
  S r^   )rP   r   r  rw   ry  r  )rq   r  r   s     r6   r  z&gengamma_gen._logpdf.<locals>.<lambda>  sJ    s1vv!A#'19M9M(M*+Q$)/13A)? r8   r  r  r  s     ` r6   r   zgengamma_gen._logpdf  sN    16a!e,q!f@ @ @ @%'VG- - - 	-r8   c                     ||z  }t          j        ||          }t          j        ||          }t          j        |dk    ||          S r7  rw   r  r  rP   rT  rE   rq   r   r  xcval1val2s          r6   ru   zgengamma_gen._cdf  E    T{1b!!|Ar""xAtT***r8   Nc                 @    |                     ||          }|d|z  z  S )Nr  r   r(  )rE   r   r  r   r   r  s         r6   r   zgengamma_gen._rvs   s(    '''552a4yr8   c                     ||z  }t          j        ||          }t          j        ||          }t          j        |dk    ||          S r7  ra  rb  s          r6   ry   zgengamma_gen._sf$  rf  r8   c                     t          j        ||          }t          j        ||          }t          j        |dk    ||          d|z  z  S r  rw   r  r  rP   rT  rE   r}   r   r  rd  re  s         r6   r~   zgengamma_gen._ppf*  E    ~a##q!$$xAtT**SU33r8   c                     t          j        ||          }t          j        ||          }t          j        |dk    ||          d|z  z  S r  rj  rk  s         r6   r   zgengamma_gen._isf/  rl  r8   c                 8    t          j        ||dz  |z            S r  r3  )rE   rb   r   r  s       r6   r  zgengamma_gen._munp4  s    wq!C%'"""r8   c                 D    d }d }t          |dk    ||f||          }|S )Nc                     t          j        |           }| d|z
  z  ||z  z   }t          j        |           t          j        t          |                    z
  }||z   }|S r^   )rw   r\  r  rP   r   r  )r   r  r}  ABr  s         r6   r  z&gengamma_gen._entropy.<locals>.regular9  sS    &))CQWa'A
1s1vv.AAAHr8   c                 <   t                                           t          j        |           dz  z
  t          j        t          j        |                    z
  | dz  dz  z   | dz  dz  z
  t          j        |           | dz  dz  z
  | dz  dz  z
  | dz  d	z  z   |z  z   S )
NrU   rA  r  r  r  r  r  r  r  )r  r   rP   r   r  )r   r  s     r6   
asymptoticz)gengamma_gen._entropy.<locals>.asymptotic@  s    MMOObfQiik1fRVAYY''(+,c61*5893{CvayyAsFA:-C;q#vslJAMN Or8         i@r  r  )rE   r   r  r  rt  r  s         r6   r   zgengamma_gen._entropy8  sH    	 	 		O 	O 	O qCx!Q:'BBBr8   r  )r   r   r   r   rc   rk   rr   r   ru   r   ry   r~   r   r  r   r   r8   r6   rW  rW    s         >" " "  
- - -- - -+ + +   + + +4 4 4
4 4 4
# # #    r8   rW  gengammac                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	genhalflogistic_gena  A generalized half-logistic continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `genhalflogistic` is:

    .. math::

        f(x, c) = \frac{2 (1 - c x)^{1/(c-1)}}{[1 + (1 - c x)^{1/c}]^2}

    for :math:`0 \le x \le 1/c`, and :math:`c > 0`.

    `genhalflogistic` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zgenhalflogistic_gen._shape_infoc  r  r8   c                     | j         d|z  fS r  r8  r  s     r6   r   z genhalflogistic_gen._get_supportf  s    vs1u}r8   c                 v    d|z  }t          j        d||z  z
            }||dz
  z  }||z  }d|z  d|z   dz  z  S r  rP   r   )rE   rq   r  limitr  tmp0tmp2s          r6   rr   zgenhalflogistic_gen._pdfi  sQ     Aj1Q3U1W~Cxv4!##r8   c                 `    d|z  }t          j        d||z  z
            }||z  }d|z
  d|z   z  S r.  r|  )rE   rq   r  r}  r  r  s         r6   ru   zgenhalflogistic_gen._cdfr  s>    Aj1Q3U|DQtV$$r8   c                 0    d|z  dd|z
  d|z   z  |z  z
  z  S r.  r   r  s      r6   r~   zgenhalflogistic_gen._ppfx  s'    1ua#a%#a%1,,--r8   c                 B    dd|z  dz   t          j        d          z  z
  S r  r2  r  s     r6   r   zgenhalflogistic_gen._entropy{  s"    AaCE26!99$$$r8   N)
r   r   r   r   rk   r   rr   ru   r~   r   r   r8   r6   rx  rx  M  s{         *E E E  $ $ $% % %. . .% % % % %r8   rx  genhalflogisticc                   |     e Zd ZdZd Zd Z fdZd Zd Zd e	d                         Z
d	 Zd
 ZddZd Z xZS )genhyperbolic_genu  A generalized hyperbolic continuous random variable.

    %(before_notes)s

    See Also
    --------
    t, norminvgauss, geninvgauss, laplace, cauchy

    Notes
    -----
    The probability density function for `genhyperbolic` is:

    .. math::

        f(x, p, a, b) =
            \frac{(a^2 - b^2)^{p/2}}
            {\sqrt{2\pi}a^{p-1/2}
            K_p\Big(\sqrt{a^2 - b^2}\Big)}
            e^{bx} \times \frac{K_{p - 1/2}
            (a \sqrt{1 + x^2})}
            {(\sqrt{1 + x^2})^{1/2 - p}}

    for :math:`x, p \in ( - \infty; \infty)`,
    :math:`|b| < a` if :math:`p \ge 0`,
    :math:`|b| \le a` if :math:`p < 0`.
    :math:`K_{p}(.)` denotes the modified Bessel function of the second
    kind and order :math:`p` (`scipy.special.kv`)

    `genhyperbolic` takes ``p`` as a tail parameter,
    ``a`` as a shape parameter,
    ``b`` as a skewness parameter.

    %(after_notes)s

    The original parameterization of the Generalized Hyperbolic Distribution
    is found in [1]_ as follows

    .. math::

        f(x, \lambda, \alpha, \beta, \delta, \mu) =
           \frac{(\gamma/\delta)^\lambda}{\sqrt{2\pi}K_\lambda(\delta \gamma)}
           e^{\beta (x - \mu)} \times \frac{K_{\lambda - 1/2}
           (\alpha \sqrt{\delta^2 + (x - \mu)^2})}
           {(\sqrt{\delta^2 + (x - \mu)^2} / \alpha)^{1/2 - \lambda}}

    for :math:`x \in ( - \infty; \infty)`,
    :math:`\gamma := \sqrt{\alpha^2 - \beta^2}`,
    :math:`\lambda, \mu \in ( - \infty; \infty)`,
    :math:`\delta \ge 0, |\beta| < \alpha` if :math:`\lambda \ge 0`,
    :math:`\delta > 0, |\beta| \le \alpha` if :math:`\lambda < 0`.

    The location-scale-based parameterization implemented in
    SciPy is based on [2]_, where :math:`a = \alpha\delta`,
    :math:`b = \beta\delta`, :math:`p = \lambda`,
    :math:`scale=\delta` and :math:`loc=\mu`

    Moments are implemented based on [3]_ and [4]_.

    For the distributions that are a special case such as Student's t,
    it is not recommended to rely on the implementation of genhyperbolic.
    To avoid potential numerical problems and for performance reasons,
    the methods of the specific distributions should be used.

    References
    ----------
    .. [1] O. Barndorff-Nielsen, "Hyperbolic Distributions and Distributions
       on Hyperbolae", Scandinavian Journal of Statistics, Vol. 5(3),
       pp. 151-157, 1978. https://www.jstor.org/stable/4615705

    .. [2] Eberlein E., Prause K. (2002) The Generalized Hyperbolic Model:
        Financial Derivatives and Risk Measures. In: Geman H., Madan D.,
        Pliska S.R., Vorst T. (eds) Mathematical Finance - Bachelier
        Congress 2000. Springer Finance. Springer, Berlin, Heidelberg.
        :doi:`10.1007/978-3-662-12429-1_12`

    .. [3] Scott, David J, Würtz, Diethelm, Dong, Christine and Tran,
       Thanh Tam, (2009), Moments of the generalized hyperbolic
       distribution, MPRA Paper, University Library of Munich, Germany,
       https://EconPapers.repec.org/RePEc:pra:mprapa:19081.

    .. [4] E. Eberlein and E. A. von Hammerstein. Generalized hyperbolic
       and inverse Gaussian distributions: Limiting cases and approximation
       of processes. FDM Preprint 80, April 2003. University of Freiburg.
       https://freidok.uni-freiburg.de/fedora/objects/freidok:7974/datastreams/FILE1/content

    %(example)s

    c                     t          j        t          j        |          |k     |dk              t          j        t          j        |          |k    |dk               z  S r7  )rP   logical_andr  )rE   r  r   r   s       r6   rc   zgenhyperbolic_gen._argcheck  sJ    rvayy1}a1f55.aQ778 	9r8   c                     t          ddt          j         t          j        fd          }t          dddt          j        fd          }t          ddt          j         t          j        fd          }|||gS )Nr  Fr
  r   r   rg   r   rh   )rE   iprj  rk  s       r6   rk   zgenhyperbolic_gen._shape_info  sc    UbfWbf$5~FFUQK??UbfWbf$5~FFB|r8   c                 J    t                                          |d          S )N)r   r   r   rN  rX  rY  s     r6   r  zgenhyperbolic_gen._fitstart  s"     ww  K 888r8   c                 H    t           j        d             } |||||          S )Nc                 0    t          j        | |||          S rN   )r   genhyperbolic_logpdfrq   r  r   r   s       r6   _logpdf_singlez1genhyperbolic_gen._logpdf.<locals>._logpdf_single  s    .q!Q:::r8   rP   	vectorize)rE   rq   r  r   r   r  s         r6   r   zgenhyperbolic_gen._logpdf  s7     
	; 	; 
	; ~aAq)))r8   c                 H    t           j        d             } |||||          S )Nc                 0    t          j        | |||          S rN   )r   genhyperbolic_pdfr  s       r6   _pdf_singlez+genhyperbolic_gen._pdf.<locals>._pdf_single  s    +Aq!Q777r8   r  )rE   rq   r  r   r   r  s         r6   rr   zgenhyperbolic_gen._pdf  s7     
	8 	8 
	8 {1aA&&&r8   c                 D    t          j        | t           j        g          S )NotypesrP   r  float64)r_  s    r6   r  zgenhyperbolic_gen.<lambda>   s    ",tRZL999 r8   c                    t          j        |||gt                    j                            t          j                  }t          j        t          d|          }t          j	        ||z   ||z
  z            }||z  t          j        |dz   |          z  t          j        ||          z  }d}	d}
| |cxk     r|k     rCn n@t          j        || ||	|
          d         t          j        ||||	|
          d         z   }nt          j        || ||	|
          d         }t          j        |          rd}t          j        |t"          d           t%          d	t'          d
|                    S )z
        Integrate the pdf of the genhyberbolic distribution from x0 to x1.
        This is a private function used by _cdf() and _sf() only; either x0
        will be -inf or x1 will be inf.
        _genhyperbolic_pdfr   r  r   )epsrelepsabszdInfinite values encountered in scipy.special.kve. Values replaced by NaN to avoid incorrect results.r  rI  r   r   )rP   arrayrW  ctypesdata_asc_void_pr   from_cythonr   r   rw   kvr   quadisnanrL  rM  rN  maxr  )r!  rE  r  r   r   	user_datallcr  r   r  r  intgrlrY   s                r6   _integrate_pdfz genhyperbolic_gen._integrate_pdf   s    HaAY..5==foNN	*63G+46 6GQUQUO$$sRU1q5!__$ruQ{{2>>>>r>>>>>  nS"d,26C C CCDF!sD".4VE E EEFHHFF
 ^CR+1&B B BBCEF8F 	=HCM#~!<<<<3C(()))r8   c                 J    |                      t          j         ||||          S rN   r  rP   ri   rE   rq   r  r   r   s        r6   ru   zgenhyperbolic_gen._cdf"  s"    ""BF7Aq!Q777r8   c                 H    |                      |t          j        |||          S rN   r  r  s        r6   ry   zgenhyperbolic_gen._sf%  s     ""1bfaA666r8   Nc                 \   t          j        |d          t          j        |d          z
  }t          j        |d          }t          j        |d          }t                              |||||          }	t                              ||          }
||	z  t          j        |	          |
z  z   S )NrU   r   r)  )r  r   r/   r   r   r  )rP   float_powergeninvgaussr  r  r   )rE   r  r   r   r   r   r  r  r  gignormsts              r6   r   zgenhyperbolic_gen._rvs(  s    
 ^Aq!!BN1a$8$88^B$$^B&&oo%    t,??3w...r8   c                 v   t          j        |||          \  }}}t          j        |d          t          j        |d          z
  }t          j        |d          }t          j        dd          t          j        |d          z  }t          j        ddd          }|                    |j        d|j        z  z             }t          j        ||z   |          \  }}}	}
fd	|||	|
fD             \  }}}}||z  |z  }||z  t          j        |d          t          j        |d          z  |t          j        |d          z
  z  z   }t          j        |d
          t          j        |d
          z  |d
|z  |z  t          j        d          z  z
  dt          j        |d
          z  z   z  d
|z  t          j        |d          z  |t          j        |d          z
  z  z   }|t          j        |d          z  }t          j        |d          t          j        |d          z  |d|	z  |z  t          j        d          z  z
  d|z  t          j        |d          z  t          j        d          z  z   d
t          j        |d          z  z
  z  t          j        |d          t          j        |d
          z  d|z  d|z  |z  t          j        d          z  z
  dt          j        |d
          z  z   z  z   d
t          j        |d          z  |z  z   }|t          j        |d          z  d
z
  }||||fS )NrU   r   r   r  r   r$  rH  r  c              3   "   K   | ]	}|z  V  
d S rN   r   )r  r   b0s     r6   	<genexpr>z+genhyperbolic_gen._stats.<locals>.<genexpr>I  s'      ;;Q!b&;;;;;;r8   r  r  rB  r  r  r  )	rP   r  r  linspacerS  shaper0  rw   r  )rE   r  r   r   r  r  integersb1b2b3b4r1r2r3r4rD  r  m3er  m4er  r  s                        @r6   r   zgenhyperbolic_gen._stats=  sE    %aA..1a^Aq!!BN1a$8$88^B$$^Aq!!BN2s$;$;;;q!Q''##HNTAF]$BCCU1x<44BB;;;;2r2r*:;;;BBFRKGbnQ**R^B-B-BB".Q''') ) 	

 N1a  2>"a#8#88!b&2+r2 6 666A&&&'( EBN2q)))".Q''')) 	 ".G,,,N1a  2>"a#8#88!b&2+r3 7 777VbnR+++bnR.E.EEFA&&&'( N1a  2>"a#8#88Vb2glR^B%<%<<<A&&&'(	( r1%%%*+ 	 ".B'''!+!Qzr8   r  )r   r   r   r   rc   rk   r  r   rr   staticmethodr  ru   ry   r   r   r  r  s   @r6   r  r    s        W Wr9 9 9  9 9 9 9 9
* * *' ' ' :9* * \ :9*@8 8 87 7 7/ / / /*' ' ' ' ' ' 'r8   r  genhyperbolicc                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )gompertz_genaq  A Gompertz (or truncated Gumbel) continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `gompertz` is:

    .. math::

        f(x, c) = c \exp(x) \exp(-c (e^x-1))

    for :math:`x \ge 0`, :math:`c > 0`.

    `gompertz` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zgompertz_gen._shape_info  r  r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zgompertz_gen._pdf  r  r8   c                 `    t          j        |          |z   |t          j        |          z  z
  S rN   r  r  s      r6   r   zgompertz_gen._logpdf  s%    vayy1}q28A;;..r8   c                 X    t          j        | t          j        |          z             S rN   r~  r  s      r6   ru   zgompertz_gen._cdf  s$    !bhqkk)****r8   c                 \    t          j        d|z  t          j        |           z            S rD  r  r  s      r6   r~   zgompertz_gen._ppf  s%    xq28QB<</000r8   c                 V    t          j        | t          j        |          z            S rN   r  r  s      r6   ry   zgompertz_gen._sf  s!    vqb28A;;&'''r8   c                 V    t          j        t          j        |           |z            S rN   r  rE   r  r  s      r6   r   zgompertz_gen._isf  s     x
1%%%r8   c                 v    dt          j        |          z
  t          j                            |          |z  z
  S r  )rP   r   rw   _ufuncs_scaled_exp1r  s     r6   r   zgompertz_gen._entropy  s.    RVAYY!8!8!;!;A!===r8   Nr   r   r   r   rk   rr   r   ru   r~   ry   r   r   r   r8   r6   r  r  j  s         *E E E* * */ / /+ + +1 1 1( ( (& & &> > > > >r8   r  gompertzc                     t          j        |           } t          j        |          }|                                }t          j        ||z
            }t          j        | |          S )N)weights)rP   r   r  r   average)rq   
logweightsmaxlogwr  s       r6   _average_with_log_weightsr    sV    

1AJ''JnnGfZ')**G:a))))r8   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Ze ee          d                         ZdS )gumbel_r_gena  A right-skewed Gumbel continuous random variable.

    %(before_notes)s

    See Also
    --------
    gumbel_l, gompertz, genextreme

    Notes
    -----
    The probability density function for `gumbel_r` is:

    .. math::

        f(x) = \exp(-(x + e^{-x}))

    for real :math:`x`.

    The Gumbel distribution is sometimes referred to as a type I Fisher-Tippett
    distribution.  It is also related to the extreme value distribution,
    log-Weibull and Gompertz distributions.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zgumbel_r_gen._shape_info  r   r8   c                 P    t          j        |                     |                    S rN   r  r   s     r6   rr   zgumbel_r_gen._pdf      vdll1oo&&&r8   c                 4    | t          j        |           z
  S rN   rz  r   s     r6   r   zgumbel_r_gen._logpdf  s    rBFA2JJr8   c                 R    t          j        t          j        |                      S rN   rz  r   s     r6   ru   zgumbel_r_gen._cdf  s    vrvqbzzk"""r8   c                 .    t          j        |            S rN   rz  r   s     r6   r   zgumbel_r_gen._logcdf  s    r

{r8   c                 R    t          j        t          j        |                      S rN   r2  r   s     r6   r~   zgumbel_r_gen._ppf  s    q		z""""r8   c                 T    t          j        t          j        |                       S rN   r  r   s     r6   ry   zgumbel_r_gen._sf  s!    "&!**%%%%r8   c                 T    t          j        t          j        |                       S rN   rP   r   r  r
  s     r6   r   zgumbel_r_gen._isf  s!    !}%%%%r8   c                     t           t          j        t          j        z  dz  dt          j        d          z  t          j        dz  z  t          z  dfS )Nr  r  r  r  r  r$   rP   r   r   r%   rj   s    r6   r   zgumbel_r_gen._stats  s9    ruRU{3271::beQh(>(GOOr8   c                     t           dz   S r  r  rj   s    r6   r   zgumbel_r_gen._entropy  s    {r8   c                    t          | ||          \  }}fd}||} ||          n|	|fdnfd|                    dd          }|dz  |dz  }
}	fd} ||	|
          sB|	dk    s|
t          j        k     r,|	dz  }	|
dz  }
 ||	|
          s|	dk    |
t          j        k     ,t	          j        |	|
fd	d	
          }|j        }||n
 ||          |fS )Nc                     |  t          j         | z            t          j        t	                              z
  z  S rN   )rw   rJ  rP   r   r  )r/   rF   s    r6   get_loc_from_scalez,gumbel_r_gen.fit.<locals>.get_loc_from_scale  s5    6R\4%%-8826#d));L;LLMMr8   c                     z
  t          j        z
  | z            z  z   }t                    | z   z  }|                                |z
  S rN   )rP   r   r  r  )r/   term1term2rF   r.   s      r6   r_  zgumbel_r_gen.fit.<locals>.func  sP     4Z263:2F+G+GG$NEIIu5E 99;;..r8   c                 f     | z  }t          |          }                                |z
  | z
  S )N)r  )r  r   )r/   sdatawavgrF   s      r6   r_  zgumbel_r_gen.fit.<locals>.func  s8    !EEME4TeLLLD99;;-55r8   r/   r   rU   c                 |    t          j         |                     t          j         |                    k    S rN   rO   )rR   rS   r_  s     r6   rT   z0gumbel_r_gen.fit.<locals>.interval_contains_root  s7    V--V--. /r8   r   r  )rJ  rtolr  )rL  r=   rP   ri   r   r+   rM  )rE   rF   rG   r5   r   r   r  r/   brack_startrR   rS   rT   resr_  r.   s    `           @@r6   rC   zgumbel_r_gen.fit  s    9t9=tE EdF	N 	N 	N 	N 	N  E$$U++CC / / / / / / /6 6 6 6 6 ((7A..K(1_kAoFF
/ / / / / .-ff== 

frvoo!! .-ff== 

frvoo &tff5E,1? ? ?CHE*$$0B0B50I0ICEzr8   N)r   r   r   r   rk   rr   r   ru   r   r~   ry   r   r   r   rK   r   r   rC   r   r8   r6   r  r    s         6  ' ' '  # # #  # # #& & && & &P P P   M**@ @ +* _@ @ @r8   r  gumbel_rc                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Ze ee          d                         ZdS )gumbel_l_gena	  A left-skewed Gumbel continuous random variable.

    %(before_notes)s

    See Also
    --------
    gumbel_r, gompertz, genextreme

    Notes
    -----
    The probability density function for `gumbel_l` is:

    .. math::

        f(x) = \exp(x - e^x)

    for real :math:`x`.

    The Gumbel distribution is sometimes referred to as a type I Fisher-Tippett
    distribution.  It is also related to the extreme value distribution,
    log-Weibull and Gompertz distributions.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zgumbel_l_gen._shape_infoF  r   r8   c                 P    t          j        |                     |                    S rN   r  r   s     r6   rr   zgumbel_l_gen._pdfI  r  r8   c                 0    |t          j        |          z
  S rN   rz  r   s     r6   r   zgumbel_l_gen._logpdfM  r  r8   c                 R    t          j        t          j        |                      S rN   r  r   s     r6   ru   zgumbel_l_gen._cdfP  s    "&))$$$$r8   c                 R    t          j        t          j        |                      S rN   rP   r   rw   r  r   s     r6   r~   zgumbel_l_gen._ppfS  s    vrx||m$$$r8   c                 ,    t          j        |           S rN   rz  r   s     r6   r   zgumbel_l_gen._logsfV  r  r8   c                 P    t          j        t          j        |                     S rN   rz  r   s     r6   ry   zgumbel_l_gen._sfY      vrvayyj!!!r8   c                 P    t          j        t          j        |                     S rN   r2  r   s     r6   r   zgumbel_l_gen._isf\  r  r8   c                     t            t          j        t          j        z  dz  dt          j        d          z  t          j        dz  z  t          z  dfS )Nr  r  r  r  r  rj   s    r6   r   zgumbel_l_gen._stats_  s@    wbeC271::~beQh&/8 	8r8   c                     t           dz   S r  r  rj   s    r6   r   zgumbel_l_gen._entropyc  s    {r8   c                     |                     d          |d          |d<   t          j        t          j        |           g|R i |\  }}| |fS )Nr   )r=   r  rC   rP   r   )rE   rF   rG   r5   loc_rscale_rs         r6   rC   zgumbel_l_gen.fitf  sa     88F' L=DL",
4(8(8'8H4HHH4HHwvwr8   N)r   r   r   r   rk   rr   r   ru   r~   r   ry   r   r   r   rK   r   r   rC   r   r8   r6   r  r  )  s         8  ' ' '  % % %% % %  " " "" " "8 8 8   M**  +* _  r8   r  gumbel_lc                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Ze ee           fd                        Z xZS )halfcauchy_gena  A Half-Cauchy continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `halfcauchy` is:

    .. math::

        f(x) = \frac{2}{\pi (1 + x^2)}

    for :math:`x \ge 0`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zhalfcauchy_gen._shape_info  r   r8   c                 2    dt           j        z  d||z  z   z  S ra  r/  r   s     r6   rr   zhalfcauchy_gen._pdf  s    25y#ac'""r8   c                 t    t          j        dt           j        z            t          j        ||z            z
  S r?  rP   r   r   rw   r  r   s     r6   r   zhalfcauchy_gen._logpdf  s)    vc"%i  28AaC==00r8   c                 J    dt           j        z  t          j        |          z  S r?  r  r   s     r6   ru   zhalfcauchy_gen._cdf  s    25y1%%r8   c                 J    t          j        t           j        dz  |z            S r  rP   tanr   r   s     r6   r~   zhalfcauchy_gen._ppf  s    vbeAgai   r8   c                 L    dt           j        z  t          j        d|          z  S Nr   r   )rP   r   r  r   s     r6   ry   zhalfcauchy_gen._sf  s    25y2:a++++r8   c                 P    dt          j        t           j        |z  dz            z  S r  r  r
  s     r6   r   zhalfcauchy_gen._isf  s!    26"%'!)$$$$r8   c                 ^    t           j        t           j        t           j        t           j        fS rN   r  rj   s    r6   r   zhalfcauchy_gen._stats  r  r8   c                 D    t          j        dt           j        z            S r  r   rj   s    r6   r   zhalfcauchy_gen._entropy  r  r8   c                 @   |                     dd          r t                      j        |g|R i |S t          | |||          \  }}}t	          j        |          }|%||k     rt          d|t          j                  |}n|}d }||}	n |||          }	||	fS )Nr@  F
halfcauchyr  c                     || z
  }|j         t          j        |          fd}t          j        d          j        dz  }t          ||t          j        |          f          }|j        S )Nc                 N    | dz  z   }dt          j        |z            z  z
  S r  rP   r  )r/   denominatorrb   shifted_data_squareds     r6   fun_to_solvez<halfcauchy_gen.fit.<locals>.find_scale.<locals>.fun_to_solve  s2    #Qh)==26"6{"BCCCaGGr8   r   r   rJ  )r   rP   squarefinfotinyr+   r  rM  )r.   rF   shifted_datar#  smallr  rb   r"  s         @@r6   
find_scalez&halfcauchy_gen.fit.<locals>.find_scale  s    #:L	A#%9\#:#: H H H H H H HSMM&+ElUBF<<P<P4QRRRC8Or8   r3   rA   rC   rL  rP   r  rL  ri   )rE   rF   rG   r5   r   r   r  r.   r*  r/   r  s             r6   rC   zhalfcauchy_gen.fit  s     88J&& 	4577;t3d333d3338t9=tE EdF 6$<<$"<t26JJJJCC C	 	 	 EEJsD))EEzr8   )r   r   r   r   rk   rr   r   ru   r~   ry   r   r   r   rK   r   r   rC   r  r  s   @r6   r  r  z  s         &  # # #1 1 1& & &! ! !, , ,% % %. . .   M**% % % % +* _% % % % %r8   r  r  c                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Ze ee           fd                        Z xZS )halflogistic_gena  A half-logistic continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `halflogistic` is:

    .. math::

        f(x) = \frac{ 2 e^{-x} }{ (1+e^{-x})^2 }
             = \frac{1}{2} \text{sech}(x/2)^2

    for :math:`x \ge 0`.

    %(after_notes)s

    References
    ----------
    .. [1] Asgharzadeh et al (2011). "Comparisons of Methods of Estimation for the
           Half-Logistic Distribution". Selcuk J. Appl. Math. 93-108.

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zhalflogistic_gen._shape_info  r   r8   c                 P    t          j        |                     |                    S rN   r  r   s     r6   rr   zhalflogistic_gen._pdf  s     vdll1oo&&&r8   c                     t          j        d          |z
  dt          j        t          j        |                     z  z
  S r   )rP   r   rw   r  r   r   s     r6   r   zhalflogistic_gen._logpdf  s2    vayy1}rBHRVQBZZ$8$8888r8   c                 0    t          j        |dz            S r?  )rP   tanhr   s     r6   ru   zhalflogistic_gen._cdf  s    wqu~~r8   c                 0    dt          j        |          z  S r  rP   arctanhr   s     r6   r~   zhalflogistic_gen._ppf  s    Ar8   c                 2    dt          j        |           z  S r  rw   expitr   s     r6   ry   zhalflogistic_gen._sf  s    28QB<<r8   c                 6    t          |dk     |fd d           S )Nr   c                 2    t          j        d| z             S r#  rw   logitr   s    r6   r  z'halflogistic_gen._isf.<locals>.<lambda>  s    RXcAg%6%6$6 r8   c                 6    dt          j        d| z
            z  S r  r4  r   s    r6   r  z'halflogistic_gen._isf.<locals>.<lambda>  s    qAE):):': r8   r  r  r   s     r6   r   zhalflogistic_gen._isf  s/    !c'A566::< < < 	<r8   c                 t   |dk    rdS |dk    rdt          j        d          z  S |dk    rt           j        t           j        z  dz  S |dk    r
dt          z  S |dk    rdt           j        dz  z  d	z  S ddt	          d
d|z
            z
  z  t          j        |dz             z  t          j        |d          z  S )Nr   r   rU   rI  r  r  r$  r  r  r   )rP   r   r   r%   r  rw   r  r  ra   s     r6   r  zhalflogistic_gen._munp
  s    66166RVAYY;665;s?"66V8O66RUAX:$$!CQqSMM/"28AaC==0A>>r8   c                 0    dt          j        d          z
  S r  r2  rj   s    r6   r   zhalflogistic_gen._entropy  r3  r8   c                 >   |                     dd          r t                      j        |g|R i |S t          | |||          \  }}}d }t	          j        |          }|%||k     rt          d|t          j                  |}n|}||n |||          }	||	fS )Nr@  Fc                    | j         d         }t          j        | d          }t          j        d|dz             |dz   z  }d|z
  }d|z   }|d|z  |z  t          j        ||z            z  z
  }d|z  |z  }||z
  }dt          j        |dd          |dd          z            z  }	dt          j        |dd          |dd          dz  z            z  }
|	t          j        |	dz  d|z  |
z  z             z   d|z  z  }d}d}|                                }||k    rU|t          j	        | |z            z  }|d|z  |                                z  z
  }t          ||z
  |z            }|}||k    U|S )	Nr   r   r   r   rU   r.  r$  r<  )r  rP   sortrR  r   r  r   r   rw   r8  r  )rF   r.   n_observationssorted_datar  r}   pp1r  ro  rr  Cr/   r  relative_residualshifted_meansum_term	scale_news                    r6   r*  z(halflogistic_gen.fit.<locals>.find_scale#  s    "Z]N'$Q///K	!^a/00.12DEAAAa%Ca#sQw77E7S=D%+KBF59{1226777ABF48k!""oq&88999A"'!Q$^);a)?"?@@@.(*E D !&++--L $d**&;,u2D)E)EE(1^+;hllnn+LL	$'):E(A$B$B!!	 $d**
 Lr8   halflogisticr  r+  )rE   rF   rG   r5   r   r   r*  r  r.   r/   r  s             r6   rC   zhalflogistic_gen.fit  s     88J&& 	4577;t3d333d3338t9=tE EdF	 	 	D 6$<<$">RVLLLLCC C !,**T32G2GEzr8   )r   r   r   r   rk   rr   r   ru   r~   ry   r   r  r   rK   r   r   rC   r  r  s   @r6   r-  r-    s         2  ' ' '
9 9 9         < < <
? ? ?   M**6 6 6 6 +* _6 6 6 6 6r8   r-  rK  c                        e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Ze ee           fd                        Z xZS )halfnorm_genaF  A half-normal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `halfnorm` is:

    .. math::

        f(x) = \sqrt{2/\pi} \exp(-x^2 / 2)

    for :math:`x >= 0`.

    `halfnorm` is a special case of `chi` with ``df=1``.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zhalfnorm_gen._shape_infon  r   r8   Nc                 H    t          |                    |                    S r9  r"  r   s      r6   r   zhalfnorm_gen._rvsq  s!    <//T/::;;;r8   c                 |    t          j        dt           j        z            t          j        | |z  dz            z  S r?  rP   r   r   r   r   s     r6   rr   zhalfnorm_gen._pdft  s1    ws25y!!"&!Ac"2"222r8   c                 \    dt          j        dt           j        z            z  ||z  dz  z
  S Nr   r   r   r   s     r6   r   zhalfnorm_gen._logpdfx  s*    RVCI&&&1S00r8   c                 T    t          j        |t          j        d          z            S r  rw   r%  rP   r   r   s     r6   ru   zhalfnorm_gen._cdf{  s    va"'!**n%%%r8   c                 ,    t          d|z   dz            S r  r   r   s     r6   r~   zhalfnorm_gen._ppf~  s    !A#s###r8   c                 &    dt          |          z  S r  r   r   s     r6   ry   zhalfnorm_gen._sf  s    8A;;r8   c                 &    t          |dz            S r  r   r
  s     r6   r   zhalfnorm_gen._isf  s    1~~r8   c                    t          j        dt           j        z            ddt           j        z  z
  t          j        d          dt           j        z
  z  t           j        dz
  dz  z  dt           j        dz
  z  t           j        dz
  dz  z  fS )Nr   r   rU   r$  r  r.  r  rP   r   r   rj   s    r6   r   zhalfnorm_gen._stats  sm    BE	""#be)

AbeG$beAg^3257RU1WqL(* 	*r8   c                 P    dt          j        t           j        dz            z  dz   S rS  r   rj   s    r6   r   zhalfnorm_gen._entropy  s"    26"%)$$$S((r8   c                 V   |                     dd          r t                      j        |g|R i |S t          | |||          \  }}}t	          j        |          }|%||k     rt          d|t          j                  |}n|}||}nt          j	        |d|          dz  }||fS )Nr@  Fhalfnormr  rU   )ordercenterr   )
r3   rA   rC   rL  rP   r  rL  ri   r  moment)
rE   rF   rG   r5   r   r   r  r.   r/   r  s
            r6   rC   zhalfnorm_gen.fit  s     88J&& 	4577;t3d333d3338t9=tE EdF 6$<<$":THHHHCCCEELQs;;;S@EEzr8   r  )r   r   r   r   rk   r   rr   r   ru   r~   ry   r   r   r   rK   r   r   rC   r  r  s   @r6   rM  rM  X  s         *  < < < <3 3 31 1 1& & &$ $ $    * * *) ) ) M**    +* _    r8   rM  r]  c                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )hypsecant_gena  A hyperbolic secant continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `hypsecant` is:

    .. math::

        f(x) = \frac{1}{\pi} \text{sech}(x)

    for a real number :math:`x`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zhypsecant_gen._shape_info  r   r8   c                 J    dt           j        t          j        |          z  z  S r  )rP   r   coshr   s     r6   rr   zhypsecant_gen._pdf  s    BE"'!**$%%r8   c                 n    dt           j        z  t          j        t          j        |                    z  S r?  rP   r   r  r   r   s     r6   ru   zhypsecant_gen._cdf  s%    25y26!99----r8   c                 n    t          j        t          j        t           j        |z  dz                      S r?  rP   r   r  r   r   s     r6   r~   zhypsecant_gen._ppf  s&    vbfRU1WS[))***r8   c                 p    dt           j        z  t          j        t          j        |                     z  S r?  rg  r   s     r6   ry   zhypsecant_gen._sf  s'    25y261"::....r8   c                 p    t          j        t          j        t           j        |z  dz                       S r?  ri  r   s     r6   r   zhypsecant_gen._isf  s)    rvbeAgck**++++r8   c                 B    dt           j        t           j        z  dz  ddfS )Nr   r$  rU   r/  rj   s    r6   r   zhypsecant_gen._stats  s    "%+a-A%%r8   c                 D    t          j        dt           j        z            S r  r   rj   s    r6   r   zhypsecant_gen._entropy  r  r8   N)r   r   r   r   rk   rr   ru   r~   ry   r   r   r   r   r8   r6   rb  rb    s         &  & & &. . .+ + +/ / /, , ,& & &    r8   rb  	hypsecantc                   *    e Zd ZdZd Zd Zd Zd ZdS )gausshyper_gena_  A Gauss hypergeometric continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `gausshyper` is:

    .. math::

        f(x, a, b, c, z) = C x^{a-1} (1-x)^{b-1} (1+zx)^{-c}

    for :math:`0 \le x \le 1`, :math:`a,b > 0`, :math:`c` a real number,
    :math:`z > -1`, and :math:`C = \frac{1}{B(a, b) F[2, 1](c, a; a+b; -z)}`.
    :math:`F[2, 1]` is the Gauss hypergeometric function
    `scipy.special.hyp2f1`.

    `gausshyper` takes :math:`a`, :math:`b`, :math:`c` and :math:`z` as shape
    parameters.

    %(after_notes)s

    References
    ----------
    .. [1] Armero, C., and M. J. Bayarri. "Prior Assessments for Prediction in
           Queues." *Journal of the Royal Statistical Society*. Series D (The
           Statistician) 43, no. 1 (1994): 139-53. doi:10.2307/2348939

    %(example)s

    c                 8    |dk    |dk    z  ||k    z  |dk    z  S )Nr   r  r   )rE   r   r   r  r/  s        r6   rc   zgausshyper_gen._argcheck   s'    A!a% AF+q2v66r8   c                    t          dddt          j        fd          }t          dddt          j        fd          }t          ddt          j         t          j        fd          }t          dddt          j        fd          }||||gS )	Nr   Fr   r
  r   r  r/  r  rh   )rE   rj  rk  r&  izs        r6   rk   zgausshyper_gen._shape_info  sz    UQK@@UQK@@UbfWbf$5~FFURL.AABBr8   c                     t          j        ||          t          j        ||||z   |           z  }d|z  ||dz
  z  z  d|z
  |dz
  z  z  d||z  z   |z  z  S r  rw   ro  hyp2f1)rE   rq   r   r   r  r/  normalization_constants          r6   rr   zgausshyper_gen._pdf  sn    !#A1aQ1K1K!K))ABK726QW:MM19q.! 	"r8   c                     t          j        ||z   |          t          j        ||          z  }t          j        |||z   ||z   |z   |           }t          j        ||||z   |           }||z  |z  S rN   ru  )	rE   rb   r   r   r  r/  r  rE  r  s	            r6   r  zgausshyper_gen._munp  sp    gac1oo1-i1Q3!Ar**i1acA2&&3w}r8   N)r   r   r   r   rc   rk   rr   r  r   r8   r6   rp  rp    s[         @7 7 7     " " "
    r8   rp  
gausshyperc                   X    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zdd
Zd ZdS )invgamma_gena_  An inverted gamma continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `invgamma` is:

    .. math::

        f(x, a) = \frac{x^{-a-1}}{\Gamma(a)} \exp(-\frac{1}{x})

    for :math:`x >= 0`, :math:`a > 0`. :math:`\Gamma` is the gamma function
    (`scipy.special.gamma`).

    `invgamma` takes ``a`` as a shape parameter for :math:`a`.

    `invgamma` is a special case of `gengamma` with ``c=-1``, and it is a
    different parameterization of the scaled inverse chi-squared distribution.
    Specifically, if the scaled inverse chi-squared distribution is
    parameterized with degrees of freedom :math:`\nu` and scaling parameter
    :math:`\tau^2`, then it can be modeled using `invgamma` with
    ``a=`` :math:`\nu/2` and ``scale=`` :math:`\nu \tau^2/2`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r	  rh   rj   s    r6   rk   zinvgamma_gen._shape_info:  r  r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zinvgamma_gen._pdf=  r  r8   c                 n    |dz    t          j        |          z  t          j        |          z
  d|z  z
  S r  rP   r   rw   r  r  s      r6   r   zinvgamma_gen._logpdfA  s1    1vq		!BJqMM1CE99r8   c                 2    t          j        |d|z            S r  r  r  s      r6   ru   zinvgamma_gen._cdfD  s    |AsQw'''r8   c                 2    dt          j        ||          z  S r  r0  r  s      r6   r~   zinvgamma_gen._ppfG  s    R_Q****r8   c                 2    t          j        |d|z            S r  r  r  s      r6   ry   zinvgamma_gen._sfJ  s    {1cAg&&&r8   c                 2    dt          j        ||          z  S r  r  r  s      r6   r   zinvgamma_gen._isfM  s    R^Aq))))r8   mvskc                 8   t          |dk    |fd t          j                  }t          |dk    |fd t          j                  }d\  }}d|v r"t          |dk    |fd t          j                  }d	|v r"t          |d
k    |fd t          j                  }||||fS )Nr   c                     d| dz
  z  S r  r   r   s    r6   r  z%invgamma_gen._stats.<locals>.<lambda>Q  s    rQV} r8   rU   c                 $    d| dz
  dz  z  | dz
  z  S )Nr   rU   r   r   r   s    r6   r  z%invgamma_gen._stats.<locals>.<lambda>R  s    rQVaK/?1r6/J r8   r  r  r  c                 B    dt          j        | dz
            z  | dz
  z  S )NrO  r   rI  r  r   s    r6   r  z%invgamma_gen._stats.<locals>.<lambda>Y  s     "rwq2v.!b&9 r8   r  r$  c                 0    dd| z  dz
  z  | dz
  z  | dz
  z  S )Nr  r  g      &@rI  rO  r   r   s    r6   r  z%invgamma_gen._stats.<locals>.<lambda>]  s%    "Q-R8AFC r8   r  )rE   r   r  rA  rB  rF  rG  s          r6   r   zinvgamma_gen._statsP  s    At%<%<bfEEAt%J%J    B'>>At9926C CB '>>AtCCRVM MB 2r2~r8   c                 B    d }d }t          |dk    |f||          }|S )Nc                 j    | | dz   t          j        |           z  z
  t          j        |           z   }|S r  r7  r   r  s     r6   r  z&invgamma_gen._entropy.<locals>.regulara  s/    QWq		))BJqMM9AHr8   c                     ddt          j        |           z  z
  t          j        d          z   t          j        t           j                  z   dz  d| dz  z  z   | dz  dz  z   | dz  d	z  z
  | d
z  dz  z
  }|S )Nr   r  rU   UUUUUU?rA  r  r  r  r  r  r  r   r  s     r6   rt  z)invgamma_gen._entropy.<locals>.asymptotice  s     aq		k/BF1II-ru=q@q#v: !3r	*,-sF2I6893s
CAHr8   ru  r  r  )rE   r   r  rt  r  s        r6   r   zinvgamma_gen._entropy`  sC    	 	 		 	 	 qCx!@@@r8   Nr  )r   r   r   r   r   r  r  rk   rr   r   ru   r~   ry   r   r   r   r   r8   r6   r{  r{    s         : "4ME E E* * *: : :( ( (+ + +' ' '* * *        r8   r{  invgammac                        e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 Z fdZ fdZd Z ee           fd            Zd Z xZS )invgauss_genaU  An inverse Gaussian continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `invgauss` is:

    .. math::

        f(x; \mu) = \frac{1}{\sqrt{2 \pi x^3}}
                    \exp\left(-\frac{(x-\mu)^2}{2 \mu^2 x}\right)

    for :math:`x \ge 0` and :math:`\mu > 0`.

    `invgauss` takes ``mu`` as a shape parameter for :math:`\mu`.

    %(after_notes)s

    A common shape-scale parameterization of the inverse Gaussian distribution
    has density

    .. math::

        f(x; \nu, \lambda) = \sqrt{\frac{\lambda}{2 \pi x^3}}
                    \exp\left( -\frac{\lambda(x-\nu)^2}{2 \nu^2 x}\right)

    Using ``nu`` for :math:`\nu` and ``lam`` for :math:`\lambda`, this
    parameterization is equivalent to the one above with ``mu = nu/lam``,
    ``loc = 0``, and ``scale = lam``.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``ppf`` and ``isf`` methods. [1]_

    References
    ----------
    .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                 @    t          dddt          j        fd          gS NrD  Fr   r
  rh   rj   s    r6   rk   zinvgauss_gen._shape_info  r  r8   Nc                 2    |                     |d|          S Nr   r  waldrE   rD  r   r   s       r6   r   zinvgauss_gen._rvs  s      St 444r8   c                     dt          j        dt           j        z  |dz  z            z  t          j        dd|z  z  ||z
  |z  dz  z            z  S )Nr   rU   rI  rA  rQ  rE   rq   rD  s      r6   rr   zinvgauss_gen._pdf  sO     271RU71c6>***26$!*qtRi!^2K+L+LLLr8   c                     dt          j        dt           j        z            z  dt          j        |          z  z
  ||z
  |z  dz  d|z  z  z
  S )Nr)  rU   r  r   r  s      r6   r   zinvgauss_gen._logpdf  sF    BF1RU7OO#c"&))m3"by1nac6JJJr8   c                     dt          j        |          z  }t          |||z  dz
  z            }d|z  t          | ||z  dz   z            z   }|t          j        t          j        ||z
                      z   S r1  )rP   r   r   r  r   rE   rq   rD  r  r   r   s         r6   r   zinvgauss_gen._logcdf  ss    "'!**nR1-..F\3$1r6Q,"788828BF1q5MM****r8   c                     dt          j        |          z  }t          |||z  dz
  z            }d|z  t          | ||z   z  |z            z   }|t          j        t          j        ||z
                       z   S r1  )rP   r   r   r   r  r   r  s         r6   r   zinvgauss_gen._logsf  su    "'!**nB!|,--F\3$!b&/B"677728RVAE]]N++++r8   c                 R    t          j        |                     ||                    S rN   r;  r  s      r6   ry   zinvgauss_gen._sf  s     vdkk!R(()))r8   c                 R    t          j        |                     ||                    S rN   rT  r  s      r6   ru   zinvgauss_gen._cdf       vdll1b))***r8   c                    t          j        ddd          5  t          j        ||          \  }}t          j        t	          j        ||d                    }|dk    }t	          j        d||         z
  ||         d          ||<   t          j        |          }t                      	                    ||         ||                   ||<   d d d            n# 1 swxY w Y   |S Nr9  )r;  rs  rA  r   r   )
rP   r<  r  r   rn   _invgauss_ppf_invgauss_isfr  rA   r~   )rE   rq   rD  ppfi_wti_nanr  s         r6   r~   zinvgauss_gen._ppf  s   [xJJJ 	; 	;'2..EAr*S.q"a8899Cs7D)!AdG)RXqAACIHSMMEah5	::CJ	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 
s   B4CC Cc                    t          j        ddd          5  t          j        ||          \  }}t          j        ||d          }|dk    }t          j        d||         z
  ||         d          ||<   t          j        |          }t                                          ||         ||                   ||<   d d d            n# 1 swxY w Y   |S r  )	rP   r<  r  rn   r  r  r  rA   r   )rE   rq   rD  isfr  r  r  s         r6   r   zinvgauss_gen._isf  s    [xJJJ 	; 	;'2..EAr#Ar1--Cs7D)!AdG)RXqAACIHSMMEah5	::CJ	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 
s   B"CCCc                 D    ||dz  dt          j        |          z  d|z  fS )NrI  r  r  r  )rE   rD  s     r6   r   zinvgauss_gen._stats  s%    2s7AbgbkkM2b500r8   c                 r   |                     dd          }t          |t                    s-t          | t                    s|                                dk    r t                      j        |g|R i |S t          | |||          \  }}}}	 || t                      j        |g|R i |S t          j	        ||z
  dk               rt          ddt          j                  ||z
  }t          j        |          }|-t          |          t          j        |dz  |dz  z
            z  }||z  }|||fS )Nr1   r;   r<   r   invgaussr  r  )r=   r?   r*   wald_genr>   rA   rC   rL  rP   r  rL  ri   r   r  r  )
rE   rF   rG   r5   r1   fshape_sr   r   fshape_nr  s
            r6   rC   zinvgauss_gen.fit  sV   (E**t\** 	4jx.H.H 	4<<>>T))577;t3d333d333'B4CG(O (O$hf	 <8/577;t3d333d333VD4K!O$$ 	)z"&AAAA$;Dwt}}H~TbfTRZ(b.-H&I&IJ&(Hv%%r8   c                     dt          j        dt           j        z            z   dt          j        |          z  z   }d|z  }t          j                            |          |z  }d|z  d|z  z
  S )zV
        Ref.: https://moser-isi.ethz.ch/docs/papers/smos-2012-10.pdf (eq. 9)
        r   rU   r  r   r  )rP   r   r   rw   r  r  )rE   rD  r   r  r   s        r6   r   zinvgauss_gen._entropy  sg     BE	"""Q^3 bDJ##A&&q(Qwq  r8   r  )r   r   r   r   r   r  r  rk   r   rr   r   r   r   ry   ru   r~   r   r   r   rC   r   r  r  s   @r6   r  r  s  s<       ( (R "4MF F F5 5 5 5M M M
K K K+ + +, , ,* * *+ + +        1 1 1 M**& & & & +*&B! ! ! ! ! ! !r8   r  r  c                   P    e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	Z
d
 Zd Zd ZdS )geninvgauss_genab  A Generalized Inverse Gaussian continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `geninvgauss` is:

    .. math::

        f(x, p, b) = x^{p-1} \exp(-b (x + 1/x) / 2) / (2 K_p(b))

    where ``x > 0``, `p` is a real number and ``b > 0``\([1]_).
    :math:`K_p` is the modified Bessel function of second kind of order `p`
    (`scipy.special.kv`).

    %(after_notes)s

    The inverse Gaussian distribution `stats.invgauss(mu)` is a special case of
    `geninvgauss` with ``p = -1/2``, ``b = 1 / mu`` and ``scale = mu``.

    Generating random variates is challenging for this distribution. The
    implementation is based on [2]_.

    References
    ----------
    .. [1] O. Barndorff-Nielsen, P. Blaesild, C. Halgreen, "First hitting time
       models for the generalized inverse gaussian distribution",
       Stochastic Processes and their Applications 7, pp. 49--54, 1978.

    .. [2] W. Hoermann and J. Leydold, "Generating generalized inverse Gaussian
       random variates", Statistics and Computing, 24(4), p. 547--557, 2014.

    %(example)s

    c                     ||k    |dk    z  S r7  r   rE   r  r   s      r6   rc   zgeninvgauss_gen._argcheck2  s    Q1q5!!r8   c                     t          ddt          j         t          j        fd          }t          dddt          j        fd          }||gS )Nr  Fr
  r   r   rh   )rE   r  rk  s      r6   rk   zgeninvgauss_gen._shape_info5  B    UbfWbf$5~FFUQK@@Bxr8   c                     d }t          j        |t           j        g          } ||||          }t          j        |                                          rd}t          j        |t          d           |S )Nc                 .    t          j        | ||          S rN   )r   geninvgauss_logpdfrq   r  r   s      r6   logpdf_singlez.geninvgauss_gen._logpdf.<locals>.logpdf_single>  s    ,Q1555r8   r  zjInfinite values encountered in scipy.special.kve(p, b). Values replaced by NaN to avoid incorrect results.r  rI  )rP   r  r  r  r  rL  rM  rN  )rE   rq   r  r   r  r/  rY   s          r6   r   zgeninvgauss_gen._logpdf:  s|    	6 	6 	6 ]BJ<HHHM!Q""8A;;?? 	=HCM#~!<<<<r8   c                 T    t          j        |                     |||                    S rN   r  rE   rq   r  r   s       r6   rr   zgeninvgauss_gen._pdfJ  r  r8   c                     |                      ||          \  }fd}t          j        |t          j        g          } ||||          S )Nc                     t          j        ||gt                    j                            t          j                  }t          j        t          d|          }t          j
        ||           d         S )N_geninvgauss_pdfr   )rP   r  rW  r  r  r  r   r  r   r   r  )rq   r  r   r  r  r  s        r6   _cdf_singlez)geninvgauss_gen._cdf.<locals>._cdf_singleQ  s`    !Q//6>>vOOI".v7I/8: :C >#r1--a00r8   r  )r   rP   r  r  )rE   rq   r  r   r  r  r  s         @r6   ru   zgeninvgauss_gen._cdfN  sc    ""1a((B	1 	1 	1 	1 	1 l;
|DDD{1a###r8   c                 L    t          |dk    |||fd t          j                   S )Nr   c                 T    |dz
  t          j        |           z  || d| z  z   z  dz  z
  S r1  r2  r  s      r6   r  z.geninvgauss_gen._logquasipdf.<locals>.<lambda>_  s,    1q5"&))*;aQqSk!m*K r8   r  r  s       r6   _logquasipdfzgeninvgauss_gen._logquasipdf\  s/    !a%!QKK6'# # 	#r8   Nc                   	
 t          j        |          r.t          j        |          r|                     ||||          }nk|j        dk    rI|j        dk    r>|                     |                                |                                ||          }nt          j        ||          \  }}t          |j        |          \  }	t          t          j	        |                    }t          j
        |          }t          j        ||gdgdgdgg          

j        st          	
fdt          t          |           d          D                       }|                     
d         
d         ||                              |          ||<   
                                 
j        |dk    r|                                }|S )Nr   multi_indexreadonlyflagsop_flagsc              3   `   K   | ](}|         sj         |         nt          d           V  )d S rN   r  slicer  r  bcits     r6   r  z'geninvgauss_gen._rvs.<locals>.<genexpr>  R       ; ; ! 79eLR^A..t ; ; ; ; ; ;r8   r   r   )rP   r  _rvs_scalarr   rU  r  r   r  r  r  emptynditerfinishedtupler  r  rS  iternext)rE   r  r   r   r   r  shp
numsamplesidxr  r  s            @@r6   r   zgeninvgauss_gen._rvsb  s    ;q>> .	bk!nn .	""1a|<<CCVq[[QVq[[""16688QVVXXt\JJCC &q!,,DAq #17D11GC RWS\\**J (4..CAq6"/&0\J<$@B B BB k   ; ; ; ; ;%*CII:q%9%9; ; ; ; ;++BqE2a5*,8: ::A'#,, C k   2::((**C
r8   c           	      ~   3 d}|sd}dk     r d}                                }d}dk    sdk    rd}n4t          ddt          j        dz
            z  dz            k    rd}nd}t	          t          j        |                    }	t          j        |	          }
t          j        |
          }d}|r|rrddz   z  z  |z
  }d|z  dz
  z  z  dz
  }||dz  dz  z
  }d|dz  z  d	z  ||z  dz  z
  |z   }t          j        | t          j        d
|dz  z            z  dz            }t          j        d|z  dz             }|t          j	        |dz  t          j
        dz  z             z  |dz  z
  }| t          j	        |dz            z  |dz  z
  }                     |          3                     |          3z
  }                     |          3z
  }||z
  t          j        d|z            z  }||z
  t          j        d|z            z  }d}3 fd}|}nt          j        d                     |          z            }dz   t          j        dz   dz  dz  z             z   z  }d}|t          j        d                     |          z            z  }d} fd}||k    rt          d          |dk    rt          d          d}||
k     r|
|z
  }||                    |          z  }|                    |          } |||z
  | z  z   } | |z  |z   }!dt          j        |          z   ||!          k    }"t          j        |"          }#|#dk    r|!|"         ||||#z   <   ||#z  }|dk    r!||
z  dk    rd||
z   d}$t#          |$          |dz  }||
k     ̐nމdz
  z  }%t          j        |%dz  f          }&t          j                             |                    }'|'|%z  }(|%dz  k     rNt          j                   })dk    r|)dz  z  |%z  z
  z  z  }*n#|)t          j        ddz  z            z  }*nd\  })}*|&dz
  z  }+d|+z  t          j        |& z  dz            z  z  },|(|*z   |,z   }-||
k     r|
|z
  }t          j        |          t          j        |          }!}.|                    |          }|-|                    |          z  } | |(k    }/t          j        |/          | |(|*z   k    z  }0t          j        |/|0z            }1|%| |/         z  |(z  |!|/<   |'|.|/<   dk    r!|%z  | |0         |(z
  z  |)z  z   dz  z  |!|0<   n8t          j        | |0         |(z
  t          j                  z            z  |!|0<   |)|!|0         dz
  z  z  |.|0<   t          j        |& z  dz            | |1         |(z
  |*z
  z  d|+z  z  z
  }2dz  t          j        |2          z  |!|1<   |+t          j        |!|1          z  dz            z  |.|1<   t          j        ||.z                                 |!          k    }"t!          |"          }#|#dk    r|!|"         ||||#z   <   ||#z  }||
k     t          j        ||	          }!|rd|!z  }!|!S )NFr   r   Tr   rU   r  r     ir  c                 8                         |           z
  S rN   r  )rq   r   lmr  rE   s    r6   logqpdfz,geninvgauss_gen._rvs_scalar.<locals>.logqpdf  s     ,,Q155::r8   c                 2                         |           S rN   r  )rq   r   r  rE   s    r6   r  z,geninvgauss_gen._rvs_scalar.<locals>.logqpdf  s    ,,Q1555r8   zvmin must be smaller than vmax.zumax must be positive.r  iP  z2Not a single random variate could be generated in zH attempts. Sampling does not appear to work for the provided parameters.)r   r   )_moder  rP   r   r  
atleast_1dr  zerosarccosr!  r   r  r   r   r  r   r  r  r  logical_notrS  )4rE   r  r   r  r   
invert_resrD  
ratio_unif
mode_shiftsize1dNrq   	simulateda2a1p1q1phir]  root1root2d1d2vminvmaxumaxr  r  xplusr  r  r  r  r  accept
num_acceptrY   r!  xsk1A1k2A2k3A3rq  r  cond1cond2cond3r/  r  s4   ```                                                @r6   r  zgeninvgauss_gen._rvs_scalar  s    
 	Jq55AJJJq! 
66QUUJJ#c1rwq1u~~-12222JJ J r}Z0011GFOOHQKK	 t	, (61q5\A%)Ua!e_q(1,"a%!)^QY^b2gk1A5ibgcBEk&:&: :Q >??gb2gk***RVC!Gbeai$788826AbfS1Woo-Q6 &&q!Q//&&ua33b8&&ua33b8 	RVC"H%5%55	RVC"H%5%55; ; ; ; ; ; ; ;  vc$"3"3Aq!"<"<<==a%27AEA:1+<#=#==q@rvcD,=,=eQ,J,J&JKKK6 6 6 6 6 6 6 t|| !BCCCqyy !9:::Aa--	M<//Q/777 ((a(00D4K1,,!eaiBF1II+5VF^^
>><?KAiZ!789+INN1?!"1? ? ?C 's+++Q' a--, a!eBQU$$B))!Q2233BbBAEzzVQBZZq55AzBE12Q6BBbfQAX...BBBa!eBR"&"q1---1BR"A a--	M!bhqkk3 ((a(00,,!,444Ru--b2g>uu}55!E(]R/E
%q55"$a%1U8b=A*=*B"Ba!e!LCJJ!"RVQuX]bfQii,G%H%H!HCJE
QU 33%FB37Q;''!qx"}r/A*Ba"f*MM!VbfQii/E
E
{Q': ; ;;%&Q--4+<+<S!Q+G+GG [[
>><?KAiZ!789+I7 a--: jF## 	c'C
r8   c                     |dk     r)|t          j        |dz
  dz  |dz  z             dz   |z
  z  S t          j        d|z
  dz  |dz  z             d|z
  z
  |z  S r1  r  r  s      r6   r  zgeninvgauss_gen._mode2  sj    q55Q
QT 122Q6:;;GQUQJA-..!a%8A==r8   c                    t          j        ||z   |          }t          j        ||          }t          j        |          t          j        |          z  }|                                rad}t          j        |t          d           t          j        |t          j	        t          j
                  }||          ||          z  || <   n||z  }|S )NzInfinite values encountered in the moment calculation involving scipy.special.kve. Values replaced by NaN to avoid incorrect results.r  rI  dtype)rw   kverP   rV   r  rL  rM  rN  	full_liker  r  )	rE   rb   r  r   rE  denominf_valsrY   rD  s	            r6   r  zgeninvgauss_gen._munp9  s    fQUAq!8C==28E??2<<>> 	.C M#~!<<<<S"&
;;;Ay>E8),<<AxiLLeAr8   r  )r   r   r   r   rc   rk   r   rr   ru   r  r   r  r  r  r   r8   r6   r  r    s        # #H" " "  
   - - -$ $ $# # #5 5 5 5nW W Wr> > >    r8   r  r  c                   \     e Zd ZdZej        Zd Zd Z fdZ	d Z
d Zd Zdd	Zd
 Z xZS )norminvgauss_gena  A Normal Inverse Gaussian continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `norminvgauss` is:

    .. math::

        f(x, a, b) = \frac{a \, K_1(a \sqrt{1 + x^2})}{\pi \sqrt{1 + x^2}} \,
                     \exp(\sqrt{a^2 - b^2} + b x)

    where :math:`x` is a real number, the parameter :math:`a` is the tail
    heaviness and :math:`b` is the asymmetry parameter satisfying
    :math:`a > 0` and :math:`|b| <= a`.
    :math:`K_1` is the modified Bessel function of second kind
    (`scipy.special.k1`).

    %(after_notes)s

    A normal inverse Gaussian random variable `Y` with parameters `a` and `b`
    can be expressed as a normal mean-variance mixture:
    ``Y = b * V + sqrt(V) * X`` where `X` is ``norm(0,1)`` and `V` is
    ``invgauss(mu=1/sqrt(a**2 - b**2))``. This representation is used
    to generate random variates.

    Another common parametrization of the distribution (see Equation 2.1 in
    [2]_) is given by the following expression of the pdf:

    .. math::

        g(x, \alpha, \beta, \delta, \mu) =
        \frac{\alpha\delta K_1\left(\alpha\sqrt{\delta^2 + (x - \mu)^2}\right)}
        {\pi \sqrt{\delta^2 + (x - \mu)^2}} \,
        e^{\delta \sqrt{\alpha^2 - \beta^2} + \beta (x - \mu)}

    In SciPy, this corresponds to
    `a = alpha * delta, b = beta * delta, loc = mu, scale=delta`.

    References
    ----------
    .. [1] O. Barndorff-Nielsen, "Hyperbolic Distributions and Distributions on
           Hyperbolae", Scandinavian Journal of Statistics, Vol. 5(3),
           pp. 151-157, 1978.

    .. [2] O. Barndorff-Nielsen, "Normal Inverse Gaussian Distributions and
           Stochastic Volatility Modelling", Scandinavian Journal of
           Statistics, Vol. 24, pp. 1-13, 1997.

    %(example)s

    c                 @    |dk    t          j        |          |k     z  S r7  )rP   absoluterE   r   r   s      r6   rc   znorminvgauss_gen._argcheck  s    A"+a..1,--r8   c                     t          dddt          j        fd          }t          ddt          j         t          j        fd          }||gS rh  rh   ri  s      r6   rk   znorminvgauss_gen._shape_info  r[  r8   c                 J    t                                          |d          S )N)r   r   rN  rX  rY  s     r6   r  znorminvgauss_gen._fitstart  s"     ww  H 555r8   c                     t          j        |dz  |dz  z
            }|t           j        z  }t          j        d|          }|t	          j        ||z            z  t          j        ||z  ||z  z
  |z             z  |z  S r  )rP   r   r   hypotrw   k1er   )rE   rq   r   r   r  fac1sqs          r6   rr   znorminvgauss_gen._pdf  ss    1q!t$$25yXa^^bfQVnn$rvacAbDj5.@'A'AABFFr8   c           
         t          j        |          r/t          j        | j        |t           j        ||f          d         S t          j        |          }t          j        |          }g }t          |||          D ]H\  }}}|                    t          j        | j        |t           j        ||f          d                    It          j	        |          S )NrN  r   )
rP   r  r   r  rr   ri   r  r  appendr  )rE   rq   r   r   resultr!  a0r  s           r6   ry   znorminvgauss_gen._sf  s    ;q>> 
	$>$)QaVDDDQGGa  Aa  AF #Aq! @ @RinTYBF35r(< < <<=? @ @ @ @8F###r8   c                       fd}t          j        |          r ||||          S g }t          |||          D ]&\  }}}|                     ||||                     't          j        |          S )Nc                    
fd}
                     ||          } |||||           }|dk    r|S |dk    r8d}|}||z   } |||||           dk    rd|z  }||z   } |||||           dk    n7d}|}||z
  } |||||           dk     rd|z  }||z
  } |||||           dk     t          j        |||||| f
j                  }	|	S )Nc                 8                         | ||          |z
  S rN   ry   )rq   r   r   r}   rE   s       r6   eqz6norminvgauss_gen._isf.<locals>._isf_scalar.<locals>.eq  s    xx1a((1,,r8   r   r   rU   )rG   r  )r   r   r@  r  )r}   r   r   r$  xmemdeltaleftrightr  rE   s             r6   _isf_scalarz*norminvgauss_gen._isf.<locals>._isf_scalar  sF   - - - - - 1aBB1aBQww	AvvU
b1a((1,,eGEJE b1a((1,,
 Ezbq!Q''!++eGE:D bq!Q''!++ _RuAq!9*.)5 5 5FMr8   )rP   r  r  r  r  )	rE   r}   r   r   r*  r  q0r  r  s	   `        r6   r   znorminvgauss_gen._isf  s    	 	 	 	 	B ;q>> 	$;q!Q'''F #Aq! 7 7Rkk"b"5566668F###r8   Nc                     t          j        |dz  |dz  z
            }t                              d|z  ||          }||z  t          j        |          t                              ||          z  z   S )NrU   r   )rD  r   r   r  )rP   r   r  r  r  )rE   r   r   r   r   r  igs          r6   r   znorminvgauss_gen._rvs  sy     1q!t$$\\QuW4l\KK2vdhhD<H '/ 'J 'J J J 	Jr8   c                     t          j        |dz  |dz  z
            }||z  }|dz  |dz  z  }d|z  |t          j        |          z  z  }ddd|dz  z  |dz  z  z   z  |z  }||||fS )NrU   r  rI  r   r$  r  )rE   r   r   r  r   varianceskewnesskurtosiss           r6   r   znorminvgauss_gen._stats  s    1q!t$$5ya4%(?7a"'%..01!a!Q$hAo-.6Xx11r8   r  )r   r   r   r   r   r  r  rc   rk   r  rr   ry   r   r   r   r  r  s   @r6   r  r  L  s        4 4j "4M. . .  
6 6 6 6 6
G G G$ $ $($ ($ ($TJ J J J2 2 2 2 2 2 2r8   r  norminvgaussc                   b     e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zd	 Zd fd	Z xZS )invweibull_genu  An inverted Weibull continuous random variable.

    This distribution is also known as the Fréchet distribution or the
    type II extreme value distribution.

    %(before_notes)s

    Notes
    -----
    The probability density function for `invweibull` is:

    .. math::

        f(x, c) = c x^{-c-1} \exp(-x^{-c})

    for :math:`x > 0`, :math:`c > 0`.

    `invweibull` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    References
    ----------
    F.R.S. de Gusmao, E.M.M Ortega and G.M. Cordeiro, "The generalized inverse
    Weibull distribution", Stat. Papers, vol. 52, pp. 591-619, 2011.

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zinvweibull_gen._shape_info  r  r8   c                     t          j        || dz
            }t          j        ||           }t          j        |           }||z  |z  S r  rP   r  r   )rE   rq   r  xc1xc2s        r6   rr   zinvweibull_gen._pdf  sG    hq1"s(##hq1"oofcTll3w}r8   c                 X    t          j        ||           }t          j        |           S rN   r7  )rE   rq   r  r8  s       r6   ru   zinvweibull_gen._cdf  s#    hq1"oovsd||r8   c                 6    t          j        || z              S rN   )rP   r  r  s      r6   ry   zinvweibull_gen._sf  s    !aR%    r8   c                 X    t          j        t          j        |           d|z            S rD  )rP   r  r   r  s      r6   r~   zinvweibull_gen._ppf  s"    x
DF+++r8   c                 :    t          j        |            d|z  z  S Nr  r>  r  s      r6   r   zinvweibull_gen._isf  s    1"A&&r8   c                 6    t          j        d||z  z
            S r^   ro  r  s      r6   r  zinvweibull_gen._munp  s    xAE	"""r8   c                 V    dt           z   t           |z  z   t          j        |          z
  S r^   r=  r  s     r6   r   zinvweibull_gen._entropy  s"    x&1*$rvayy00r8   Nc                 V    |dn|}t                                          ||          S )N)r   rN  rX  )rE   rF   rG   r  s      r6   r  zinvweibull_gen._fitstart  s-    vv4ww  D 111r8   rN   )r   r   r   r   r   r  r  rk   rr   ru   ry   r~   r   r  r   r  r  r  s   @r6   r4  r4    s         : "4ME E E    ! ! !, , ,' ' '# # #1 1 12 2 2 2 2 2 2 2 2 2r8   r4  
invweibullc                   >    e Zd ZdZd Zd Zd
dZd Zd Zd Z	d	 Z
dS )jf_skew_t_gena  Jones and Faddy skew-t distribution.

    %(before_notes)s

    Notes
    -----
    The probability density function for `jf_skew_t` is:

    .. math::

        f(x; a, b) = C_{a,b}^{-1}
                    \left(1+\frac{x}{\left(a+b+x^2\right)^{1/2}}\right)^{a+1/2}
                    \left(1-\frac{x}{\left(a+b+x^2\right)^{1/2}}\right)^{b+1/2}

    for real numbers :math:`a>0` and :math:`b>0`, where
    :math:`C_{a,b} = 2^{a+b-1}B(a,b)(a+b)^{1/2}`, and :math:`B` denotes the
    beta function (`scipy.special.beta`).

    When :math:`a<b`, the distribution is negatively skewed, and when
    :math:`a>b`, the distribution is positively skewed. If :math:`a=b`, then
    we recover the `t` distribution with :math:`2a` degrees of freedom.

    `jf_skew_t` takes :math:`a` and :math:`b` as shape parameters.

    %(after_notes)s

    References
    ----------
    .. [1] M.C. Jones and M.J. Faddy. "A skew extension of the t distribution,
           with applications" *Journal of the Royal Statistical Society*.
           Series B (Statistical Methodology) 65, no. 1 (2003): 159-174.
           :doi:`10.1111/1467-9868.00378`

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS rh  rh   ri  s      r6   rk   zjf_skew_t_gen._shape_infoM  rl  r8   c                 (   d||z   dz
  z  t          j        ||          z  t          j        ||z             z  }d|t          j        ||z   |dz  z             z  z   |dz   z  }d|t          j        ||z   |dz  z             z  z
  |dz   z  }||z  |z  S NrU   r   r   )rw   ro  rP   r   )rE   rq   r   r   r  r  r  s          r6   rr   zjf_skew_t_gen._pdfR  s    !a%!)rwq!}},rwq1u~~=!bga!ea1fn----1s7;!bga!ea1fn----1s7;Bw{r8   Nc                     |                     |||          }d|z  dz
  t          j        ||z             z  }dt          j        |d|z
  z            z  }||z  S r  )ro  rP   r   )rE   r   r   r   r   r  r  d3s           r6   r   zjf_skew_t_gen._rvsX  s\    q!T**"fqjBGAENN*q2v'''Bwr8   c                 z    d|t          j        ||z   |dz  z             z  z   dz  }t          j        |||          S Nr   rU   r   )rP   r   rw   r}  rE   rq   r   r   r  s        r6   ru   zjf_skew_t_gen._cdf^  s@    RWQUQ!V^,,,,3z!Q"""r8   c                 z    d|t          j        ||z   |dz  z             z  z   dz  }t          j        |||          S rK  )rP   r   rw   r  rL  s        r6   ry   zjf_skew_t_gen._sfb  s@    RWQUQ!V^,,,,3{1a###r8   c                     t                               |||          }d|z  dz
  t          j        ||z             z  }dt          j        |d|z
  z            z  }||z  S r  )ro  r  rP   r   )rE   r}   r   r   r  r  rI  s          r6   r~   zjf_skew_t_gen._ppff  sZ    XXaA"fqjBGAENN*q2v'''Bwr8   c                     d }|d|z  k    |d|z  k    z  |dk    z  }t          ||||ft          j        |t          j        g          t          j                  S )zReturns the n-th moment(s) where all the following hold:

        - n >= 0
        - a > n / 2
        - b > n / 2

        The result is np.nan in all other cases.
        c                 n   ||z   d| z  z  }d| z  t          j        ||          z  }t          j        | dz             }t          j        |dz  dk    dd          }t          j        |d| z  z   |z
  |d| z  z
  |z             }t          j        | |          |z  |z  }||z  |                                z  S )zgComputes E[T^(n_k)] where T is skew-t distributed with
            parameters a_k and b_k.
            r   rU   r   r   r  )rw   ro  rP   rR  rT  r  r  )	n_ka_kb_krE  r  indicesr~  r  	sum_termss	            r6   
nth_momentz'jf_skew_t_gen._munp.<locals>.nth_momentu  s     9#),CHrwsC000Eia((G(7Q;?B22CcCi'13s?W3LMMAW--3a7I;00r8   r   r   r  r   rP   r  r  r  )rE   rb   r   r   rV  nth_moment_valids         r6   r  zjf_skew_t_gen._munpl  sp    	1 	1 	1 aKAaK8AFC1ILRZL999F	
 
 	
r8   r  )r   r   r   r   rk   rr   r   ru   ry   r~   r  r   r8   r6   rD  rD  (  s        # #H  
     # # #$ $ $  
 
 
 
 
r8   rD  	jf_skew_tc                   J    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zd	S )
johnsonsb_gena!  A Johnson SB continuous random variable.

    %(before_notes)s

    See Also
    --------
    johnsonsu

    Notes
    -----
    The probability density function for `johnsonsb` is:

    .. math::

        f(x, a, b) = \frac{b}{x(1-x)}  \phi(a + b \log \frac{x}{1-x} )

    where :math:`x`, :math:`a`, and :math:`b` are real scalars; :math:`b > 0`
    and :math:`x \in [0,1]`.  :math:`\phi` is the pdf of the normal
    distribution.

    `johnsonsb` takes :math:`a` and :math:`b` as shape parameters.

    %(after_notes)s

    %(example)s

    c                     |dk    ||k    z  S r7  r   r  s      r6   rc   zjohnsonsb_gen._argcheck  rY  r8   c                     t          ddt          j         t          j        fd          }t          dddt          j        fd          }||gS Nr   Fr
  r   r   rh   ri  s      r6   rk   zjohnsonsb_gen._shape_info  r  r8   c                 r    t          ||t          j        |          z  z             }|dz  |d|z
  z  z  |z  S r.  )r   rw   r<  )rE   rq   r   r   trms        r6   rr   zjohnsonsb_gen._pdf  s;    AbhqkkM)**ua1gs""r8   c                 P    t          ||t          j        |          z  z             S rN   )r   rw   r<  ru  s       r6   ru   zjohnsonsb_gen._cdf  s!    Qrx{{]*+++r8   c                 V    t          j        d|z  t          |          |z
  z            S r  )rw   r8  r   r  s       r6   r~   zjohnsonsb_gen._ppf  &    xa9Q<<!#34555r8   c                 P    t          ||t          j        |          z  z             S rN   )r   rw   r<  ru  s       r6   ry   zjohnsonsb_gen._sf  s!    AbhqkkM)***r8   c                 V    t          j        d|z  t          |          |z
  z            S r  )rw   r8  r   r  s       r6   r   zjohnsonsb_gen._isf  rc  r8   N)r   r   r   r   r   r  r  rc   rk   rr   ru   r~   ry   r   r   r8   r6   r[  r[    s         6 "4M" " "  
# # #
, , ,6 6 6+ + +6 6 6 6 6r8   r[  	johnsonsbc                   D    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
dd
ZdS )johnsonsu_gena-  A Johnson SU continuous random variable.

    %(before_notes)s

    See Also
    --------
    johnsonsb

    Notes
    -----
    The probability density function for `johnsonsu` is:

    .. math::

        f(x, a, b) = \frac{b}{\sqrt{x^2 + 1}}
                     \phi(a + b \log(x + \sqrt{x^2 + 1}))

    where :math:`x`, :math:`a`, and :math:`b` are real scalars; :math:`b > 0`.
    :math:`\phi` is the pdf of the normal distribution.

    `johnsonsu` takes :math:`a` and :math:`b` as shape parameters.

    The first four central moments are calculated according to the formulas
    in [1]_.

    %(after_notes)s

    References
    ----------
    .. [1] Taylor Enterprises. "Johnson Family of Distributions".
       https://variation.com/wp-content/distribution_analyzer_help/hs126.htm

    %(example)s

    c                     |dk    ||k    z  S r7  r   r  s      r6   rc   zjohnsonsu_gen._argcheck  rY  r8   c                     t          ddt          j         t          j        fd          }t          dddt          j        fd          }||gS r^  rh   ri  s      r6   rk   zjohnsonsu_gen._shape_info  r  r8   c                     ||z  }t          ||t          j        |          z  z             }|dz  t          j        |dz             z  |z  S r  )r   rP   arcsinhr   )rE   rq   r   r   rF  r`  s         r6   rr   zjohnsonsu_gen._pdf  sL     qSA
1--..uRWRV__$S((r8   c                 P    t          ||t          j        |          z  z             S rN   )r   rP   rl  ru  s       r6   ru   zjohnsonsu_gen._cdf  s"    QA..///r8   c                 P    t          j        t          |          |z
  |z            S rN   )rP   sinhr   r  s       r6   r~   zjohnsonsu_gen._ppf   "    w	!q(A-...r8   c                 P    t          ||t          j        |          z  z             S rN   )r   rP   rl  ru  s       r6   ry   zjohnsonsu_gen._sf  s"    A
1--...r8   c                 P    t          j        t          |          |z
  |z            S rN   )rP   ro  r   ru  s       r6   r   zjohnsonsu_gen._isf  rp  r8   r  c                 t   d\  }}}}|dz  }t          j        |          }	||z  }
d|v r|	dz   t          j        |
          z  }d|v r5dt          j        |          z  |	t          j        d|
z            z  dz   z  }d|v r|	dz  t          j        |          dz  z  }d	t          j        |
          z  }|	|	dz   z  t          j        d	|
z            z  }t          j        d          d|	t          j        d|
z            z  z   d
z  z  }| ||z   z  |z  }d|v rd	d|	z  z   }d|	dz  z  |	dz   z  t          j        d|
z            z  }|	dz  t          j        d|
z            z  }dd	|	dz  z  z   d|	d	z  z  z   |	dz  z   }dd|	t          j        d|
z            z  z   dz  z  }||z   ||z  z   |z  d	z
  }||||fS )NNNNNr  rD  r   r  rU   r   r  r  r  r  r  r$  r  )rP   r   ro  rw   r  re  r   )rE   r   r   r  rD  rE  rF  rG  bn2expbn2a_br  r  r  r  rK  s                   r6   r   zjohnsonsu_gen._stats	  s    1CRf!e'>>#+,B'>>bhsmm#VBGAcENN%:Q%>?C'>>bhsmmS00B273<<B6A:&37BGAJJ!frwqu~~&="=!EEER5(B'>>QvXB619
+bgaenn<BRWQsU^^+Ba	k!AfaiK/&!);Bq6"'!C%..00144Er'BrE/U*Q.B3Br8   Nr  )r   r   r   r   rc   rk   rr   ru   r~   ry   r   r   r   r8   r6   rh  rh    s        " "F" " "  
) ) )0 0 0/ / // / // / /     r8   rh  	johnsonsuc                   X    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZddZddZdS )
landau_gena4  A Landau continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `landau` ([1]_, [2]_) is:

    .. math::

        f(x) = \frac{1}{\pi}\int_0^\infty \exp(-t \log t - xt)\sin(\pi t) dt

    for a real number :math:`x`.

    %(after_notes)s

    Often (e.g. [2]_), the Landau distribution is parameterized in terms of a
    location parameter :math:`\mu` and scale parameter :math:`c`, the latter of
    which *also* introduces a location shift. If ``mu`` and ``c`` are used to
    represent these parameters, this corresponds with SciPy's parameterization
    with ``loc = mu + 2*c / np.pi * np.log(c)`` and ``scale = c``.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``pdf``, ``cdf``, ``ppf``, ``sf`` and ``isf``
    methods. [1]_

    References
    ----------
    .. [1] Landau, L. (1944). "On the energy loss of fast particles by
           ionization". J. Phys. (USSR). 8: 201.
    .. [2] "Landau Distribution", Wikipedia,
           https://en.wikipedia.org/wiki/Landau_distribution
    .. [3] Chambers, J. M., Mallows, C. L., & Stuck, B. (1976).
           "A method for simulating stable random variables."
           Journal of the American Statistical Association, 71(354), 340-344.
    .. [4] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.
    .. [5] Yoshimura, T. "Numerical Evaluation and High Precision Approximation
           Formula for Landau Distribution".
           :doi:`10.36227/techrxiv.171822215.53612870/v2`

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zlandau_gen._shape_infoV  r   r8   c                     dS )NgX(@r   rj   s    r6   r   zlandau_gen._entropyY  s    ""r8   c                 .    t          j        |dd          S r  )rn   _landau_pdfr   s     r6   rr   zlandau_gen._pdf]  r  r8   c                 .    t          j        |dd          S r  )rn   _landau_cdfr   s     r6   ru   zlandau_gen._cdf`  r  r8   c                 .    t          j        |dd          S r  )rn   
_landau_sfr   s     r6   ry   zlandau_gen._sfc  s    ~aA&&&r8   c                 .    t          j        |dd          S r  )rn   _landau_ppfr
  s     r6   r~   zlandau_gen._ppff  r  r8   c                 .    t          j        |dd          S r  )rn   _landau_isfr
  s     r6   r   zlandau_gen._isfi  r  r8   c                 ^    t           j        t           j        t           j        t           j        fS rN   r  rj   s    r6   r   zlandau_gen._statsl  r  r8   c                 *    |dk    rt           j        ndS r  r  ra   s     r6   r  zlandau_gen._munpo  s    QrvvA%r8   Nc                     t          |t                    r|                                }t          j        |g d          \  }}}|||z
  dz  fS r  r  r  s         r6   r  zlandau_gen._fitstartr  r  r8   c                 p   t           j        dz  }|                    t           j         dz  t           j        dz  |          }|                    |          }dt           j        z  ||z   t          j        |          z  t          j        ||z  t          j        |          z  ||z   z            z
  z  }|S )NrU   r  )rP   r   r  r;  r  r   r!  )rE   r   r   pi_2UWSs          r6   r   zlandau_gen._rvsy  s    uqy  "%!RUQYT BB--4-88I$(bfQii/64!8bfQii#7D1H"EFFG Hr8   rN   r  )r   r   r   r   rk   r   rr   ru   ry   r~   r   r   r  r  r   r   r8   r6   rz  rz  *  s        * *V  # # #( ( (( ( (' ' '( ( (( ( (. . .& & &" " " "     r8   rz  landauc                       e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Ze eed          d                         ZdS )laplace_gena
  A Laplace continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `laplace` is

    .. math::

        f(x) = \frac{1}{2} \exp(-|x|)

    for a real number :math:`x`.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zlaplace_gen._shape_info  r   r8   Nc                 2    |                     dd|          S )Nr   r   r  )laplacer   s      r6   r   zlaplace_gen._rvs  s    ##Aqt#444r8   c                 L    dt          j        t          |                     z  S r#  )rP   r   r  r   s     r6   rr   zlaplace_gen._pdf  s    263q66'??""r8   c           	          t          j        d          5  t          j        |dk    ddt          j        |           z  z
  dt          j        |          z            cd d d            S # 1 swxY w Y   d S )Nr9  rr  r   r   r   )rP   r<  rT  r   r   s     r6   ru   zlaplace_gen._cdf  s    [h''' 	H 	H8AE3RVQBZZ#7RVAYYGG	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs   AA++A/2A/c                 .    |                      |           S rN   ru   r   s     r6   ry   zlaplace_gen._sf  s    yy!}}r8   c                     t          j        |dk    t          j        dd|z
  z             t          j        d|z                      S r   rP   rT  r   r   s     r6   r~   zlaplace_gen._ppf  s9    xC"&AaC//!126!A#;;???r8   c                 .    |                      |           S rN   r  r   s     r6   r   zlaplace_gen._isf  s    		!}r8   c                     dS )N)r   rU   r   r  r   rj   s    r6   r   zlaplace_gen._stats  s    zr8   c                 0    t          j        d          dz   S r  r2  rj   s    r6   r   zlaplace_gen._entropy  s    vayy{r8   z        This function uses explicit formulas for the maximum likelihood
        estimation of the Laplace distribution parameters, so the keyword
        arguments `loc`, `scale`, and `optimizer` are ignored.

r   c                     t          | |||          \  }}}|t          j        |          }|9t          j        t          j        ||z
                      t          |          z  }||fS rN   )rL  rP   medianr  r  r  )rE   rF   rG   r5   r   r   s         r6   rC   zlaplace_gen.fit  sp     9t9=tE EdF <9T??D>fRVD4K0011SYY>FV|r8   r  )r   r   r   r   rk   r   rr   ru   ry   r~   r   r   r   rK   r
   r   rC   r   r8   r6   r  r    s         &  5 5 5 5# # #H H H  @ @ @        6F G G G 	G G _
  r8   r  r  c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )laplace_asymmetric_genu  An asymmetric Laplace continuous random variable.

    %(before_notes)s

    See Also
    --------
    laplace : Laplace distribution

    Notes
    -----
    The probability density function for `laplace_asymmetric` is

    .. math::

       f(x, \kappa) &= \frac{1}{\kappa+\kappa^{-1}}\exp(-x\kappa),\quad x\ge0\\
                    &= \frac{1}{\kappa+\kappa^{-1}}\exp(x/\kappa),\quad x<0\\

    for :math:`-\infty < x < \infty`, :math:`\kappa > 0`.

    `laplace_asymmetric` takes ``kappa`` as a shape parameter for
    :math:`\kappa`. For :math:`\kappa = 1`, it is identical to a
    Laplace distribution.

    %(after_notes)s

    Note that the scale parameter of some references is the reciprocal of
    SciPy's ``scale``. For example, :math:`\lambda = 1/2` in the
    parameterization of [1]_ is equivalent to ``scale = 2`` with
    `laplace_asymmetric`.

    References
    ----------
    .. [1] "Asymmetric Laplace distribution", Wikipedia
            https://en.wikipedia.org/wiki/Asymmetric_Laplace_distribution

    .. [2] Kozubowski TJ and Podgórski K. A Multivariate and
           Asymmetric Generalization of Laplace Distribution,
           Computational Statistics 15, 531--540 (2000).
           :doi:`10.1007/PL00022717`

    %(example)s

    c                 @    t          dddt          j        fd          gS )NkappaFr   r
  rh   rj   s    r6   rk   z"laplace_asymmetric_gen._shape_info  s    7EArv;GGHHr8   c                 R    t          j        |                     ||                    S rN   r  rE   rq   r  s      r6   rr   zlaplace_asymmetric_gen._pdf   s     vdll1e,,---r8   c                     d|z  }|t          j        |dk    | |          z  }|t          j        ||z             z  }|S r  r  )rE   rq   r  kapinvr{  s        r6   r   zlaplace_asymmetric_gen._logpdf  sF    5"(16E66222rveFl###
r8   c                     d|z  }||z   }t          j        |dk    dt          j        | |z            ||z  z  z
  t          j        ||z            ||z  z            S r  rP   rT  r   rE   rq   r  r  
kappkapinvs        r6   ru   zlaplace_asymmetric_gen._cdf	  sk    56\
xQBFA2e8,,fZ.?@@qx((%
*:;= = 	=r8   c           	          d|z  }||z   }t          j        |dk    t          j        | |z            ||z  z  dt          j        ||z            ||z  z  z
            S r  r  r  s        r6   ry   zlaplace_asymmetric_gen._sf  sn    56\
xQr%x((&*;<BF1V8,,eJ.>??A A 	Ar8   c                     d|z  }||z   }t          j        |||z  k    t          j        d|z
  |z  |z             |z  t          j        ||z  |z            |z            S r^   r  rE   r}   r  r  r  s        r6   r~   zlaplace_asymmetric_gen._ppf  sr    56\
xU:--Q
 25 8999&@q|E12258: : 	:r8   c                     d|z  }||z   }t          j        |||z  k    t          j        ||z  |z             |z  t          j        d|z
  |z  |z            |z            S r^   r  r  s        r6   r   zlaplace_asymmetric_gen._isf  su    56\
xVJ..*U 2333F:Az1%788>@ @ 	@r8   c                 T   d|z  }||z
  }||z  ||z  z   }ddt          j        |d          z
  z  t          j        dt          j        |d          z   d          z  }ddt          j        |d          z   z  t          j        dt          j        |d          z   d          z  }||||fS )	Nr   r   r  r$  r  r  r.  rU   r  )rE   r  r  mnr  rF  rG  s          r6   r   zlaplace_asymmetric_gen._stats%  s    5e^VmeEk)!BHUA&&&'28E13E3E1Es(K(KK!BHUA&&&'28E13E3E1Eq(I(II3Br8   c                 <    dt          j        |d|z  z             z   S r^   r2  rE   r  s     r6   r   zlaplace_asymmetric_gen._entropy-  s    26%%-((((r8   Nr  r   r8   r6   r  r    s        * *VI I I. . .  = = =A A A: : :@ @ @  ) ) ) ) )r8   r  laplace_asymmetricc                 *   t          |t                    st          j        |          }|                    dd           }|                    dd           }| j        r't          | j                            d                    nd}g }g }| j        r| j                            dd                                          }	t          |	          D ]c\  }
}dt          |
          z   }|d|z   d|z   g}t          ||          }|                    |           |                    |           ||||<   ddd	d
dddh|}t          |                              |          }|rt          d| d          t          |          |k    rt          d          d ||h|vrt!          d          t          |t                    r|                                n|}t          j        |                                          st)          d          |g|||R S )Nr   r   ,r    r  fix_r.   r/   r0   r1   zUnknown keyword arguments: r2   zToo many positional arguments.r   r   )r?   r*   rP   r   r=   shapesr  splitrW  	enumeratestrr   r  set
differencer4   r  r  r   r   r   )distrF   rG   r5   r   r   
num_shapesfshape_keysfshapesr  r  r  keynamesr}  
known_keysunknown_keys
uncensoreds                     r6   rL  rL  4  sD   dL))  z$88FD!!DXXh%%F04BT[&&s++,,,JKG
 { 	 $$S#..4466f%% 	  	 DAqA,C#'6A:.E&tU33Cs###NN3S	 +x(2%02Jt99''
33L GElEEEFFF
4yy:8999D&+7+++  ' ( ( 	( &0l%C%CM!!!J;z""&&(( A?@@@)7)D)&)))r8   c                   J    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zd	S )
levy_genag  A Levy continuous random variable.

    %(before_notes)s

    See Also
    --------
    levy_stable, levy_l

    Notes
    -----
    The probability density function for `levy` is:

    .. math::

        f(x) = \frac{1}{\sqrt{2\pi x^3}} \exp\left(-\frac{1}{2x}\right)

    for :math:`x > 0`.

    This is the same as the Levy-stable distribution with :math:`a=1/2` and
    :math:`b=1`.

    %(after_notes)s

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

    Calculate the first four moments:

    >>> mean, var, skew, kurt = levy.stats(moments='mvsk')

    Display the probability density function (``pdf``):

    >>> # `levy` is very heavy-tailed.
    >>> # To show a nice plot, let's cut off the upper 40 percent.
    >>> a, b = levy.ppf(0), levy.ppf(0.6)
    >>> x = np.linspace(a, b, 100)
    >>> ax.plot(x, levy.pdf(x),
    ...        'r-', lw=5, alpha=0.6, label='levy 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 = levy()
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

    Check accuracy of ``cdf`` and ``ppf``:

    >>> vals = levy.ppf([0.001, 0.5, 0.999])
    >>> np.allclose([0.001, 0.5, 0.999], levy.cdf(vals))
    True

    Generate random numbers:

    >>> r = levy.rvs(size=1000)

    And compare the histogram:

    >>> # manual binning to ignore the tail
    >>> bins = np.concatenate((np.linspace(a, b, 20), [np.max(r)]))
    >>> ax.hist(r, bins=bins, density=True, histtype='stepfilled', alpha=0.2)
    >>> ax.set_xlim([x[0], x[-1]])
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()

    c                     g S rN   r   rj   s    r6   rk   zlevy_gen._shape_info  r   r8   c                     dt          j        dt           j        z  |z            z  |z  t          j        dd|z  z            z  S Nr   rU   r  rQ  r   s     r6   rr   zlevy_gen._pdf  s=    271RU719%%%)BF2qs8,<,<<<r8   c                 T    t          j        t          j        d|z                      S r#  )rw   erfcrP   r   r   s     r6   ru   zlevy_gen._cdf  s     wrwsQw''(((r8   c                 T    t          j        t          j        d|z                      S r#  rU  r   s     r6   ry   zlevy_gen._sf  s     vbgcAg&&'''r8   c                 6    t          |dz            }d||z  z  S NrU   r   r   rE   r}   r}  s      r6   r~   zlevy_gen._ppf  s     !nncCi  r8   c                 <    ddt          j        |          dz  z  z  S r1  )rw   erfinvr
  s     r6   r   zlevy_gen._isf  s    !BIaLL!O#$$r8   c                 ^    t           j        t           j        t           j        t           j        fS rN   r  rj   s    r6   r   zlevy_gen._stats  r  r8   Nr   r   r   r   r   r  r  rk   rr   ru   ry   r~   r   r   r   r8   r6   r  r  e  s        G GP "4M  = = =) ) )( ( (! ! !
% % %. . . . .r8   r  levyc                   J    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zd	S )

levy_l_gena  A left-skewed Levy continuous random variable.

    %(before_notes)s

    See Also
    --------
    levy, levy_stable

    Notes
    -----
    The probability density function for `levy_l` is:

    .. math::
        f(x) = \frac{1}{|x| \sqrt{2\pi |x|}} \exp{ \left(-\frac{1}{2|x|} \right)}

    for :math:`x < 0`.

    This is the same as the Levy-stable distribution with :math:`a=1/2` and
    :math:`b=-1`.

    %(after_notes)s

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

    Calculate the first four moments:

    >>> mean, var, skew, kurt = levy_l.stats(moments='mvsk')

    Display the probability density function (``pdf``):

    >>> # `levy_l` is very heavy-tailed.
    >>> # To show a nice plot, let's cut off the lower 40 percent.
    >>> a, b = levy_l.ppf(0.4), levy_l.ppf(1)
    >>> x = np.linspace(a, b, 100)
    >>> ax.plot(x, levy_l.pdf(x),
    ...        'r-', lw=5, alpha=0.6, label='levy_l 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 = levy_l()
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

    Check accuracy of ``cdf`` and ``ppf``:

    >>> vals = levy_l.ppf([0.001, 0.5, 0.999])
    >>> np.allclose([0.001, 0.5, 0.999], levy_l.cdf(vals))
    True

    Generate random numbers:

    >>> r = levy_l.rvs(size=1000)

    And compare the histogram:

    >>> # manual binning to ignore the tail
    >>> bins = np.concatenate(([np.min(r)], np.linspace(a, b, 20)))
    >>> ax.hist(r, bins=bins, density=True, histtype='stepfilled', alpha=0.2)
    >>> ax.set_xlim([x[0], x[-1]])
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()

    c                     g S rN   r   rj   s    r6   rk   zlevy_l_gen._shape_info  r   r8   c                     t          |          }dt          j        dt          j        z  |z            z  |z  t          j        dd|z  z            z  S r  )r  rP   r   r   r   rE   rq   r  s      r6   rr   zlevy_l_gen._pdf  sH    VV25$$$R'r1R4y(9(999r8   c                 t    t          |          }dt          dt          j        |          z            z  dz
  S r  )r  r   rP   r   r  s      r6   ru   zlevy_l_gen._cdf  s1    VV9Q_---11r8   c                 n    t          |          }dt          dt          j        |          z            z  S r  )r  r   rP   r   r  s      r6   ry   zlevy_l_gen._sf#  s,    VV8AO,,,,r8   c                 <    t          |dz   dz            }d||z  z  S )Nr   rU   rA  r   r  s      r6   r~   zlevy_l_gen._ppf'  s&    SA&&sSy!!r8   c                 2    dt          |dz            dz  z  S )Nr  rU   r   r
  s     r6   r   zlevy_l_gen._isf+  s    )AaC..!###r8   c                 ^    t           j        t           j        t           j        t           j        fS rN   r  rj   s    r6   r   zlevy_l_gen._stats.  r  r8   Nr  r   r8   r6   r  r    s        F FN "4M  : : :
2 2 2- - -" " "$ $ $. . . . .r8   r  levy_lc                        e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Ze ee           fd                        Z xZS )logistic_gena  A logistic (or Sech-squared) continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `logistic` is:

    .. math::

        f(x) = \frac{\exp(-x)}
                    {(1+\exp(-x))^2}

    `logistic` is a special case of `genlogistic` with ``c=1``.

    Remark that the survival function (``logistic.sf``) is equal to the
    Fermi-Dirac distribution describing fermionic statistics.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zlogistic_gen._shape_infoM  r   r8   Nc                 .    |                     |          S r9  )logisticr   s      r6   r   zlogistic_gen._rvsP  s    $$$$///r8   c                 P    t          j        |                     |                    S rN   r  r   s     r6   rr   zlogistic_gen._pdfS  r  r8   c                     t          j        |           }|dt          j        t          j        |                    z  z
  S r?  )rP   r  rw   r  r   )rE   rq   r  s      r6   r   zlogistic_gen._logpdfW  s3    VAYYJ2+++++r8   c                 *    t          j        |          S rN   r7  r   s     r6   ru   zlogistic_gen._cdf[      x{{r8   c                 *    t          j        |          S rN   rw   	log_expitr   s     r6   r   zlogistic_gen._logcdf^  s    |Ar8   c                 *    t          j        |          S rN   r;  r   s     r6   r~   zlogistic_gen._ppfa  r  r8   c                 ,    t          j        |           S rN   r7  r   s     r6   ry   zlogistic_gen._sfd  s    x||r8   c                 ,    t          j        |           S rN   r  r   s     r6   r   zlogistic_gen._logsfg  s    |QBr8   c                 ,    t          j        |           S rN   r;  r   s     r6   r   zlogistic_gen._isfj  s    |r8   c                 B    dt           j        t           j        z  dz  ddfS )Nr   rI  g333333?r/  rj   s    r6   r   zlogistic_gen._statsm  s    "%+c/1g--r8   c                     dS r?  r   rj   s    r6   r   zlogistic_gen._entropyp  s    sr8   c                   
 |                     dd          r t                      j        g|R i |S t          | ||          \  }}t	                    |                               \  }}|                    d|          |                    d|          }}|ffd	
|ffd	
fd}|(|&t          j        
|f          }	|	j	        d         }|}nK|(|&t          j        |f          }	|	j	        d         }|}n!t          j        |||f          }	|	j	        \  }}t          |          }|	j        r||fn t                      j        g|R i |S )	Nr@  Fr.   r/   c                 l    | z
  |z  }t          j        t          j        |                    dz  z
  S r  )rP   r  rw   r8  )r.   r/   r  rF   rb   s      r6   dl_dlocz!logistic_gen.fit.<locals>.dl_dloc  s2    u$A6"(1++&&1,,r8   c                 r    |z
  | z  }t          j        |t          j        |dz            z            z
  S r  )rP   r  r2  )r/   r.   r  rF   rb   s      r6   	dl_dscalez#logistic_gen.fit.<locals>.dl_dscale  s6    u$A6!BGAaCLL.))A--r8   c                 >    | \  }} ||           ||          fS rN   r   )paramsr.   r/   r  r  s      r6   r_  zlogistic_gen.fit.<locals>.func  s/    JC73&&		%(=(===r8   r   )r3   rA   rC   rL  r  r  r=   r   rM  rq   r  success)rE   rF   rG   r5   r   r   r.   r/   r_  r  r  r  rb   r  s    `        @@@r6   rC   zlogistic_gen.fitt  s    88J&& 	4577;t3d333d3338t9=tE EdFII ^^D))
UXXeS))488GU+C+CU  & 	- 	- 	- 	- 	- 	- 	- "& 	. 	. 	. 	. 	. 	. 	.	> 	> 	> 	> 	> 	> $,-#00C%(CEE&.-	E844CE!HECC-sEl33CJC E

 # 6e UWW[555555	7r8   r  )r   r   r   r   rk   r   rr   r   ru   r   r~   ry   r   r   r   r   rK   r   r   rC   r  r  s   @r6   r  r  5  s        .  0 0 0 0' ' ', , ,               . . .   M**07 07 07 07 +* _07 07 07 07 07r8   r  r  c                   P    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )loggamma_gena  A log gamma continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `loggamma` is:

    .. math::

        f(x, c) = \frac{\exp(c x - \exp(x))}
                       {\Gamma(c)}

    for all :math:`x, c > 0`. Here, :math:`\Gamma` is the
    gamma function (`scipy.special.gamma`).

    `loggamma` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zloggamma_gen._shape_info  r  r8   Nc                     t          j        |                    |dz   |                    t          j        |                    |                    |z  z   S )Nr   r  )rP   r   r  r  r  s       r6   r   zloggamma_gen._rvs  sU     |))!a%d);;<<&--4-8899!;< 	=r8   c                     t          j        ||z  t          j        |          z
  t          j        |          z
            S rN   rP   r   rw   r  r  s      r6   rr   zloggamma_gen._pdf  s/    vac"&))mBJqMM1222r8   c                 `    ||z  t          j        |          z
  t          j        |          z
  S rN   r  r  s      r6   r   zloggamma_gen._logpdf  s%    sRVAYYA..r8   c                 B    t          |t          k     ||fd d           S )Nc                 `    t          j        || z  t          j        |dz             z
            S r^   r  r  s     r6   r  z#loggamma_gen._cdf.<locals>.<lambda>  s%    rvacBJqsOO.C'D'D r8   c                 P    t          j        |t          j        |                     S rN   )rw   r  rP   r   r  s     r6   r  z#loggamma_gen._cdf.<locals>.<lambda>  s    "+a*C*C r8   r  r   r#   r  s      r6   ru   zloggamma_gen._cdf  s7     !h,ADDCCE E E 	Er8   c                 n    t          j        ||          }t          |t          k     |||fd d           S )Nc                 `    t          j        |          t          j        |dz             z   |z  S r^   r  r  r}   r  s      r6   r  z#loggamma_gen._ppf.<locals>.<lambda>  s$    26!99rz!A#+F*I r8   c                 *    t          j        |           S rN   r2  r
  s      r6   r  z#loggamma_gen._ppf.<locals>.<lambda>      RVAYY r8   r  )rw   r  r   r"   rE   r}   r  r  s       r6   r~   zloggamma_gen._ppf  sF     N1a  !e)aAYII668 8 8 	8r8   c                 B    t          |t          k     ||fd d           S )Nc                 b    t          j        || z  t          j        |dz             z
             S r^   )rP   r  rw   r  r  s     r6   r  z"loggamma_gen._sf.<locals>.<lambda>  s(    1rz!A#1F(G(G'G r8   c                 P    t          j        |t          j        |                     S rN   )rw   r  rP   r   r  s     r6   r  z"loggamma_gen._sf.<locals>.<lambda>  s    ",q"&))*D*D r8   r  r  r  s      r6   ry   zloggamma_gen._sf  s5    !h,AGGDDF F F 	Fr8   c                 n    t          j        ||          }t          |t          k     |||fd d           S )Nc                 b    t          j        |           t          j        |dz             z   |z  S r^   )rP   r  rw   r  r
  s      r6   r  z#loggamma_gen._isf.<locals>.<lambda>  s&    28QB<<"*QqS//+I1*L r8   c                 *    t          j        |           S rN   r2  r
  s      r6   r  z#loggamma_gen._isf.<locals>.<lambda>  r  r8   r  )rw   r  r   r"   r  s       r6   r   zloggamma_gen._isf  sF     OAq!!!e)aAYLL668 8 8 	8r8   c                     t          j        |          }t          j        d|          }t          j        d|          t          j        |d          z  }t          j        d|          ||z  z  }||||fS )Nr   rU   r  r  )rw   r  	polygammarP   r  )rE   r  r   r  r0  excess_kurtosiss         r6   r   zloggamma_gen._stats  sm     z!}}l1a  <1%%c(:(::,q!,,C8S(O33r8   c                 B    d }d }t          |dk    |f||          }|S )Nc                 d    t          j        |           | t          j        |           z  z
  | z   }|S rN   )rw   r  r  )r  r  s     r6   r  z&loggamma_gen._entropy.<locals>.regular  s+    
1BJqMM 11A5AHr8   c                     dt          j        |           z  | dz  dz  z   | dz  dz  z
  | dz  dz  z   }t                                          |z   }|S )Nr)  rA  r  r  r  r     )rP   r   r  r   )r  termr  s      r6   rt  z)loggamma_gen._entropy.<locals>.asymptotic  sQ    q		>AsF1H,q#vby81c6#:ED$&AHr8   -   r  r  )rE   r  r  rt  r  s        r6   r   zloggamma_gen._entropy  sC    	 	 		 	 	 qBw@@@r8   r  r   r   r   r   rk   r   rr   r   ru   r~   ry   r   r   r   r   r8   r6   r  r    s         0E E E= = = =3 3 3/ / /E E E&8 8 8F F F8 8 84 4 4    r8   r  loggammac                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Ze ee           fd
                        Z xZS )loglaplace_genaT  A log-Laplace continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `loglaplace` is:

    .. math::

        f(x, c) = \begin{cases}\frac{c}{2} x^{ c-1}  &\text{for } 0 < x < 1\\
                               \frac{c}{2} x^{-c-1}  &\text{for } x \ge 1
                  \end{cases}

    for :math:`c > 0`.

    `loglaplace` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    Suppose a random variable ``X`` follows the Laplace distribution with
    location ``a`` and scale ``b``.  Then ``Y = exp(X)`` follows the
    log-Laplace distribution with ``c = 1 / b`` and ``scale = exp(a)``.

    References
    ----------
    T.J. Kozubowski and K. Podgorski, "A log-Laplace growth rate model",
    The Mathematical Scientist, vol. 28, pp. 49-60, 2003.

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zloglaplace_gen._shape_infoB  r  r8   c                 X    |dz  }t          j        |dk     ||           }|||dz
  z  z  S r  rP   rT  )rE   rq   r  cd2s       r6   rr   zloglaplace_gen._pdfE  s8     eHQUAr""1qs8|r8   c                 V    t          j        |dk     d||z  z  dd|| z  z  z
            S Nr   r   r#  r  s      r6   ru   zloglaplace_gen._cdfL  s0    xAs1a4x3qA2w;777r8   c                 V    t          j        |dk     dd||z  z  z
  d|| z  z            S r&  r#  r  s      r6   ry   zloglaplace_gen._sfO  s0    xAq3q!t8|SaR[999r8   c                 `    t          j        |dk     d|z  d|z  z  dd|z
  z  d|z  z            S Nr   r   r   rU   rA  r#  r  s      r6   r~   zloglaplace_gen._ppfR  s8    xC#a%3q5!1As1uIa3HIIIr8   c                 `    t          j        |dk    dd|z
  z  d|z  z  d|z  d|z  z            S r)  r#  r  s      r6   r   zloglaplace_gen._isfU  s7    xC#sQw-3q5!9AaC46?KKKr8   c                     t          j        d          5  |dz  |dz  }}t          j        ||k     |||z
  z  t           j                  cd d d            S # 1 swxY w Y   d S )Nr9  r:  rU   )rP   r<  rT  ri   )rE   rb   r  r  n2s        r6   r  zloglaplace_gen._munpX  s    [))) 	= 	=T1a4B8BGR27^RV<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=s   4AAAc                 6    t          j        d|z            dz   S ra  r2  r  s     r6   r   zloglaplace_gen._entropy]  s    vc!e}}s""r8   c                    t          | |||          \  }}}}|, t          t          |           |           j        |g|R i |S t	          j        ||k              rt          d|t          j                  |dk    r||z
  }t                              t	          j	        |          |t	          j	        |          nd |d|z  nd d          \  }}|}	|t	          j
        |          n|}
|d|z  n|}||	|
fS )N
loglaplacer  r   r   r;   )r   r   r1   )rL  rA   rB   rC   rP   r  rL  ri   r  r   r   )rE   rF   rG   r5   rN  r   r   r   r   r.   r/   r  r  s               r6   rC   zloglaplace_gen.fit`  s-    "=T4=A4"I "Ib$ <.5dT**.tCdCCCdCCC 6$$, 	G|4rvFFFF 199$;D {{26$<<282Dv$*,.!B$$d"'  ) )1 #^q			ZAEER#u}r8   )r   r   r   r   rk   rr   ru   ry   r~   r   r  r   rK   r   r   rC   r  r  s   @r6   r   r   !  s         @E E E  8 8 8: : :J J JL L L= = =
# # # M**    +* _    r8   r   r/  c                 J    t          | dk    | |fd t          j                   S )Nr   c                     t          j        |           dz   d|dz  z  z  t          j        || z  t          j        dt           j        z            z            z
  S r  )rP   r   r   r   rq   r  s     r6   r  z!_lognorm_logpdf.<locals>.<lambda>  sM    RVAYY\MQAX$>&(fQURWQY5G5G-G&H&H%I r8   r  r2  s     r6   _lognorm_logpdfr3    s3    a1fq!fJ Jvg  r8   c                        e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Ze eed           fd                        Z xZS )lognorm_gena  A lognormal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `lognorm` is:

    .. math::

        f(x, s) = \frac{1}{s x \sqrt{2\pi}}
                  \exp\left(-\frac{\log^2(x)}{2s^2}\right)

    for :math:`x > 0`, :math:`s > 0`.

    `lognorm` takes ``s`` as a shape parameter for :math:`s`.

    %(after_notes)s

    Suppose a normally distributed random variable ``X`` has  mean ``mu`` and
    standard deviation ``sigma``. Then ``Y = exp(X)`` is lognormally
    distributed with ``s = sigma`` and ``scale = exp(mu)``.

    %(example)s

    The logarithm of a log-normally distributed random variable is
    normally distributed:

    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from scipy import stats
    >>> fig, ax = plt.subplots(1, 1)
    >>> mu, sigma = 2, 0.5
    >>> X = stats.norm(loc=mu, scale=sigma)
    >>> Y = stats.lognorm(s=sigma, scale=np.exp(mu))
    >>> x = np.linspace(*X.interval(0.999))
    >>> y = Y.rvs(size=10000)
    >>> ax.plot(x, X.pdf(x), label='X (pdf)')
    >>> ax.hist(np.log(y), density=True, bins=x, label='log(Y) (histogram)')
    >>> ax.legend()
    >>> plt.show()

    c                 @    t          dddt          j        fd          gS )Nr  Fr   r
  rh   rj   s    r6   rk   zlognorm_gen._shape_info  r  r8   Nc                 V    t          j        ||                    |          z            S rN   rP   r   r   )rE   r  r   r   s       r6   r   zlognorm_gen._rvs  s%    va,66t<<<===r8   c                 R    t          j        |                     ||                    S rN   r  rE   rq   r  s      r6   rr   zlognorm_gen._pdf  r  r8   c                 "    t          ||          S rN   r3  r:  s      r6   r   zlognorm_gen._logpdf  s    q!$$$r8   c                 J    t          t          j        |          |z            S rN   r   rP   r   r:  s      r6   ru   zlognorm_gen._cdf  s    Q'''r8   c                 J    t          t          j        |          |z            S rN   r  r:  s      r6   r   zlognorm_gen._logcdf  s    BF1IIM***r8   c                 J    t          j        |t          |          z            S rN   rP   r   r   rE   r}   r  s      r6   r~   zlognorm_gen._ppf      va)A,,&'''r8   c                 J    t          t          j        |          |z            S rN   r   rP   r   r:  s      r6   ry   zlognorm_gen._sf  s    q		A&&&r8   c                 J    t          t          j        |          |z            S rN   )r   rP   r   r:  s      r6   r   zlognorm_gen._logsf  s    26!99q=)))r8   c                 J    t          j        |t          |          z            S rN   rP   r   r   rB  s      r6   r   zlognorm_gen._isf  rC  r8   c                     t          j        ||z            }t          j        |          }||dz
  z  }t          j        |dz
            d|z   z  }t          j        g d|          }||||fS Nr   rU   )r   rU   r  r   r  )rP   r   r   polyval)rE   r  r  rD  rE  rF  rG  s          r6   r   zlognorm_gen._stats  sm    F1Q3KKWQZZ1gWQqS\\1Q3Z***A..3Br8   c                     ddt          j        dt           j        z            z   dt          j        |          z  z   z  S Nr   r   rU   r   )rE   r  s     r6   r   zlognorm_gen._entropy  s1    a"&25//)Aq		M9::r8   aF          When `method='MLE'` and
        the location parameter is fixed by using the `floc` argument,
        this function uses explicit formulas for the maximum likelihood
        estimation of the log-normal shape and scale parameters, so the
        `optimizer`, `loc` and `scale` keyword arguments are ignored.
        If the location is free, a likelihood maximum is found by
        setting its partial derivative wrt to location to 0, and
        solving by substituting the analytical expressions of shape
        and scale (or provided parameters).
        See, e.g., equation 3.1 in
        A. Clifford Cohen & Betty Jones Whitten (1980)
        Estimation in the Three-Parameter Lognormal Distribution,
        Journal of the American Statistical Association, 75:370, 399-404
        https://doi.org/10.2307/2287466
        

r   c                 P    |                     dd          r t                      j        g|R i |S t           ||          }|\  }t	          j                  }fdfd} fd}|;t	          j        |          }	||	z
  }
 ||
          } ||
          }d|	z  }|dk    r||z
  }
 ||
          }|dz  }|dk    t	          j        |
          rt	          j        |          s t                      j        g|R i |S t	          j        t	          j	        |
t          j
                   |
dz
            } ||          }d|
|z
  z  }t	          j        |          rt	          j        |          rt	          j        |          t	          j        |          k    rg|
|z
  } ||          }|dz  }t	          j        |          r>t	          j        |          r*t	          j        |          t	          j        |          k    gt	          j        |          rt	          j        |          s t                      j        g|R i |S t          |||
f	          }|j        s t                      j        g|R i |S  ||j                  }||k    r|j        n||	z
  }n$||k    rt          d
dt          j
                  |} |          \  }}                     |          r|dk    s t                      j        g|R i |S |||fS )Nr@  Fc                    t          j        | z
            }p%t          j        |                                          }p=t          j        t          j        |t          j        |          z
  dz                      }||fS r  )rP   r   r   r   r   )r.   lndatar/   r  rF   r   fshapes       r6   get_shape_scalez(lognorm_gen.fit.<locals>.get_shape_scale  sw     ~s
++3bfV[[]]33EKbgbgvu/E.I&J&JKKE%<r8   c                      |           \  }}| z
  }t          j        dt          j        ||z            |dz  z  z   |z            S r1  rP   r  r   )r.   r  r/   shiftedrF   rR  s       r6   dL_dLocz lognorm_gen.fit.<locals>.dL_dLoc  sP    *?3//LE5SjG61rvgem44UAX==wFGGGr8   c                 T     |           \  }}                     || |f           S rN   )nnlf)r.   r  r/   rF   rR  rE   s      r6   llzlognorm_gen.fit.<locals>.ll  s4    *?3//LE5IIuc5148888r8   rU   gưr   r$  lognormr   r  r   )r3   rA   rC   rL  rP   r  spacingr   r  	nextafterri   rQ   r+   	convergedrM  rL  rc   )rE   rF   rG   r5   
parametersr   r  rV  rY  r[  rS   dL_dLoc_rbrack	ll_rbrackr'  rR   dL_dLoc_lbrackr  ll_rootr.   r  r/   r   rQ  rR  r  s   ``                   @@@r6   rC   zlognorm_gen.fit  s   $ 88J&& 	4577;t3d333d3330tT4HH
%/"fdF6$<<	  	  	  	  	  	  	 	H 	H 	H 	H 	H 	H	9 	9 	9 	9 	9 	9 	9
 < j**G'F %WV__N6

IKE E))!E)!(
 !E))
 ;v&& 8bk..I.I 8 #uww{47$777$777
 ZVbfW = =vaxHHF$WV__N&)E;v&& 2;~+F+F w~.."'.2I2III%!(
	 ;v&& 2;~+F+F w~.."'.2I2III ;v&& 8bk..I.I 8"uww{47$777$777 g/?@@@C= 8"uww{47$777$777
 bllG%	11#((x7GCC x"9BbfEEEEC&s++uu%% 	4%!))577;t3d333d333c5  r8   r  )r   r   r   r   r   r  r  rk   r   rr   r   ru   r   r~   ry   r   r   r   r   rK   r	   rC   r  r  s   @r6   r5  r5    sD       * *V "4ME E E> > > >* * *% % %( ( (+ + +( ( (' ' '* * *( ( (  ; ; ; } 5    Z! Z! Z! Z!!  _"Z! Z! Z! Z! Z!r8   r5  rZ  c                   ^    e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 Zd Zd ZdS )
gibrat_gena[  A Gibrat continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `gibrat` is:

    .. math::

        f(x) = \frac{1}{x \sqrt{2\pi}} \exp(-\frac{1}{2} (\log(x))^2)

    for :math:`x >= 0`.

    `gibrat` is a special case of `lognorm` with ``s=1``.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zgibrat_gen._shape_infol  r   r8   Nc                 P    t          j        |                    |                    S rN   r8  r   s      r6   r   zgibrat_gen._rvso  s     vl22488999r8   c                 P    t          j        |                     |                    S rN   r  r   s     r6   rr   zgibrat_gen._pdfr  r  r8   c                 "    t          |d          S r  r<  r   s     r6   r   zgibrat_gen._logpdfv  s    q#&&&r8   c                 D    t          t          j        |                    S rN   r>  r   s     r6   ru   zgibrat_gen._cdfy  s    ###r8   c                 D    t          j        t          |                    S rN   rA  r   s     r6   r~   zgibrat_gen._ppf|      vill###r8   c                 D    t          t          j        |                    S rN   rE  r   s     r6   ry   zgibrat_gen._sf  s    q		"""r8   c                 D    t          j        t          |                    S rN   rH  r
  s     r6   r   zgibrat_gen._isf  rk  r8   c                     t           j        }t          j        |          }||dz
  z  }t          j        |dz
            d|z   z  }t          j        g d|          }||||fS rJ  )rP   er   rK  )rE   r  rD  rE  rF  rG  s         r6   r   zgibrat_gen._stats  sc    DWQZZ1q5kWQU^^q1u%Z***A..3Br8   c                 P    dt          j        dt           j        z            z  dz   S r  r   rj   s    r6   r   zgibrat_gen._entropy  s"    RVAI&&&,,r8   r  )r   r   r   r   r   r  r  rk   r   rr   r   ru   r~   ry   r   r   r   r   r8   r6   rd  rd  T  s         * "4M  : : : :' ' '' ' '$ $ $$ $ $# # #$ $ $  - - - - -r8   rd  gibratc                   P    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )maxwell_gena  A Maxwell continuous random variable.

    %(before_notes)s

    Notes
    -----
    A special case of a `chi` distribution,  with ``df=3``, ``loc=0.0``,
    and given ``scale = a``, where ``a`` is the parameter used in the
    Mathworld description [1]_.

    The probability density function for `maxwell` is:

    .. math::

        f(x) = \sqrt{2/\pi}x^2 \exp(-x^2/2)

    for :math:`x >= 0`.

    %(after_notes)s

    References
    ----------
    .. [1] http://mathworld.wolfram.com/MaxwellDistribution.html

    %(example)s
    c                     g S rN   r   rj   s    r6   rk   zmaxwell_gen._shape_info  r   r8   Nc                 <    t                               d||          S )NrI  r  r  r  r   s      r6   r   zmaxwell_gen._rvs  s    wwsLwAAAr8   c                 T    t           |z  |z  t          j        | |z  dz            z  S r?  )r'   rP   r   r   s     r6   rr   zmaxwell_gen._pdf  s+    q "261"Q$s(#3#333r8   c                     t          j        d          5  t          dt          j        |          z  z   d|z  |z  z
  cd d d            S # 1 swxY w Y   d S )Nr9  r:  rU   r   )rP   r<  r)   r   r   s     r6   r   zmaxwell_gen._logpdf  s    [))) 	? 	?&26!994s1uQw>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   (AAAc                 8    t          j        d||z  dz            S Nr  r   r  r   s     r6   ru   zmaxwell_gen._cdf  s    {3!C(((r8   c                 V    t          j        dt          j        d|          z            S r  r  r   s     r6   r~   zmaxwell_gen._ppf  s#    wqQ///000r8   c                 8    t          j        d||z  dz            S rz  r  r   s     r6   ry   zmaxwell_gen._sf  s    |C1S)))r8   c                 V    t          j        dt          j        d|          z            S r  r  r   s     r6   r   zmaxwell_gen._isf  s#    wqa000111r8   c                 R   dt           j        z  dz
  }dt          j        dt           j        z            z  ddt           j        z  z
  t          j        d          ddt           j        z  z
  z  |dz  z  dt           j        z  t           j        z  d	t           j        z  z   d
z
  |dz  z  fS )Nr  r.  rU   r       r  r  r     i  rP   r   r   rE   r}  s     r6   r   zmaxwell_gen._stats  s    gai"'#be)$$$!BE'	

Br"%xK(c1RU253ru9,s2c3h>@ 	@r8   c                 `    t           dt          j        dt          j        z            z  z   dz
  S r  )r$   rP   r   r   rj   s    r6   r   zmaxwell_gen._entropy  s%    BF1RU7OO++C//r8   r  r  r   r8   r6   rs  rs    s         4  B B B B4 4 4? ? ?
) ) )1 1 1* * *2 2 2@ @ @0 0 0 0 0r8   rs  maxwellc                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	
mielke_gena  A Mielke Beta-Kappa / Dagum continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `mielke` is:

    .. math::

        f(x, k, s) = \frac{k x^{k-1}}{(1+x^s)^{1+k/s}}

    for :math:`x > 0` and :math:`k, s > 0`. The distribution is sometimes
    called Dagum distribution ([2]_). It was already defined in [3]_, called
    a Burr Type III distribution (`burr` with parameters ``c=s`` and
    ``d=k/s``).

    `mielke` takes ``k`` and ``s`` as shape parameters.

    %(after_notes)s

    References
    ----------
    .. [1] Mielke, P.W., 1973 "Another Family of Distributions for Describing
           and Analyzing Precipitation Data." J. Appl. Meteor., 12, 275-280
    .. [2] Dagum, C., 1977 "A new model for personal income distribution."
           Economie Appliquee, 33, 327-367.
    .. [3] Burr, I. W. "Cumulative frequency functions", Annals of
           Mathematical Statistics, 13(2), pp 215-232 (1942).

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )Nr  Fr   r
  r  rh   )rE   iki_ss      r6   rk   zmielke_gen._shape_info  >    UQK@@ea[.AACyr8   c                 B    |||dz
  z  z  d||z  z   d|dz  |z  z   z  z  S r  r   rE   rq   r  r  s       r6   rr   zmielke_gen._pdf  s2    QsU|s1a4x3quQw;777r8   c                     t          j        d          5  t          j        |          t          j        |          |dz
  z  z   t          j        ||z            d||z  z   z  z
  cd d d            S # 1 swxY w Y   d S )Nr9  r:  r   )rP   r<  r   r  r  s       r6   r   zmielke_gen._logpdf  s    [))) 	L 	L6!99rvayy!a%0028AqD>>1qs73KK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   AA33A7:A7c                 0    ||z  d||z  z   |dz  |z  z  z  S r  r   r  s       r6   ru   zmielke_gen._cdf  s&    !ts1a4x1S57+++r8   c                 `    t          ||dz  |z            }t          |d|z
  z  d|z            S r  r9  )rE   r}   r  r  qsks        r6   r~   zmielke_gen._ppf
  s3    !QsU1Woo3C=#a%(((r8   c                 N    d }t          ||k     |||f|t          j                  S )Nc                     t          j        || z   |z            t          j        d| |z  z
            z  t          j        ||z            z  S r^   ro  )rb   r  r  s      r6   rV  z$mielke_gen._munp.<locals>.nth_moment  s@    8QqS!G$$RXa!e__4RXac]]BBr8   r  )rE   rb   r  r  rV  s        r6   r  zmielke_gen._munp  s6    	C 	C 	C !a%!QJ???r8   N)
r   r   r   r   rk   rr   r   ru   r~   r  r   r8   r6   r  r    s           B  
8 8 8L L L
, , ,) ) )@ @ @ @ @r8   r  mielkec                   T    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )
kappa4_genap  Kappa 4 parameter distribution.

    %(before_notes)s

    Notes
    -----
    The probability density function for kappa4 is:

    .. math::

        f(x, h, k) = (1 - k x)^{1/k - 1} (1 - h (1 - k x)^{1/k})^{1/h-1}

    if :math:`h` and :math:`k` are not equal to 0.

    If :math:`h` or :math:`k` are zero then the pdf can be simplified:

    h = 0 and k != 0::

        kappa4.pdf(x, h, k) = (1.0 - k*x)**(1.0/k - 1.0)*
                              exp(-(1.0 - k*x)**(1.0/k))

    h != 0 and k = 0::

        kappa4.pdf(x, h, k) = exp(-x)*(1.0 - h*exp(-x))**(1.0/h - 1.0)

    h = 0 and k = 0::

        kappa4.pdf(x, h, k) = exp(-x)*exp(-exp(-x))

    kappa4 takes :math:`h` and :math:`k` as shape parameters.

    The kappa4 distribution returns other distributions when certain
    :math:`h` and :math:`k` values are used.

    +------+-------------+----------------+------------------+
    | h    | k=0.0       | k=1.0          | -inf<=k<=inf     |
    +======+=============+================+==================+
    | -1.0 | Logistic    |                | Generalized      |
    |      |             |                | Logistic(1)      |
    |      |             |                |                  |
    |      | logistic(x) |                |                  |
    +------+-------------+----------------+------------------+
    |  0.0 | Gumbel      | Reverse        | Generalized      |
    |      |             | Exponential(2) | Extreme Value    |
    |      |             |                |                  |
    |      | gumbel_r(x) |                | genextreme(x, k) |
    +------+-------------+----------------+------------------+
    |  1.0 | Exponential | Uniform        | Generalized      |
    |      |             |                | Pareto           |
    |      |             |                |                  |
    |      | expon(x)    | uniform(x)     | genpareto(x, -k) |
    +------+-------------+----------------+------------------+

    (1) There are at least five generalized logistic distributions.
        Four are described here:
        https://en.wikipedia.org/wiki/Generalized_logistic_distribution
        The "fifth" one is the one kappa4 should match which currently
        isn't implemented in scipy:
        https://en.wikipedia.org/wiki/Talk:Generalized_logistic_distribution
        https://www.mathwave.com/help/easyfit/html/analyses/distributions/gen_logistic.html
    (2) This distribution is currently not in scipy.

    References
    ----------
    J.C. Finney, "Optimization of a Skewed Logistic Distribution With Respect
    to the Kolmogorov-Smirnov Test", A Dissertation Submitted to the Graduate
    Faculty of the Louisiana State University and Agricultural and Mechanical
    College, (August, 2004),
    https://digitalcommons.lsu.edu/gradschool_dissertations/3672

    J.R.M. Hosking, "The four-parameter kappa distribution". IBM J. Res.
    Develop. 38 (3), 25 1-258 (1994).

    B. Kumphon, A. Kaew-Man, P. Seenoi, "A Rainfall Distribution for the Lampao
    Site in the Chi River Basin, Thailand", Journal of Water Resource and
    Protection, vol. 4, 866-869, (2012).
    :doi:`10.4236/jwarp.2012.410101`

    C. Winchester, "On Estimation of the Four-Parameter Kappa Distribution", A
    Thesis Submitted to Dalhousie University, Halifax, Nova Scotia, (March
    2000).
    http://www.nlc-bnc.ca/obj/s4/f2/dsk2/ftp01/MQ57336.pdf

    %(after_notes)s

    %(example)s

    c                 n    t          j        ||          d         j        }t          j        |d          S )Nr   T
fill_value)rP   r  r  full)rE   r  r  r  s       r6   rc   zkappa4_gen._argcheckr  s1    #Aq))!,2wu....r8   c                     t          ddt          j         t          j        fd          }t          ddt          j         t          j        fd          }||gS )Nr  Fr
  r  rh   )rE   ihr  s      r6   rk   zkappa4_gen._shape_infov  sG    UbfWbf$5~FFUbfWbf$5~FFBxr8   c           
         t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk               t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk               g}d }d }d }d }t          |||||||g||gt           j                  }d }d }t          |||||||g||gt           j                  }	||	fS )	Nr   c                 :    dt          j        | |           z
  |z  S r  )rP   r  r  r  s     r6   r  z#kappa4_gen._get_support.<locals>.f0  s     ".QB///22r8   c                 *    t          j        |           S rN   r2  r  s     r6   r  z#kappa4_gen._get_support.<locals>.f1  s    6!99r8   c                 v    t          j        t          j        |                     }t           j         |d d <   |S rN   rP   r  r  ri   r  r  r   s      r6   f3z#kappa4_gen._get_support.<locals>.f3  s/    !%%AF7AaaaDHr8   c                     d|z  S r  r   r  s     r6   f5z#kappa4_gen._get_support.<locals>.f5      q5Lr8   defaultc                     d|z  S r  r   r  s     r6   r  z#kappa4_gen._get_support.<locals>.f0  r  r8   c                 t    t          j        t          j        |                     }t           j        |d d <   |S rN   r  r  s      r6   r  z#kappa4_gen._get_support.<locals>.f1  s-    !%%A6AaaaDHr8   rP   r  r   r  )
rE   r  r  condlistr  r  r  r  r  r  s
             r6   r   zkappa4_gen._get_support{  s`   N1q5!a%00N1q5!q&11N1q5!a%00N161q511N161622N161q5113	3 	3 	3	 	 		 	 	
	 	 	 b"b"b1Q!#) ) )
	 	 		 	 	
 b"b"b1Q!#) ) ) 2vr8   c                 T    t          j        |                     |||                    S rN   r  rE   rq   r  r  s       r6   rr   zkappa4_gen._pdf  r  r8   c                 F   t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk              g}d }d }d }d }t          |||||g|||gt           j                  S )Nr   c                     t          j        d|z  dz
  | | z            t          j        d|z  dz
  | d|| z  z
  d|z  z  z            z   S )zpdf = (1.0 - k*x)**(1.0/k - 1.0)*(
                      1.0 - h*(1.0 - k*x)**(1.0/k))**(1.0/h-1.0)
               logpdf = ...
            r   rk  rq   r  r  s      r6   r  zkappa4_gen._logpdf.<locals>.f0  s\    
 Js1us{QBqD11Js1us{QBac	SU/C,CDDE Fr8   c                 ^    t          j        d|z  dz
  | | z            d|| z  z
  d|z  z  z
  S )z~pdf = (1.0 - k*x)**(1.0/k - 1.0)*np.exp(-(
                      1.0 - k*x)**(1.0/k))
               logpdf = ...
            r   rk  r  s      r6   r  zkappa4_gen._logpdf.<locals>.f1  s:    
 :c!eckA2a400C!A#IQ3GGGr8   c                 n    |  t          j        d|z  dz
  | t          j        |            z            z   S )z]pdf = np.exp(-x)*(1.0 - h*np.exp(-x))**(1.0/h - 1.0)
               logpdf = ...
            r   )rw   rx  rP   r   r  s      r6   r  zkappa4_gen._logpdf.<locals>.f2  s5     2
3q53;261"::>>>>r8   c                 4    |  t          j        |            z
  S )zDpdf = np.exp(-x-np.exp(-x))
               logpdf = ...
            rz  r  s      r6   r  zkappa4_gen._logpdf.<locals>.f3  s     2r

?"r8   r  r  	rE   rq   r  r  r  r  r  r  r  s	            r6   r   zkappa4_gen._logpdf  s    N161622N161622N161622N1616224
	F 	F 	F	H 	H 	H	? 	? 	?	# 	# 	# 8B+q!9#%6+ + + 	+r8   c                 T    t          j        |                     |||                    S rN   rT  r  s       r6   ru   zkappa4_gen._cdf  r]  r8   c                 F   t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk              g}d }d }d }d }t          |||||g|||gt           j                  S )Nr   c                 V    d|z  t          j        | d|| z  z
  d|z  z  z            z  S )zVcdf = (1.0 - h*(1.0 - k*x)**(1.0/k))**(1.0/h)
               logcdf = ...
            r   r  r  s      r6   r  zkappa4_gen._logcdf.<locals>.f0  s5     E28QBac	SU';$;<<<<r8   c                      d|| z  z
  d|z  z   S )zLcdf = np.exp(-(1.0 - k*x)**(1.0/k))
               logcdf = ...
            r   r   r  s      r6   r  zkappa4_gen._logcdf.<locals>.f1  s     1Q3Y#a%(((r8   c                 d    d|z  t          j        | t          j        |            z            z  S )zLcdf = (1.0 - h*np.exp(-x))**(1.0/h)
               logcdf = ...
            r   )rw   r  rP   r   r  s      r6   r  zkappa4_gen._logcdf.<locals>.f2  s-     E28QBrvqbzzM2222r8   c                 .    t          j        |             S )zBcdf = np.exp(-np.exp(-x))
               logcdf = ...
            rz  r  s      r6   r  zkappa4_gen._logcdf.<locals>.f3  s     FA2JJ;r8   r  r  r  s	            r6   r   zkappa4_gen._logcdf  s    N161622N161622N161622N1616224
	= 	= 	=	) 	) 	)	3 	3 	3	 	 	 8B+q!9#%6+ + + 	+r8   c                 F   t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk              t          j        |dk    |dk              g}d }d }d }d }t          |||||g|||gt           j                  S )Nr   c                 0    d|z  dd| |z  z
  |z  |z  z
  z  S r  r   r}   r  r  s      r6   r  zkappa4_gen._ppf.<locals>.f0  s(    q5##A,!1A 5566r8   c                 D    d|z  dt          j        |            |z  z
  z  S r  r2  r  s      r6   r  zkappa4_gen._ppf.<locals>.f1  s$    q5#"&))a/00r8   c                 ^    t          j        | |z              t          j        |          z   S )z,ppf = -np.log((1.0 - (q**h))/h)
            r  r  s      r6   r  zkappa4_gen._ppf.<locals>.f2  s*     Hq!tW%%%q		11r8   c                 R    t          j        t          j        |                       S rN   r2  r  s      r6   r  zkappa4_gen._ppf.<locals>.f3  s    FBF1II:&&&&r8   r  r  )	rE   r}   r  r  r  r  r  r  r  s	            r6   r~   zkappa4_gen._ppf  s    N161622N161622N161622N1616224
	7 	7 	7	1 	1 	1	2 	2 	2
	' 	' 	' 8B+q!9#%6+ + + 	+r8   c                     t          j        |dk     |dk              |dk     g}d }d }t          |||g||gd          S )Nr   c                 B    d| z  |z                       t                    S rD  astyper  r  s     r6   r  z&kappa4_gen._get_stats_info.<locals>.f0  s    F1H$$S)))r8   c                 <    d|z                       t                    S rD  r  r  s     r6   r  z&kappa4_gen._get_stats_info.<locals>.f1  s    F??3'''r8   rH  r  )rP   r  r   )rE   r  r  r  r  r  s         r6   _get_stats_infozkappa4_gen._get_stats_info  sf    N1q5!q&))E

	* 	* 	*	( 	( 	( 8b"X1vqAAAAr8   c                 |    |                      ||          fdt          dd          D             }|d d          S )Nc                 \    g | ](}t          j        |k               rd nt           j        )S rN   rP   r  r  )r  r  maxrs     r6   r  z%kappa4_gen._stats.<locals>.<listcomp>  s2    MMMA26!d(++744MMMr8   r   rH  )r  r  )rE   r  r  outputsr  s       @r6   r   zkappa4_gen._stats  sG    ##Aq))MMMMq!MMMqqqzr8   c                     |                      |d         |d                   }||k    rt          j        S t          j        | j        dd|f|z             d         S Nr   r   rN  )r  rP   r  r   r  _mom_integ1)rE   rD  rG   r  s       r6   _mom1_sczkappa4_gen._mom1_sc!  sV    ##DGT!W55996M~d.1A49EEEaHHr8   N)r   r   r   r   rc   rk   r   rr   r   ru   r   r~   r  r   r  r   r8   r6   r  r    s        W Wp/ / /  
' ' 'R- - -
$+ $+ $+L- - -!+ !+ !+F+ + +2B B B  
I I I I Ir8   r  kappa4c                   L     e Zd ZdZd Zd Zd Z fdZd Zd Z	d Z
d	 Z xZS )

kappa3_gena*  Kappa 3 parameter distribution.

    %(before_notes)s

    Notes
    -----
    The probability density function for `kappa3` is:

    .. math::

        f(x, a) = a (a + x^a)^{-(a + 1)/a}

    for :math:`x > 0` and :math:`a > 0`.

    `kappa3` takes ``a`` as a shape parameter for :math:`a`.

    References
    ----------
    P.W. Mielke and E.S. Johnson, "Three-Parameter Kappa Distribution Maximum
    Likelihood and Likelihood Ratio Tests", Methods in Weather Research,
    701-707, (September, 1973),
    :doi:`10.1175/1520-0493(1973)101<0701:TKDMLE>2.3.CO;2`

    B. Kumphon, "Maximum Entropy and Maximum Likelihood Estimation for the
    Three-Parameter Kappa Distribution", Open Journal of Statistics, vol 2,
    415-419 (2012), :doi:`10.4236/ojs.2012.24050`

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r	  rh   rj   s    r6   rk   zkappa3_gen._shape_infoL  r  r8   c                 *    ||||z  z   d|z  dz
  z  z  S r@  r   r  s      r6   rr   zkappa3_gen._pdfO  s"    !ad(d1fQh'''r8   c                 $    ||||z  z   d|z  z  z  S rD  r   r  s      r6   ru   zkappa3_gen._cdfS  s    !ad(d1f%%%r8   c           	      X   t          j        ||          \  }}t                                          ||          }d}||k     }t	          j        t	          j        d||         z  ||         ||         ||          z  z                       }||k    }||         |         ||<   |||<   |S )Ng{Gz?rA  )rP   r  rA   ry   rw   r  rx  )	rE   rq   r   sfcutoffr  sf2i2r  s	           r6   ry   zkappa3_gen._sfV  s    "1a((1WW[[A
 Kx
4!A$;!qtadU{0BCCDDD6\Q%)B1	r8   c                 &    ||| z  dz
  z  d|z  z  S r  r   r  s      r6   r~   zkappa3_gen._ppff  s    1qb53;3q5))r8   c                 n    t          j        | |           }t          j        |          }||z  d|z  z  S r  rE  )rE   r}   r   lgr  s        r6   r   zkappa3_gen._isfi  s7    ZQBE	S1W%%r8   c                 P    fdt          dd          D             }|d d          S )Nc                 \    g | ](}t          j        |k               rd nt           j        )S rN   r  )r  r  r   s     r6   r  z%kappa3_gen._stats.<locals>.<listcomp>o  s0    JJJ26!a%==444bfJJJr8   r   rH  )r  )rE   r   r  s    ` r6   r   zkappa3_gen._statsn  s2    JJJJeAqkkJJJqqqzr8   c                     t          j        ||d         k              rt           j        S t          j        | j        dd|f|z             d         S r  )rP   r  r  r   r  r  )rE   rD  rG   s      r6   r  zkappa3_gen._mom1_scr  sJ    6!tAw, 	6M~d.1A49EEEaHHr8   )r   r   r   r   rk   rr   ru   ry   r~   r   r   r  r  r  s   @r6   r  r  +  s         @E E E( ( (& & &     * * *& & &
  I I I I I I Ir8   r  kappa3c                   D    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 ZdS )	moyal_gena  A Moyal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `moyal` is:

    .. math::

        f(x) = \exp(-(x + \exp(-x))/2) / \sqrt{2\pi}

    for a real number :math:`x`.

    %(after_notes)s

    This distribution has utility in high-energy physics and radiation
    detection. It describes the energy loss of a charged relativistic
    particle due to ionization of the medium [1]_. It also provides an
    approximation for the Landau distribution. For an in depth description
    see [2]_. For additional description, see [3]_.

    References
    ----------
    .. [1] J.E. Moyal, "XXX. Theory of ionization fluctuations",
           The London, Edinburgh, and Dublin Philosophical Magazine
           and Journal of Science, vol 46, 263-280, (1955).
           :doi:`10.1080/14786440308521076` (gated)
    .. [2] G. Cordeiro et al., "The beta Moyal: a useful skew distribution",
           International Journal of Research and Reviews in Applied Sciences,
           vol 10, 171-192, (2012).
           http://www.arpapress.com/Volumes/Vol10Issue2/IJRRAS_10_2_02.pdf
    .. [3] C. Walck, "Handbook on Statistical Distributions for
           Experimentalists; International Report SUF-PFY/96-01", Chapter 26,
           University of Stockholm: Stockholm, Sweden, (2007).
           http://www.stat.rice.edu/~dobelman/textfiles/DistributionsHandbook.pdf

    .. versionadded:: 1.1.0

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zmoyal_gen._shape_info  r   r8   Nc                 h    t                               dd||          }t          j        |           S )Nr   rU   )r   r/   r   r   )r  r  rP   r   )rE   r   r   r  s       r6   r   zmoyal_gen._rvs  s3    YYAD$0  2 2r

{r8   c                     t          j        d|t          j        |           z   z            t          j        dt           j        z            z  S Nr)  rU   )rP   r   r   r   r   s     r6   rr   zmoyal_gen._pdf  s:    vda"&!**n-..251A1AAAr8   c                 ~    t          j        t          j        d|z            t          j        d          z            S r  )rw   r  rP   r   r   r   s     r6   ru   zmoyal_gen._cdf  s-    wrvdQh''"'!**4555r8   c                 ~    t          j        t          j        d|z            t          j        d          z            S r  )rw   r%  rP   r   r   r   s     r6   ry   zmoyal_gen._sf  s-    vbfTAX&&3444r8   c                 \    t          j        dt          j        |          dz  z             S r  )rP   r   rw   erfcinvr   s     r6   r~   zmoyal_gen._ppf  s'    q2:a==!++,,,,r8   c                     t          j        d          t           j        z   }t           j        dz  dz  }dt          j        d          z  t          j        d          z  t           j        dz  z  }d}||||fS )NrU      r  rO  )rP   r   euler_gammar   r   rw   r  rC  s        r6   r   zmoyal_gen._stats  sa    VAYY'eQhl"'!**_rwqzz)BE1H43Br8   c                 b   |dk    r!t          j        d          t           j        z   S |dk    r7t           j        dz  dz  t          j        d          t           j        z   dz  z   S |dk    rwdt           j        dz  z  t          j        d          t           j        z   z  }t          j        d          t           j        z   dz  }dt	          j        d          z  }||z   |z   S |dk    rd	t	          j        d          z  t          j        d          t           j        z   z  }dt           j        dz  z  t          j        d          t           j        z   dz  z  }t          j        d          t           j        z   d
z  }dt           j        d
z  z  d
z  }||z   |z   |z   S |                     |          S )Nr   rU   r   rI  r  r  r  rO  8   r$  r  )rP   r   r  r   rw   r  r  )rE   rb   tmp1r  tmp3tmp4s         r6   r  zmoyal_gen._munp  sc   886!99r~--#XX5!8a<26!99r~#="AAA#XX>RVAYYr~%=>DF1IIbn,q0D

?D$;%%#XXBGAJJ&"&))bn*DEDruax<26!99r~#="AADF1II.2Druax<!#D$;%,, ==###r8   r  )r   r   r   r   rk   r   rr   ru   ry   r~   r   r  r   r8   r6   r  r  {  s        ) )T     
B B B6 6 65 5 5- - -  $ $ $ $ $r8   r  moyalc                   ^    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZddZddZdS )nakagami_gena`  A Nakagami continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `nakagami` is:

    .. math::

        f(x, \nu) = \frac{2 \nu^\nu}{\Gamma(\nu)} x^{2\nu-1} \exp(-\nu x^2)

    for :math:`x >= 0`, :math:`\nu > 0`. The distribution was introduced in
    [2]_, see also [1]_ for further information.

    `nakagami` takes ``nu`` as a shape parameter for :math:`\nu`.

    %(after_notes)s

    References
    ----------
    .. [1] "Nakagami distribution", Wikipedia
           https://en.wikipedia.org/wiki/Nakagami_distribution
    .. [2] M. Nakagami, "The m-distribution - A general formula of intensity
           distribution of rapid fading", Statistical methods in radio wave
           propagation, Pergamon Press, 1960, 3-36.
           :doi:`10.1016/B978-0-08-009306-2.50005-4`

    %(example)s

    c                     |dk    S r7  r   )rE   nus     r6   rc   znakagami_gen._argcheck  s    Avr8   c                 @    t          dddt          j        fd          gS )Nr  Fr   r
  rh   rj   s    r6   rk   znakagami_gen._shape_info  r  r8   c                 R    t          j        |                     ||                    S rN   r  rE   rq   r  s      r6   rr   znakagami_gen._pdf   r  r8   c                     t          j        d          t          j        ||          z   t          j        |          z
  t          j        d|z  dz
  |          z   ||dz  z  z
  S r  )rP   r   rw   ry  r  r  s      r6   r   znakagami_gen._logpdf  s^     q		BHR,,,rz"~~=21%%&(*1a40 	1r8   c                 8    t          j        |||z  |z            S rN   r  r  s      r6   ru   znakagami_gen._cdf	  s    {2r!tAv&&&r8   c                 \    t          j        d|z  t          j        ||          z            S r  r  )rE   r}   r  s      r6   r~   znakagami_gen._ppf  s'    ws2vbnR333444r8   c                 8    t          j        |||z  |z            S rN   r  r  s      r6   ry   znakagami_gen._sf  s    |B1Q'''r8   c                 \    t          j        d|z  t          j        ||          z            S r^   r  )rE   r  r  s      r6   r   znakagami_gen._isf  s'    wqtbob!444555r8   c                 "   t          j        |d          t          j        |          z  }d||z  z
  }|dd|z  |z  z
  z  dz  |z  t          j        |d          z  }d|dz  z  |z  d|z  d	z
  |d	z  z  z   d	|z  z
  dz   }|||dz  z  z  }||||fS )
Nr   r   r   r$  r   r  r.  rU   )rw   r  rP   r   r  )rE   r  rD  rE  rF  rG  s         r6   r   znakagami_gen._stats  s    WRbgbkk)"R%i1qtCx< 3&+bhsC.@.@@AXb[AbDFBE>)!B$.2
bck3Br8   c                    t          j        |          }t          j        |          }t          j        |          }||dz
  t          j        |          z  z
  }dt          j        |          z  t          j        d          z
  }||z   |z   }t          j        	                                }|dk    }||         |z   dd||         z  z  z
  ||<   |
                    |          d         S )Nr   r)  rU   g     j@r   r  r   )rP   r  r  rw   r  r  r   r  r  r   rS  )	rE   r  r  rq  rr  rF  r  norm_entropyr  s	            r6   r   znakagami_gen._entropy  s    ]2JrNN"s(bjnn,,26"::q		)EAIz**,, Htl"Q2a5\1!yy##r8   Nc                 Z    t          j        |                    ||          |z            S r9  )rP   r   r)  )rE   r  r   r   s       r6   r   znakagami_gen._rvs.  s*    w|222D2AABFGGGr8   c                    t          |t                    r|                                }|
d| j        z  }t	          j        |          }t	          j        t	          j        ||z
  dz            t          |          z            }|||fz   S )N)r   rU   )	r?   r*   r  numargsrP   r  r   r  r  )rE   rF   rG   r.   r/   s        r6   r  znakagami_gen._fitstart2  s~    dL)) 	$>>##D<DL(D fTlls
Q//#d));<<sEl""r8   r  rN   )r   r   r   r   rc   rk   rr   r   ru   r~   ry   r   r   r   r   r  r   r8   r6   r  r    s         >  F F F+ + +1 1 1' ' '5 5 5( ( (6 6 6  $ $ $"H H H H	# 	# 	# 	# 	# 	#r8   r  nakagamic                 0   |dz  dz
  }t          j        |           t          j        |          }}t          j        |dz  | |z            d||z
  dz  z  z
  }t          j        |||z            dz  }t          |dk    ||fd t           j                   S )Nr   r   r   rU   r   c                 0    | t          j        |          z   S rN   r2  )r  r  s     r6   r  z_ncx2_log_pdf.<locals>.<lambda>N  s    q26!99} r8   r  )rP   r   rw   ry  iver   ri   )rq   r  rV  df2r  nsr  corrs           r6   _ncx2_log_pdfr	  B  s     S&3,CWQZZB
(3s7AbD
!
!Cb1$4
4C6#r"u#Dq	d
$
$6'	   r8   c                   P    e Zd ZdZd Zd ZddZd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )ncx2_gena  A non-central chi-squared continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `ncx2` is:

    .. math::

        f(x, k, \lambda) = \frac{1}{2} \exp(-(\lambda+x)/2)
            (x/\lambda)^{(k-2)/4}  I_{(k-2)/2}(\sqrt{\lambda x})

    for :math:`x >= 0`, :math:`k > 0` and :math:`\lambda \ge 0`.
    :math:`k` specifies the degrees of freedom (denoted ``df`` in the
    implementation) and :math:`\lambda` is the non-centrality parameter
    (denoted ``nc`` in the implementation). :math:`I_\nu` denotes the
    modified Bessel function of first order of degree :math:`\nu`
    (`scipy.special.iv`).

    `ncx2` takes ``df`` and ``nc`` as shape parameters.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``pdf``, ``cdf``, ``ppf``, ``sf`` and ``isf``
    methods. [1]_

    %(after_notes)s

    References
    ----------
    .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                 F    |dk    t          j        |          z  |dk    z  S r7  r  rE   r  rV  s      r6   rc   zncx2_gen._argcheckv  s"    Q"+b//)R1W55r8   c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )Nr  Fr   r
  rV  rg   rh   rE   idfincs      r6   rk   zncx2_gen._shape_infoy  s>    uq"&k>BBuq"&k=AASzr8   Nc                 0    |                     |||          S rN   )noncentral_chisquare)rE   r  rV  r   r   s        r6   r   zncx2_gen._rvs~  s    00R>>>r8   c                 ~    t          j        |t                    |dk    z  }t          ||||ft          d           S )Nr
  r   c                 8    t                               | |          S rN   )r  r   rq   r  _s      r6   r  z"ncx2_gen._logpdf.<locals>.<lambda>  s    dll1b.A.A r8   r  )rP   	ones_likeboolr   r	  rE   rq   r  rV  conds        r6   r   zncx2_gen._logpdf  sL    |AT***bAg6$B}AAC C C 	Cr8   c                     t          j        |t                    |dk    z  }t          j        d          5  t	          ||||ft
          j        d           cd d d            S # 1 swxY w Y   d S )Nr
  r   r9  rr  c                 8    t                               | |          S rN   )r  rr   r	  s      r6   r  zncx2_gen._pdf.<locals>.<lambda>      $))Ar2B2B r8   r  )rP   r	  r 	  r<  r   rn   	_ncx2_pdfr!	  s        r6   rr   zncx2_gen._pdf      |AT***bAg6[h''' 	D 	DdQBK3=!B!BD D D	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D   !A&&A*-A*c                     t          j        |t                    |dk    z  }t          j        d          5  t	          ||||ft
          j        d           cd d d            S # 1 swxY w Y   d S )Nr
  r   r9  rr  c                 8    t                               | |          S rN   )r  ru   r	  s      r6   r  zncx2_gen._cdf.<locals>.<lambda>  r%	  r8   r  )rP   r	  r 	  r<  r   rn   	_ncx2_cdfr!	  s        r6   ru   zncx2_gen._cdf  r'	  r(	  c                     t          j        |t                    |dk    z  }t          j        d          5  t	          ||||ft
          j        d           cd d d            S # 1 swxY w Y   d S )Nr
  r   r9  rr  c                 8    t                               | |          S rN   )r  r~   r	  s      r6   r  zncx2_gen._ppf.<locals>.<lambda>  r%	  r8   r  )rP   r	  r 	  r<  r   rn   	_ncx2_ppf)rE   r}   r  rV  r"	  s        r6   r~   zncx2_gen._ppf  r'	  r(	  c                     t          j        |t                    |dk    z  }t          j        d          5  t	          ||||ft
          j        d           cd d d            S # 1 swxY w Y   d S )Nr
  r   r9  rr  c                 8    t                               | |          S rN   )r  ry   r	  s      r6   r  zncx2_gen._sf.<locals>.<lambda>  s    $((1b// r8   r  )rP   r	  r 	  r<  r   rn   _ncx2_sfr!	  s        r6   ry   zncx2_gen._sf  s    |AT***bAg6[h''' 	C 	CdQBK3<!A!AC C C	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cr(	  c                     t          j        |t                    |dk    z  }t          j        d          5  t	          ||||ft
          j        d           cd d d            S # 1 swxY w Y   d S )Nr
  r   r9  rr  c                 8    t                               | |          S rN   )r  r   r	  s      r6   r  zncx2_gen._isf.<locals>.<lambda>  r%	  r8   r  )rP   r	  r 	  r<  r   rn   	_ncx2_isfr!	  s        r6   r   zncx2_gen._isf  r'	  r(	  c                 
   ||z   }d }d |||d          z  }t          j        d           |||d          z  t          j         |||d          dz            z  }d |||d          z   |||d          dz  z  }||||fS )Nc                     | ||z  z   S rN   r   )r  r  r  s      r6   	k_plus_clz"ncx2_gen._stats.<locals>.k_plus_cl  s    qs7Nr8   r   r  r  r  rO  rU   r  )rE   r  rV  
_ncx2_meanr7	  _ncx2_variance_ncx2_skewness_ncx2_kurtosis_excesss           r6   r   zncx2_gen._stats  s    "W
	 	 			"b# 6 66'#,,2r1)=)=='))BC"8"8!";<<=!%		"b#(>(>!>!*2r3!7!7!:"; !	
 	
r8   r  )r   r   r   r   rc   rk   r   r   rr   ru   r~   ry   r   r   r   r8   r6   r	  r	  R  s        " "F6 6 6  
? ? ? ?C C C
D D DD D DD D DC C CD D D
 
 
 
 
r8   r	  ncx2c                   L    e Zd ZdZd Zd ZddZd Zd Zd Z	d	 Z
d
 ZddZdS )ncf_gena2  A non-central F distribution continuous random variable.

    %(before_notes)s

    See Also
    --------
    scipy.stats.f : Fisher distribution

    Notes
    -----
    The probability density function for `ncf` is:

    .. math::

        f(x, n_1, n_2, \lambda) =
            \exp\left(\frac{\lambda}{2} +
                      \lambda n_1 \frac{x}{2(n_1 x + n_2)}
                \right)
            n_1^{n_1/2} n_2^{n_2/2} x^{n_1/2 - 1} \\
            (n_2 + n_1 x)^{-(n_1 + n_2)/2}
            \gamma(n_1/2) \gamma(1 + n_2/2) \\
            \frac{L^{\frac{n_1}{2}-1}_{n_2/2}
                \left(-\lambda n_1 \frac{x}{2(n_1 x + n_2)}\right)}
            {B(n_1/2, n_2/2)
                \gamma\left(\frac{n_1 + n_2}{2}\right)}

    for :math:`n_1, n_2 > 0`, :math:`\lambda \ge 0`.  Here :math:`n_1` is the
    degrees of freedom in the numerator, :math:`n_2` the degrees of freedom in
    the denominator, :math:`\lambda` the non-centrality parameter,
    :math:`\gamma` is the logarithm of the Gamma function, :math:`L_n^k` is a
    generalized Laguerre polynomial and :math:`B` is the beta function.

    `ncf` takes ``dfn``, ``dfd`` and ``nc`` as shape parameters. If ``nc=0``,
    the distribution becomes equivalent to the Fisher distribution.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``pdf``, ``cdf``, ``ppf``, ``stats``, ``sf`` and
    ``isf`` methods. [1]_

    %(after_notes)s

    References
    ----------
    .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                 *    |dk    |dk    z  |dk    z  S r7  r   )rE   r  r  rV  s       r6   rc   zncf_gen._argcheck  s    aC!G$a00r8   c                     t          dddt          j        fd          }t          dddt          j        fd          }t          dddt          j        fd          }|||gS )Nr  Fr   r
  r  rV  rg   rh   )rE   idf1idf2r	  s       r6   rk   zncf_gen._shape_info  sZ    %BF^DD%BF^DDuq"&k=AAdC  r8   Nc                 2    |                     ||||          S rN   )noncentral_f)rE   r  r  rV  r   r   s         r6   r   zncf_gen._rvs  s    ((c2t<<<r8   c                 0    t          j        ||||          S rN   )rn   _ncf_pdfrE   rq   r  r  rV  s        r6   rr   zncf_gen._pdf  s    |AsC,,,r8   c                 0    t          j        ||||          S rN   )rw   ncfdtrrG	  s        r6   ru   zncf_gen._cdf  s    yc2q)))r8   c                     t          j        d          5  t          j        ||||          cd d d            S # 1 swxY w Y   d S rq  )rP   r<  rw   ncfdtri)rE   r}   r  r  rV  s        r6   r~   zncf_gen._ppf  s    [h''' 	/ 	/:c3A..	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/   :>>c                 0    t          j        ||||          S rN   )rn   _ncf_sfrG	  s        r6   ry   zncf_gen._sf  s    {1c3+++r8   c                     t          j        d          5  t          j        ||||          cd d d            S # 1 swxY w Y   d S rq  )rP   r<  rn   _ncf_isfrG	  s        r6   r   zncf_gen._isf  s    [h''' 	1 	1<3R00	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1rL	  r  c                     t          j        |||          }t          j        |||          }d|v rt          j        |||          nd }d|v rt          j        |||          dz
  nd }||||fS )Nr  r  r  )rn   	_ncf_mean_ncf_variance_ncf_skewness_ncf_kurtosis_excess)	rE   r  r  rV  r  rD  rE  rF  rG  s	            r6   r   zncf_gen._stats  s    ]3R((S"--03wSsC,,,D!$ %b  59 	 3Br8   r  r  r   r   r   r   rc   rk   r   rr   ru   r~   ry   r   r   r   r8   r6   r>	  r>	    s        / /`1 1 1! ! != = = =- - -* * */ / /, , ,1 1 1     r8   r>	  ncfc                   P    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
d
 Zd Zd ZdS )t_gena  A Student's t continuous random variable.

    For the noncentral t distribution, see `nct`.

    %(before_notes)s

    See Also
    --------
    nct

    Notes
    -----
    The probability density function for `t` is:

    .. math::

        f(x, \nu) = \frac{\Gamma((\nu+1)/2)}
                        {\sqrt{\pi \nu} \Gamma(\nu/2)}
                    (1+x^2/\nu)^{-(\nu+1)/2}

    where :math:`x` is a real number and the degrees of freedom parameter
    :math:`\nu` (denoted ``df`` in the implementation) satisfies
    :math:`\nu > 0`. :math:`\Gamma` is the gamma function
    (`scipy.special.gamma`).

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zt_gen._shape_info:  r  r8   Nc                 0    |                     ||          S r9  )
standard_tr  s       r6   r   z
t_gen._rvs=  s    &&r&555r8   c                 R     t          |t          j        k    ||fd  fd          S )Nc                 6    t                               |           S rN   )r  rr   rq   r  s     r6   r  zt_gen._pdf.<locals>.<lambda>C  s    DIIaLL r8   c                 T    t          j                            | |                    S rN   r  )rq   r  rE   s     r6   r  zt_gen._pdf.<locals>.<lambda>D  s#    t||Ar**++ r8   r  r  r  s   `  r6   rr   z
t_gen._pdf@  sC    "&L1b'((   
 
 
 	
r8   c                 T    d }d }t          |t          j        k    ||f||          S )Nc                    t          j        t          j        d|z  d                    dt          j        |          t          j        t           j                  z   z  z
  |dz   dz  t          j        | | z  |z            z  z
  S rM  )rP   r   rw   r  r   r  r_	  s     r6   t_logpdfzt_gen._logpdf.<locals>.t_logpdfK  so    F2738S1122RVBZZ"&--789Avqj!a%(!3!334 5r8   c                 6    t                               |           S rN   )r  r   r_	  s     r6   norm_logpdfz"t_gen._logpdf.<locals>.norm_logpdfP  s    <<??"r8   r  r  )rE   rq   r  rc	  re	  s        r6   r   zt_gen._logpdfI  sC    	5 	5 	5
	# 	# 	# ",B	[XNNNNr8   c                 ,    t          j        ||          S rN   rw   stdtrr  s      r6   ru   z
t_gen._cdfU  r  r8   c                 .    t          j        ||           S rN   rg	  r  s      r6   ry   z	t_gen._sfX  s    xQBr8   c                 ,    t          j        ||          S rN   rw   stdtritr  s      r6   r~   z
t_gen._ppf[  s    z"a   r8   c                 .    t          j        ||           S rN   rk	  r  s      r6   r   z
t_gen._isf^  s    
2q!!!!r8   c                    t          j        |          }t          j        |dk    dt           j                  }|dk    |dk    z  |dk    t          j        |          z  |f}d d d f}t          |||ft           j                  }t          j        |dk    dt           j                  }|dk    |dk    z  |dk    t          j        |          z  |f}d	 d
 d f}t          |||ft           j                  }||||fS )Nr   r   rU   c                 J    t          j        t           j        | j                  S rN   rP   broadcast_tori   r  r  s    r6   r  zt_gen._stats.<locals>.<lambda>j      !B!B r8   c                     | | dz
  z  S r?  r   r  s    r6   r  zt_gen._stats.<locals>.<lambda>k  s    r#v r8   c                 6    t          j        d| j                  S r^   rP   rq	  r  r  s    r6   r  zt_gen._stats.<locals>.<lambda>l      BH!=!= r8   r  r$  c                 J    t          j        t           j        | j                  S rN   rp	  r  s    r6   r  zt_gen._stats.<locals>.<lambda>t  rr	  r8   c                     d| dz
  z  S )Nr  rO  r   r  s    r6   r  zt_gen._stats.<locals>.<lambda>u  s    3 r8   c                 6    t          j        d| j                  S r7  ru	  r  s    r6   r  zt_gen._stats.<locals>.<lambda>v  rv	  r8   )rP   isposinfrT  ri   r   r   r  )	rE   r  infinite_dfrD  r  
choicelistrE  rF  rG  s	            r6   r   zt_gen._statsa  s   k"ooXb1fc26**!Va(!Vr{2.! CB..==?
 (Jrv>>Xb1fc26**!Va(!Vr{2.! CB//==?
 :ubf==3Br8   c                     |t           j        k    rt                                          S d }d }t	          |dk    |f||          }|S )Nc                     | dz  }| dz   dz  }|t          j        |          t          j        |          z
  z  t          j        t          j        |           t          j        |d          z            z   S rG  )rw   r  rP   r   r   ro  )r  halfhalf1s      r6   r  zt_gen._entropy.<locals>.regular  si    a4D!VQJE2:e,,rz$/?/??@fRWR[[s););;<<= >r8   c                     t                                           d| z  z   | dz  dz  z   | dz  dz  z
  | dz  dz  z
  d| d	z  z  z   | d
z  dz  z   }|S )Nr   r  r$  r  r  r  r.  g333333?r  r  )r  r   )r  r  s     r6   rt  z"t_gen._entropy.<locals>.asymptotic  si     1R4'2s7A+5S!CGQ;!%r3w035s7A+>AHr8   d   r  )rP   ri   r  r   r   )rE   r  r  rt  r  s        r6   r   zt_gen._entropy{  s\    <<==??"	> 	> 	>	 	 	 rSy2&J7CCCr8   r  r  r   r8   r6   rY	  rY	    s         <F F F6 6 6 6
 
 

O 
O 
O       ! ! !" " "  4    r8   rY	  r  c                   L    e Zd ZdZd Zd ZddZd Zd Zd Z	d	 Z
d
 ZddZdS )nct_gena  A non-central Student's t continuous random variable.

    %(before_notes)s

    Notes
    -----
    If :math:`Y` is a standard normal random variable and :math:`V` is
    an independent chi-square random variable (`chi2`) with :math:`k` degrees
    of freedom, then

    .. math::

        X = \frac{Y + c}{\sqrt{V/k}}

    has a non-central Student's t distribution on the real line.
    The degrees of freedom parameter :math:`k` (denoted ``df`` in the
    implementation) satisfies :math:`k > 0` and the noncentrality parameter
    :math:`c` (denoted ``nc`` in the implementation) is a real number.

    This distribution uses routines from the Boost Math C++ library for
    the computation of the ``pdf``, ``cdf``, ``ppf``, ``sf`` and ``isf``
    methods. [1]_

    %(after_notes)s

    References
    ----------
    .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                     |dk    ||k    z  S r7  r   r	  s      r6   rc   znct_gen._argcheck  s    Q28$$r8   c                     t          dddt          j        fd          }t          ddt          j         t          j        fd          }||gS )Nr  Fr   r
  rV  rh   r	  s      r6   rk   znct_gen._shape_info  sC    uq"&k>BBuw&7HHSzr8   Nc                     t                               |||          }t                              |||          }|t          j        |          z  t          j        |          z  S )Nr  r  )r  r  r  rP   r   )rE   r  rV  r   r   rb   r  s          r6   r   znct_gen._rvs  sO    HH$\HBBXXbt,X??272;;,,r8   c                 .    t          j        |||          S rN   )rn   _nct_pdfrE   rq   r  rV  s       r6   rr   znct_gen._pdf  s    |Ar2&&&r8   c                 .    t          j        |||          S rN   )rw   nctdtrr	  s       r6   ru   znct_gen._cdf  s    yR###r8   c                     t          j        d          5  t          j        |||          cd d d            S # 1 swxY w Y   d S rq  )rP   r<  rn   _nct_ppf)rE   r}   r  rV  s       r6   r~   znct_gen._ppf      [h''' 	+ 	+<2r**	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+rv  c                     t          j        d          5  t          j        t          j        |||          dd          cd d d            S # 1 swxY w Y   d S )Nr9  rr  r   r   )rP   r<  cliprn   _nct_sfr	  s       r6   ry   znct_gen._sf  s    [h''' 	9 	973;q"b111a88	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9r=  c                     t          j        d          5  t          j        |||          cd d d            S # 1 swxY w Y   d S rq  )rP   r<  rn   _nct_isfr	  s       r6   r   znct_gen._isf  r	  rv  r  c                     t          j        ||          }t          j        ||          }d|v rt          j        ||          nd }d|v rt          j        ||          nd }||||fS )Nr  r  )rn   	_nct_mean_nct_variance_nct_skewness_nct_kurtosis_excess)rE   r  rV  r  rD  rE  rF  rG  s           r6   r   znct_gen._stats  sq    ]2r""B''*-..Sr2&&&d14S%b"---T3Br8   r  r  rV	  r   r8   r6   r	  r	    s         @% % %  
- - - -
' ' '$ $ $+ + +9 9 9+ + +     r8   r	  nctc                        e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	Z
d
 Ze ee           fd                        Z xZS )
pareto_genaL  A Pareto continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `pareto` is:

    .. math::

        f(x, b) = \frac{b}{x^{b+1}}

    for :math:`x \ge 1`, :math:`b > 0`.

    `pareto` takes ``b`` as a shape parameter for :math:`b`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zpareto_gen._shape_info  r  r8   c                     ||| dz
  z  z  S r^   r   r  s      r6   rr   zpareto_gen._pdf  s    1r!t9}r8   c                     d|| z  z
  S r^   r   r  s      r6   ru   zpareto_gen._cdf  s    1r7{r8   c                 .    t          d|z
  d|z            S )Nr   rA  r9  r  s      r6   r~   zpareto_gen._ppf  s    1Q3Qr8   c                     || z  S rN   r   r  s      r6   ry   zpareto_gen._sf   s    A2wr8   c                 2    t          j        |d|z            S rD  r  r  s      r6   r   zpareto_gen._isf   s    x4!8$$$r8   r  c                 X   d\  }}}}d|v ri|dk    }t          j        ||          }t          j        t          j        |          t           j                  }t          j        ||||dz
  z             d|v rr|dk    }t          j        ||          }t          j        t          j        |          t           j                  }t          j        ||||dz
  z  |dz
  dz  z             d	|v r|d
k    }t          j        ||          }t          j        t          j        |          t           j                  }d|dz   z  t          j        |dz
            z  |dz
  t          j        |          z  z  }	t          j        |||	           d|v r|dk    }t          j        ||          }t          j        t          j        |          t           j                  }dt          j        g d|          z  t          j        g d|          z  }	t          j        |||	           ||||fS )Nrt  rD  r   r  r   r  rU   r   r  r  rI  r  r$  r  )r   r   r	  r  )r   g      r  r   )	rP   extractr  r  ri   placer  r   rK  )
rE   r   r  rD  rE  rF  rG  maskbtr  s
             r6   r   zpareto_gen._stats   s   0CR'>>q5DD!$$B!888BHRrRV}---'>>q5DD!$$B'"(1++"&999CHS$bfC! ;<<<'>>q5DD!$$B!888BS>BGBH$5$55"s(bgbkk9QRDHRt$$$'>>q5DD!$$B!888B
#5#5#5r:::J555r::;DHRt$$$3Br8   c                 <    dd|z  z   t          j        |          z
  S r  r2  rE   r   s     r6   r   zpareto_gen._entropy#       3q5y26!99$$r8   c                    t          | ||          }|\  }}|9t          j                  |z
  |pdk     rt          ddt          j                  j        d         fd||cxu rCn n?fdfdfdfd	}t          |                    d
d                    }|dz  |dz  }
}	 ||	|
          sB|	dk    s|
t          j        k     r,|	dz  }	|
dz  }
 ||	|
          s|	dk    |
t          j        k     ,t          |	|
g          }|j	        rx|j
        }t          j                  |z
  }p ||          }||z   t          j                  k     s,t          j                  |z
  }t          j        |d          }|||fS  t                      j        fi |S |t          j                  |z
  }n|}|pt          j                  |z
  }p ||          }|||fS )Nr   paretor   r  c                 b    t          j        t          j        |z
  | z                      z  S rN   rT  )r/   locationrF   ndatas     r6   	get_shapez!pareto_gen.fit.<locals>.get_shape3   s-     26"&$/U)B"C"CDDDDr8   c                     | z  |z  S rN   r   )r  r/   r	  s     r6   	dL_dScalez!pareto_gen.fit.<locals>.dL_dScale>   s     u}u,,r8   c                 D    | dz   t          j        d|z
  z            z  S r^   r   )r  r	  rF   s     r6   dL_dLocationz$pareto_gen.fit.<locals>.dL_dLocationC   s'     	RVA,A%B%BBBr8   c                     t          j                  | z
  }p | |          } ||           ||           z
  S rN   )rP   r  )r/   r	  r  r	  r	  rF   rQ  r	  s      r6   r#  z$pareto_gen.fit.<locals>.fun_to_solveH   sP     6$<<%/<))E8"<"<#|E844yy7N7NNNr8   c                 |    t          j         |                     t          j         |                    k    S rN   rO   rR   rS   r#  s     r6   rT   z.pareto_gen.fit.<locals>.interval_contains_rootO   s;    V 4 455V 4 4556 7r8   r/   rU   r$  )rL  rP   r  rL  ri   r  rW  r=   r+   r]  rM  r\  rA   rC   )rE   rF   rG   r5   r^  r   r   rT   r  rR   rS   r  r/   r.   r  r	  r	  rQ  r#  r	  r	  r  s    `             @@@@@@r6   rC   zpareto_gen.fit&   s    1tT4HH
%/"fdF tt 3v{ C Cxq????
1	E 	E 	E 	E 	E 	E
 6!!!!!!!!- - - - -
C C C C C
O O O O O O O O O7 7 7 7 7  ! 4 455K(1_kAoFF .-ff== 

frvoo!! .-ff== 

frvoo lVV4DEEEC} 1fTllU*7))E3"7"7 rvd||33F4LL3.EL22Ec5(("uww{4004000\&,,'CCC ,"&,,,/))E3//c5  r8   r  )r   r   r   r   rk   rr   ru   r~   ry   r   r   r   rK   r   r   rC   r  r  s   @r6   r	  r	    s         *E E E           % % %   6% % % M**R! R! R! R! +* _R! R! R! R! R!r8   r	  r	  c                   N    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )	lomax_gena  A Lomax (Pareto of the second kind) continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `lomax` is:

    .. math::

        f(x, c) = \frac{c}{(1+x)^{c+1}}

    for :math:`x \ge 0`, :math:`c > 0`.

    `lomax` takes ``c`` as a shape parameter for :math:`c`.

    `lomax` is a special case of `pareto` with ``loc=-1.0``.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zlomax_gen._shape_info   r  r8   c                 $    |dz  d|z   |dz   z  z  S r  r   r  s      r6   rr   zlomax_gen._pdf   s    uc!equ%%%r8   c                 `    t          j        |          |dz   t          j        |          z  z
  S r^   r  r  s      r6   r   zlomax_gen._logpdf   s&    vayyAaC!,,,r8   c                 X    t          j        | t          j        |          z             S rN   r  r  s      r6   ru   zlomax_gen._cdf   s#    !BHQKK((((r8   c                 V    t          j        | t          j        |          z            S rN   )rP   r   rw   r  r  s      r6   ry   zlomax_gen._sf   s     vqb!n%%%r8   c                 2    | t          j        |          z  S rN   r  r  s      r6   r   zlomax_gen._logsf   s    r"(1++~r8   c                 X    t          j        t          j        |            |z            S rN   r  r  s      r6   r~   zlomax_gen._ppf   s"    x1"a(((r8   c                     |d|z  z  dz
  S r@  r   r  s      r6   r   zlomax_gen._isf   s    4!8}q  r8   c                 R    t                               |dd          \  }}}}||||fS )NrA  r  )r.   r  )r	  r  r  s         r6   r   zlomax_gen._stats   s/     ,,qdF,CCCR3Br8   c                 <    dd|z  z   t          j        |          z
  S r  r2  r  s     r6   r   zlomax_gen._entropy   s    Qwrvayy  r8   N)r   r   r   r   rk   rr   r   ru   ry   r   r~   r   r   r   r   r8   r6   r	  r	     s         .E E E& & &- - -) ) )& & &  ) ) )! ! !  ! ! ! ! !r8   r	  lomaxc                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 ZddZd Ze eed           fd                        Z xZS )pearson3_gena  A pearson type III continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `pearson3` is:

    .. math::

        f(x, \kappa) = \frac{|\beta|}{\Gamma(\alpha)}
                       (\beta (x - \zeta))^{\alpha - 1}
                       \exp(-\beta (x - \zeta))

    where:

    .. math::

            \beta = \frac{2}{\kappa}

            \alpha = \beta^2 = \frac{4}{\kappa^2}

            \zeta = -\frac{\alpha}{\beta} = -\beta

    :math:`\Gamma` is the gamma function (`scipy.special.gamma`).
    Pass the skew :math:`\kappa` into `pearson3` as the shape parameter
    ``skew``.

    %(after_notes)s

    %(example)s

    References
    ----------
    R.W. Vogel and D.E. McMartin, "Probability Plot Goodness-of-Fit and
    Skewness Estimation Procedures for the Pearson Type 3 Distribution", Water
    Resources Research, Vol.27, 3149-3158 (1991).

    L.R. Salvosa, "Tables of Pearson's Type III Function", Ann. Math. Statist.,
    Vol.1, 191-198 (1930).

    "Using Modern Computing Tools to Fit the Pearson Type III Distribution to
    Aviation Loads Data", Office of Aviation Research (2003).

    c                    d}d}d}t          j        d||          \  }}}|                                }t          j        |          |k     }| }d||         |z  z  }	||	z  dz  }
||
|	z  z
  }|	||         |z
  z  }||||||	|
|fS )Nr   r   g>r   rU   )rP   r  copyr  )rE   rq   rF  r.   r/   norm2pearson_transitionansr	  invmaskro  r  r  transxs                r6   _preprocesszpearson3_gen._preprocess   s    
  #+*3488Qhhjj {4  #::%d7me+,!UT\!7d*+AvtWdE4??r8   c                 *    t          j        |          S rN   r  )rE   rF  s     r6   rc   zpearson3_gen._argcheck!  s    
 {4   r8   c                 V    t          ddt          j         t          j        fd          gS )NrF  Fr
  rh   rj   s    r6   rk   zpearson3_gen._shape_info!  s$    65BF7BF*;^LLMMr8   c                 *    d}d}|}d|dz  z  }||||fS )Nr   r   r  rU   r   )rE   rF  rD  r  r  r  s         r6   r   zpearson3_gen._stats!  s,    aK!Qzr8   c                     t          j        |                     ||                    }|j        dk    rt          j        |          rdS |S d|t          j        |          <   |S )Nr   r   )rP   r   r   r0  r  )rE   rq   rF  r	  s       r6   rr   zpearson3_gen._pdf!  s]    
 fT\\!T**++8q==x}} sJ BHSMM
r8   c                    |                      ||          \  }}}}}}}}	t          j        t          ||                             ||<   t          j        t	          |                    t
                              ||          z   ||<   |S rN   )r	  rP   r   r   r  r  r  )
rE   rq   rF  r	  r	  r	  r	  ro  r  r	  s
             r6   r   zpearson3_gen._logpdf$!  s     Q%% 	6QgtUA F9QtW--..D	 vc$ii((5<<+F+FFG
r8   c                    |                      ||          \  }}}}}}}}t          ||                   ||<   t          j        ||j                  }t          j        ||dk              }	||         dk    }
t                              ||
         ||
                   ||	<   t          j        ||dk               }||         dk     }t                              ||         ||                   ||<   |S r7  )	r	  r   rP   rq	  r  r  r  r   r  rE   rq   rF  r	  r	  r	  r	  r	  r  	invmask1a	invmask1b	invmask2a	invmask2bs                r6   ru   zpearson3_gen._cdf3!  s    Q%% 	3Qgq% ag&&D	tW]33N7D1H55	MA%	 6)#4eI6FGGI N7D1H55	MA%	&"3U95EFFI
r8   c                    |                      ||          \  }}}}}}}}t          ||                   ||<   t          j        ||j                  }t          j        ||dk              }	||         dk    }
t                              ||
         ||
                   ||	<   t          j        ||dk               }||         dk     }t                              ||         ||                   ||<   |S r7  )	r	  r   rP   rq	  r  r  r  r  r   r	  s                r6   ry   zpearson3_gen._sfK!  s    Q%% 	3Qgq% QtW%%D	tW]33N7D1H55	MA%	&"3U95EFFIN7D1H55	MA%	6)#4eI6FGGI
r8   Nc                 6   t          j        ||          }|                     dg|          \  }}}}}}}	}
|                                }|j        |z
  }|                    |          ||<   |                    |	|          |z  |
z   ||<   |dk    r|d         }|S )Nr   r   )rP   rq	  r	  r  r   r   r)  )rE   rF  r   r   r	  r	  r	  r	  ro  r  r  nsmallnbigs                r6   r   zpearson3_gen._rvs\!  s    tT**aS$'' 	4Q4$t y6! 0088D	#225$??DtKG2::a&C
r8   c                     |                      ||          \  }}}}}}}}	t          ||                   ||<   ||         }d||dk              z
  ||dk     <   t          j        ||          |z  |	z   ||<   |S r  )r	  r   rw   r  )
rE   r}   rF  r	  r	  r	  r	  ro  r  r  s
             r6   r~   zpearson3_gen._ppfj!  s    Q%% 	4Q4$tag&&D	gJ!D1H+o$(~eQ//4t;G
r8   ze        Note that method of moments (`method='MM'`) is not
        available for this distribution.

r   c                     |                     dd           dk    rt          d           t          t          |           |           j        |g|R i |S )Nr1   MMzhFit `method='MM'` is not available for the Pearson3 distribution. Please try the default `method='MLE'`.)r=   NotImplementedErrorrA   rB   rC   rT  s       r6   rC   zpearson3_gen.fits!  sn    
 88Hd##t++% 'D E E E /5dT**.tCdCCCdCCCr8   r  )r   r   r   r   r	  rc   rk   r   rr   r   ru   ry   r   r~   rK   r	   r   rC   r  r  s   @r6   r	  r	     s       , ,Z@ @ @8! ! !N N N        0  "      } 50 1 1 1D D D D1 1 _D D D D Dr8   r	  pearson3c                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Z fdZe eed           fd                        Z xZS )powerlaw_gena  A power-function continuous random variable.

    %(before_notes)s

    See Also
    --------
    pareto

    Notes
    -----
    The probability density function for `powerlaw` is:

    .. math::

        f(x, a) = a x^{a-1}

    for :math:`0 \le x \le 1`, :math:`a > 0`.

    `powerlaw` takes ``a`` as a shape parameter for :math:`a`.

    %(after_notes)s

    For example, the support of `powerlaw` can be adjusted from the default
    interval ``[0, 1]`` to the interval ``[c, c+d]`` by setting ``loc=c`` and
    ``scale=d``. For a power-law distribution with infinite support, see
    `pareto`.

    `powerlaw` is a special case of `beta` with ``b=1``.

    %(example)s

    c                 @    t          dddt          j        fd          gS r	  rh   rj   s    r6   rk   zpowerlaw_gen._shape_info!  r  r8   c                     |||dz
  z  z  S r  r   r  s      r6   rr   zpowerlaw_gen._pdf!  s    QsU|r8   c                 \    t          j        |          t          j        |dz
  |          z   S r^   )rP   r   rw   ry  r  s      r6   r   zpowerlaw_gen._logpdf!  s%    vayy28AE1----r8   c                     ||dz  z  S r  r   r  s      r6   ru   zpowerlaw_gen._cdf!  s    1S5zr8   c                 0    |t          j        |          z  S rN   r2  r  s      r6   r   zpowerlaw_gen._logcdf!  r3  r8   c                 (    t          |d|z            S r  r9  r  s      r6   r~   zpowerlaw_gen._ppf!  s    1c!e}}r8   c                 .    t          j        ||           S rN   )rw   r  )rE   r  r   s      r6   ry   zpowerlaw_gen._sf!  s    Ar8   c                     |||z   z  S rN   r   r4  s      r6   r  zpowerlaw_gen._munp!  s    AE{r8   c                     ||dz   z  ||dz   z  |dz   dz  z  d|dz
  |dz   z  z  t          j        |dz   |z            z  dt          j        g d|          z  ||dz   z  |dz   z  z  fS )	Nr   r   rU   r  rI  r  )r   r  r	  rU   r$  )rP   r   rK  r  s     r6   r   zpowerlaw_gen._stats!  s    QWQWSQ.SQW-.!c'Q1G1GGBJ~~~q111Q!c']a!e5LMO 	Or8   c                 <    dd|z  z
  t          j        |          z
  S r  r2  r  s     r6   r   zpowerlaw_gen._entropy!  r	  r8   c                 d    t                                          ||          |dk    |dk    z  z  S r  )rA   r  )rE   rq   r   r  s      r6   r  zpowerlaw_gen._support_mask!  s4    %%a++FqAv&( 	)r8   a:          Notes specifically for ``powerlaw.fit``: If the location is a free
        parameter and the value returned for the shape parameter is less than
        one, the true maximum likelihood approaches infinity. This causes
        numerical difficulties, and the resulting estimates are approximate.
        

r   c                 N   |                     dd          r t                      j        g|R i |S t          t	          j                            dk    r t                      j        g|R i |S t          | ||          \  }}|                               fg}|                     |i           d         }|W	                                |k    st          ddd          |,                                ||z   k    st          ddd          |>|dk    rt          d          |t	          j                  k    rd}t          |          d d	 || ||          ||fS |t	          j        	                                t          j                   }	p |	|          }
 ||
|	|f          }t	          j                                        |z
  t          j                  }p ||          } ||||f          }||k     r|
|	|fS |||fS |  |          }p ||          }|||fS fd
}d d fdfdfd}dk    r
 |            S dk    r
 |            S  |            }|                     |          } |            }|                     |          }||k    r|d         dk    r|S ||k    r|d         dk    r|S  t                      j        g|R i |S )Nr@  Fr   powerlawr   zKNegative or zero `fscale` is outside the range allowed by the distribution.z0`fscale` must be greater than the range of data.c                     t          |           }| t          j        t          j        | |z
                      |t          j        |          z  z
  z  S rN   )r  rP   r  r   )rF   r.   r/   r  s       r6   r	  z#powerlaw_gen.fit.<locals>.get_shape"  sE     D		A3"&s
!3!344qFGGr8   c                 0    |                                  |z
  S rN   )r  )rF   r.   s     r6   	get_scalez#powerlaw_gen.fit.<locals>.get_scale"  s     88::##r8   c                     t          j                                        t           j                   } t          j        |           t          j        | j                  j        k     r3t          j        |           t          j        | j                  j        z  } t          j         |           t           j                  }p | |          }|| |fS rN   )	rP   r\  r  ri   r  r&  r  r'  rQ   )r.   r/   r  rF   rQ  r	  r	  s      r6   fit_loc_scale_w_shape_lt_1z4powerlaw_gen.fit.<locals>.fit_loc_scale_w_shape_lt_1="  s    ,txxzzBF733Cvc{{RXci00555gcllRXci%8%8%==L4!5!5rv>>E9iic599E#u$$r8   c                 *    | j         d          |z  |z  S r7  )r  )rF   r  r/   s      r6   r	  z#powerlaw_gen.fit.<locals>.dL_dScaleL"  s     JqM>E)E11r8   c                 B    |dz
  t          j        d|| z
  z            z  S r^   r   )rF   r  r.   s      r6   r	  z&powerlaw_gen.fit.<locals>.dL_dLocationQ"  s&     AIS4Z(8!9!999r8   c                     t          j         |           t           j                   }p | |          } ||           S rN   rP   r\  ri   )r.   r/   r  r	  rF   rQ  r	  r	  s      r6   dL_dLocation_starz+powerlaw_gen.fit.<locals>.dL_dLocation_starV"  sR     L4!5!5w??E9iic599E<eS111r8   c                     t          j         |           t           j                   }p | |          } ||           ||           z
  S rN   r	  )	r.   r/   r  r	  r	  rF   rQ  r	  r	  s	      r6   r#  z&powerlaw_gen.fit.<locals>.fun_to_solve]"  sj     L4!5!5w??E9iic599EIdE511"l4445 6r8   c                     t          j        
                                t           j                   } 
                                | z
  } 	|           dk    r+
                                |z
  } |dz  } 	|           dk    +fd}| dz
  }d} |||           sJ|t           j         k    r9
                                |z
  }|dz  } |||           s|t           j         k    9t	          j        || f          }t          j        |j        t           j                   }t          j         
|          t           j                  }p 
||          }|||fS )Nr   rU   c                 |    t          j         |                     t          j         |                    k    S rN   rO   r	  s     r6   rT   zTpowerlaw_gen.fit.<locals>.fit_loc_scale_w_shape_gt_1.<locals>.interval_contains_rootq"  s;    V 4 4557<<#7#7889 :r8   r   r   r$  )rP   r\  r  ri   r   r+   rM  )rS   r'  rT   rR   r  rM  r.   r/   r  r	  rF   rQ  r#  r	  r	  s            r6   fit_loc_scale_w_shape_gt_1z4powerlaw_gen.fit.<locals>.fit_loc_scale_w_shape_gt_1e"  s    \$((**rvg66F XXZZ&(E##F++a//e+
 $#F++a//: : : : :
 aZF
 A--ff== "&((((**q.Q .-ff== "&(( 'vv>NOOOD,ty26'22CL4!5!5rv>>E9iic599E#u$$r8   )r3   rA   rC   r  rP   uniquerL  r  _reduce_funcr  rL  r  r   ptpr\  ri   rX  )rE   rF   rG   r5   r   r   penalized_nllf_argspenalized_nllfrY   loc_lt1	shape_lt1ll_lt1loc_gt1	shape_gt1ll_gt1r/   r  r	  r	  fit_shape_lt1fit_shape_gt1r	  r	  r	  rQ  r#  r	  r	  r  s    `                   @@@@@@@r6   rC   zpowerlaw_gen.fit!  s   P 88J&& 	4577;t3d333d333ry1$$577;t3d333d333%@tAEt&M &M"fdF#dnnT&:&:%<=**+>CCAF
 88::$$":q!444!$((**v*E*E":q!444{{  "F G G G%%H oo%	H 	H 	H	$ 	$ 	$ $"29T400$>> l488::w77GB))D'6"B"BI#^Y$@$GGF l488::#6??GB))D'6"B"BI#^Y$@$GGF '611 '611 IdD))E:iidE::E$%%
	% 	% 	% 	% 	% 	% 	% 	%	2 	2 	2
	: 	: 	:
	2 	2 	2 	2 	2 	2 	2 	2 	2	6 	6 	6 	6 	6 	6 	6 	6 	6 	6!	% !	% !	% !	% !	% !	% !	% !	% !	% !	%H &A++--///FQJJ--/// 3244=$//2244=$//Va 0A 5 5  f__q!1A!5!5  577;t3d333d333r8   )r   r   r   r   rk   rr   r   ru   r   r~   ry   r  r   r   r  rK   r	   r   rC   r  r  s   @r6   r	  r	  !  s3        @E E E  . . .          O O O% % %) ) ) ) ) } 5   H4 H4 H4 H4  _H4 H4 H4 H4 H4r8   r	  r	  c                   P    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zd	 Zd
S )powerlognorm_gena  A power log-normal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `powerlognorm` is:

    .. math::

        f(x, c, s) = \frac{c}{x s} \phi(\log(x)/s)
                     (\Phi(-\log(x)/s))^{c-1}

    where :math:`\phi` is the normal pdf, and :math:`\Phi` is the normal cdf,
    and :math:`x > 0`, :math:`s, c > 0`.

    `powerlognorm` takes :math:`c` and :math:`s` as shape parameters.

    %(after_notes)s

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )Nr  Fr   r
  r  rh   )rE   r&  r  s      r6   rk   zpowerlognorm_gen._shape_info"  r  r8   c                 T    t          j        |                     |||                    S rN   r  rE   rq   r  r  s       r6   rr   zpowerlognorm_gen._pdf"  r]  r8   c                     t          j        |          t          j        |          z
  t          j        |          z
  t          t          j        |          |z            z   t          t          j        |           |z            |dz
  z  z   S r  rP   r   r   r   r
  s       r6   r   zpowerlognorm_gen._logpdf"  so    q		BF1II%q		1RVAYY]++,bfQiiZ!^,,B78 	9r8   c                 V    t          j        |                     |||                     S rN   rf  r
  s       r6   ru   zpowerlognorm_gen._cdf"  rg  r8   c                 6    |                      d|z
  ||          S r^   )r   rE   r}   r  r  s       r6   r~   zpowerlognorm_gen._ppf"  s    yyQ1%%%r8   c                 T    t          j        |                     |||                    S rN   r;  r
  s       r6   ry   zpowerlognorm_gen._sf"  r<  r8   c                 R    t          t          j        |           |z            |z  S rN   r  r
  s       r6   r   zpowerlognorm_gen._logsf"  s#    RVAYYJN++a//r8   c                 X    t          j        t          |d|z  z             |z            S r^   rA  r
  s       r6   r   zpowerlognorm_gen._isf"  s*    vyQqS***Q.///r8   N)r   r   r   r   r   r  r  rk   rr   r   ru   r~   ry   r   r   r   r8   r6   r
  r
  "  s         . "4M  
- - -9 9 9
/ / /& & &, , ,0 0 00 0 0 0 0r8   r
  powerlognormc                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )powernorm_genah  A power normal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `powernorm` is:

    .. math::

        f(x, c) = c \phi(x) (\Phi(-x))^{c-1}

    where :math:`\phi` is the normal pdf, :math:`\Phi` is the normal cdf,
    :math:`x` is any real, and :math:`c > 0` [1]_.

    `powernorm` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    References
    ----------
    .. [1] NIST Engineering Statistics Handbook, Section 1.3.6.6.13,
           https://www.itl.nist.gov/div898/handbook//eda/section3/eda366d.htm

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zpowernorm_gen._shape_info"  r  r8   c                 T    |t          |          z  t          |           |dz
  z  z  S r  r   r   r  s      r6   rr   zpowernorm_gen._pdf"  s(    1~A23!788r8   c                 x    t          j        |          t          |          z   |dz
  t          |           z  z   S r^   r
  r  s      r6   r   zpowernorm_gen._logpdf"  s3    vayy<??*ac<3C3C-CCCr8   c                 T    t          j        |                     ||                     S rN   rf  r  s      r6   ru   zpowernorm_gen._cdf #  s#    Q**++++r8   c                 J    t          t          d|z
  d|z                       S r  )r   r  r  s      r6   r~   zpowernorm_gen._ppf#  s%    #cAgsQw//0000r8   c                 R    t          j        |                     ||                    S rN   r;  r  s      r6   ry   zpowernorm_gen._sf#  r7  r8   c                 (    |t          |           z  S rN   r   r  s      r6   r   zpowernorm_gen._logsf	#  s    <####r8   c                 p    t          t          j        t          j        |          |z                       S rN   )r   rP   r   r   r  s      r6   r   zpowernorm_gen._isf#  s)    "&Q//0000r8   N)r   r   r   r   rk   rr   r   ru   r~   ry   r   r   r   r8   r6   r
  r
  "  s         6E E E9 9 9D D D, , ,1 1 1) ) )$ $ $1 1 1 1 1r8   r
  	powernormc                   D    e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	Z
d
 ZdS )	rdist_gena/  An R-distributed (symmetric beta) continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `rdist` is:

    .. math::

        f(x, c) = \frac{(1-x^2)^{c/2-1}}{B(1/2, c/2)}

    for :math:`-1 \le x \le 1`, :math:`c > 0`. `rdist` is also called the
    symmetric beta distribution: if B has a `beta` distribution with
    parameters (c/2, c/2), then X = 2*B - 1 follows a R-distribution with
    parameter c.

    `rdist` takes ``c`` as a shape parameter for :math:`c`.

    This distribution includes the following distribution kernels as
    special cases::

        c = 2:  uniform
        c = 3:  `semicircular`
        c = 4:  Epanechnikov (parabolic)
        c = 6:  quartic (biweight)
        c = 8:  triweight

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zrdist_gen._shape_info5#  r  r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zrdist_gen._pdf9#  r  r8   c                 ~    t          j        d           t                              |dz   dz  |dz  |dz            z   S r  )rP   r   ro  r   r  s      r6   r   zrdist_gen._logpdf<#  s7    q		zDLL!a%AaC1====r8   c                 R    t                               |dz   dz  |dz  |dz            S r1  r  r  s      r6   ru   zrdist_gen._cdf?#  s(    yy!a%AaC1---r8   c                 R    t                               |dz   dz  |dz  |dz            S r1  r  r  s      r6   ry   zrdist_gen._sfB#  s(    xxQ	1Q3!,,,r8   c                 R    dt                               ||dz  |dz            z  dz
  S r  )ro  r~   r  s      r6   r~   zrdist_gen._ppfE#  s*    1ac1Q3'''!++r8   Nc                 H    d|                     |dz  |dz  |          z  dz
  S r  rn  r  s       r6   r   zrdist_gen._rvsH#  s,    <$$QqS!A#t444q88r8   c                     d|dz  z
  t          j        |dz   dz  |dz            z  }|t          j        d|dz            z  S )Nr   rU   r   r   r   rY  )rE   rb   r  	numerators       r6   r  zrdist_gen._munpK#  sG    !a%[BGQWM1s7$C$CC	2761r62222r8   r  )r   r   r   r   rk   rr   r   ru   ry   r~   r   r  r   r8   r6   r'
  r'
  #  s           BE E E* * *> > >. . .- - -, , ,9 9 9 93 3 3 3 3r8   r'
  rA  rdistc                        e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Ze eed           fd                        Z xZS )rayleigh_gena7  A Rayleigh continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `rayleigh` is:

    .. math::

        f(x) = x \exp(-x^2/2)

    for :math:`x \ge 0`.

    `rayleigh` is a special case of `chi` with ``df=2``.

    %(after_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zrayleigh_gen._shape_infok#  r   r8   Nc                 <    t                               d||          S )NrU   r  rv  r   s      r6   r   zrayleigh_gen._rvsn#  s    wwqt,w???r8   c                 P    t          j        |                     |                    S rN   r  rE   r  s     r6   rr   zrayleigh_gen._pdfq#  r  r8   c                 <    t          j        |          d|z  |z  z
  S r#  r2  r7
  s     r6   r   zrayleigh_gen._logpdfu#  s    vayy37Q;&&r8   c                 8    t          j        d|dz  z             S r  r~  r7
  s     r6   ru   zrayleigh_gen._cdfx#  s    1%%%%r8   c                 V    t          j        dt          j        |           z            S Nr  )rP   r   rw   r  r   s     r6   r~   zrayleigh_gen._ppf{#  s!    wrBHaRLL()))r8   c                 P    t          j        |                     |                    S rN   r;  r7
  s     r6   ry   zrayleigh_gen._sf~#  s    vdkk!nn%%%r8   c                     d|z  |z  S )Nr)  r   r7
  s     r6   r   zrayleigh_gen._logsf#  s    ax!|r8   c                 T    t          j        dt          j        |          z            S r;
  )rP   r   r   r   s     r6   r   zrayleigh_gen._isf#  s    wrBF1II~&&&r8   c                    dt           j        z
  }t          j        t           j        dz            |dz  dt           j        dz
  z  t          j        t           j                  z  |dz  z  dt           j        z  |z  d|dz  z  z
  fS )Nr$  rU   r  r  r  r,  r  r  s     r6   r   zrayleigh_gen._stats#  sp    "%ia  A257BGBENN*383"%BsAvI%' 	'r8   c                 L    t           dz  dz   dt          j        d          z  z
  S )Nr   r   r   rU   r=  rj   s    r6   r   zrayleigh_gen._entropy#  s!    czA~BF1II--r8   a          Notes specifically for ``rayleigh.fit``: If the location is fixed with
        the `floc` parameter, this method uses an analytical formula to find
        the scale.  Otherwise, this function uses a numerical root finder on
        the first order conditions of the log-likelihood function to find the
        MLE.  Only the (optional) `loc` parameter is used as the initial guess
        for the root finder; the `scale` parameter and any other parameters
        for the optimizer are ignored.

r   c                    |                     dd          r t                      j        g|R i |S t          | ||          \  }}fd}fd}|ffd	}|Dt	          j        |z
  dk              rt          ddt          j        	          | ||          fS |                    d
          }	|	| 	                              d         }	||n|}
t	          j
        t	          j                  t          j                   }t          |
|          }t          j        |
||f          }|j        st!          |j                  |j        }|p
 ||          }||fS )Nr@  Fc                 d    t          j        | z
  dz            dt                    z  z  dz  S r  )rP   r  r  )r.   rF   s    r6   	scale_mlez#rayleigh_gen.fit.<locals>.scale_mle#  s2     FD3J1,--SYY?BFFr8   c                     | z
  }|                                 }|dz                                   }d|z                                   }||dt                    z  z  |z  z
  S r  )r  r  )r.   r%  r]  rc  s3rF   s        r6   loc_mlez!rayleigh_gen.fit.<locals>.loc_mle#  s\     BBa%BB$BAc$iiK(+++r8   c                 r    | z
  }|                                 |dz  d|z                                   z  z
  S r  )r  )r.   r/   r%  rF   s      r6   loc_mle_scale_fixedz-rayleigh_gen.fit.<locals>.loc_mle_scale_fixed#  s6     B6688eQh!B$555r8   r   rayleighr   r  r.   r$  )r3   rA   rC   rL  rP   r  rL  ri   r=   r  r\  r  rZ   r   r+   r]  rW   flagrM  )rE   rF   rG   r5   r   r   rC
  rF
  rH
  loc0rI   rS   rR   r  r.   r/   r  s    `              r6   rC   zrayleigh_gen.fit#  s    88J&& 	4577;t3d333d3338t9=tE EdF	G 	G 	G 	G 	G
	, 	, 	, 	, 	, ,2 	6 	6 	6 	6 	6 	6 vdTkQ&'' -":QbfEEEEYYt__,, xx<>>$''*Dgg-@bfTllRVG44"3//"30@AAA} 	+ ***h())C..Ezr8   r  )r   r   r   r   r   r  r  rk   r   rr   r   ru   r~   ry   r   r   r   r   rK   r	   rC   r  r  s   @r6   r3
  r3
  S#  s,        * "4M  @ @ @ @' ' '' ' '& & &* * *& & &  ' ' '' ' '. . . } 5. / / // / / // / _/ / / / /r8   r3
  rI
  c                        e Zd ZdZd Zd Z fdZd Zd Zd Z	d Z
d	 Zd
 Zd ZdZ eee           fd            Z xZS )reciprocal_gena,  A loguniform or reciprocal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for this class is:

    .. math::

        f(x, a, b) = \frac{1}{x \log(b/a)}

    for :math:`a \le x \le b`, :math:`b > a > 0`. This class takes
    :math:`a` and :math:`b` as shape parameters.

    %(after_notes)s

    %(example)s

    This doesn't show the equal probability of ``0.01``, ``0.1`` and
    ``1``. This is best when the x-axis is log-scaled:

    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> fig, ax = plt.subplots(1, 1)
    >>> ax.hist(np.log10(r))
    >>> ax.set_ylabel("Frequency")
    >>> ax.set_xlabel("Value of random variable")
    >>> ax.xaxis.set_major_locator(plt.FixedLocator([-2, -1, 0]))
    >>> ticks = ["$10^{{ {} }}$".format(i) for i in [-2, -1, 0]]
    >>> ax.set_xticklabels(ticks)  # doctest: +SKIP
    >>> plt.show()

    This random variable will be log-uniform regardless of the base chosen for
    ``a`` and ``b``. Let's specify with base ``2`` instead:

    >>> rvs = %(name)s(2**-2, 2**0).rvs(size=1000)

    Values of ``1/4``, ``1/2`` and ``1`` are equally likely with this random
    variable.  Here's the histogram:

    >>> fig, ax = plt.subplots(1, 1)
    >>> ax.hist(np.log2(rvs))
    >>> ax.set_ylabel("Frequency")
    >>> ax.set_xlabel("Value of random variable")
    >>> ax.xaxis.set_major_locator(plt.FixedLocator([-2, -1, 0]))
    >>> ticks = ["$2^{{ {} }}$".format(i) for i in [-2, -1, 0]]
    >>> ax.set_xticklabels(ticks)  # doctest: +SKIP
    >>> plt.show()

    c                     |dk    ||k    z  S r7  r   r  s      r6   rc   zreciprocal_gen._argcheck$      A!a%  r8   c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS rh  rh   ri  s      r6   rk   zreciprocal_gen._shape_info$  rl  r8   c                     t          |t                    r|                                }t                                          |t          j        |          t          j        |          f          S NrN  r?   r*   r  rA   r  rP   r  r  rY  s     r6   r  zreciprocal_gen._fitstart$  sV    dL)) 	$>>##Dww  RVD\\26$<<,H IIIr8   c                 
    ||fS rN   r   r  s      r6   r   zreciprocal_gen._get_support$  r[  r8   c                 T    t          j        |                     |||                    S rN   r  ru  s       r6   rr   zreciprocal_gen._pdf$  r  r8   c                     t          j        |           t          j        t          j        |          t          j        |          z
            z
  S rN   r2  ru  s       r6   r   zreciprocal_gen._logpdf$  s6    q		zBF26!99rvayy#89999r8   c                     t          j        |          t          j        |          z
  t          j        |          t          j        |          z
  z  S rN   r2  ru  s       r6   ru   zreciprocal_gen._cdf$  s7    q		"&))#q		BF1II(=>>r8   c                     t          j        t          j        |          |t          j        |          t          j        |          z
  z  z             S rN   rP   r   r   r  s       r6   r~   zreciprocal_gen._ppf$  s9    vbfQii!RVAYY%:";;<<<r8   c                 6   |dk    rdS dt          j        |          t          j        |          z
  z  |z  }t          j        t          j        t	          |t          j        |          z  |t          j        |          z                                }||z  S )Nr   r   r   )rP   r   r  r   	_log_diff)rE   rb   r   r   r  r  s         r6   r  zreciprocal_gen._munp!$  sx    663"&))bfQii'(1,WRVIa"&))mQrvayy[AABBCCBwr8   c                     dt          j        |          t          j        |          z   z  t          j        t          j        |          t          j        |          z
            z   S r#  r2  r  s      r6   r   zreciprocal_gen._entropy($  sF    BF1IIq		)*RVBF1IIq		4I-J-JJJr8   z        `loguniform`/`reciprocal` is over-parameterized. `fit` automatically
         fixes `scale` to 1 unless `fscale` is provided by the user.

r   c                 n    |                     dd          } t                      j        |g|R d|i|S )Nr   r   )r3   rA   rC   )rE   rF   rG   r5   r   r  s        r6   rC   zreciprocal_gen.fit/$  sA    (A&&uww{4>$>>>v>>>>r8   )r   r   r   r   rc   rk   r  r   rr   r   ru   r~   r  r   fit_noter	   r   rC   r  r  s   @r6   rM
  rM
  #  s       2 2f! ! !  
J J J J J  - - -: : :? ? ?= = =  K K KLH }H===? ? ? ? >=? ? ? ? ?r8   rM
  
loguniform
reciprocalc                   >    e Zd ZdZd Zd Zd
dZd Zd Zd Z	d	 Z
dS )rice_gena  A Rice continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `rice` is:

    .. math::

        f(x, b) = x \exp(- \frac{x^2 + b^2}{2}) I_0(x b)

    for :math:`x >= 0`, :math:`b > 0`. :math:`I_0` is the modified Bessel
    function of order zero (`scipy.special.i0`).

    `rice` takes ``b`` as a shape parameter for :math:`b`.

    %(after_notes)s

    The Rice distribution describes the length, :math:`r`, of a 2-D vector with
    components :math:`(U+u, V+v)`, where :math:`U, V` are constant, :math:`u,
    v` are independent Gaussian random variables with standard deviation
    :math:`s`.  Let :math:`R = \sqrt{U^2 + V^2}`. Then the pdf of :math:`r` is
    ``rice.pdf(x, R/s, scale=s)``.

    %(example)s

    c                     |dk    S r7  r   r	  s     r6   rc   zrice_gen._argcheck\$  r  r8   c                 @    t          dddt          j        fd          gS )Nr   Fr   rg   rh   rj   s    r6   rk   zrice_gen._shape_info_$  r  r8   Nc                     |t          j        d          z  |                    d|z             z   }t          j        ||z                      d                    S )NrU   )rU   r  r   r   )rP   r   r   r  )rE   r   r   r   r  s        r6   r   zrice_gen._rvsb$  sO    bgajjL<77TD[7IIIw!yyay(()))r8   c                 v    t          j        t          j        |          dt          j        |                    S r  )rw   chndtrrP   r%  r  s      r6   ru   zrice_gen._cdfg$  s&    y1q")A,,777r8   c           	      v    t          j        t          j        |dt          j        |                              S r  )rP   r   rw   chndtrixr%  r  s      r6   r~   zrice_gen._ppfj$  s(    wr{1a166777r8   c                 z    |t          j        ||z
   ||z
  z  dz            z  t          j        ||z            z  S r?  )rP   r   rw   i0er  s      r6   rr   zrice_gen._pdfm$  s=     26AaC&!A#,s*+++bfQqSkk99r8   c                     |dz  }d|z   }||z  dz  }d|z  t          j        |           z  t          j        |          z  t          j        |d|          z  S r  )rP   r   rw   r  hyp1f1)rE   rb   r   nd2n1r  s         r6   r  zrice_gen._munpv$  s_    eWqSWc
RVRC[[(28B<<7	"a$$% 	&r8   r  )r   r   r   r   rc   rk   r   ru   r~   rr   r  r   r8   r6   rb
  rb
  ?$  s         8  D D D* * * *
8 8 88 8 8: : :& & & & &r8   rb
  ricec                       e Zd ZdZ eed          d             Zd Zd Zd Z	d Z
ed	             Zd
 Zd Zd ZddZd ZdS )irwinhall_gena\
  An Irwin-Hall (Uniform Sum) continuous random variable.

    An `Irwin-Hall <https://en.wikipedia.org/wiki/Irwin-Hall_distribution/>`_
    continuous random variable is the sum of :math:`n` independent
    standard uniform random variables [1]_ [2]_.

    %(before_notes)s

    Notes
    -----
    Applications include `Rao's Spacing Test
    <https://jammalam.faculty.pstat.ucsb.edu/html/favorite/test.htm>`_,
    a more powerful alternative to the Rayleigh test
    when the data are not unimodal, and radar [3]_.

    Conveniently, the pdf and cdf are the :math:`n`-fold convolution of
    the ones for the standard uniform distribution, which is also the
    definition of the cardinal B-splines of degree :math:`n-1`
    having knots evenly spaced from :math:`1` to :math:`n` [4]_ [5]_.

    The Bates distribution, which represents the *mean* of statistically
    independent, uniformly distributed random variables, is simply the
    Irwin-Hall distribution scaled by :math:`1/n`. For example, the frozen
    distribution ``bates = irwinhall(10, scale=1/10)`` represents the
    distribution of the mean of 10 uniformly distributed random variables.
    
    %(after_notes)s

    References
    ----------
    .. [1] P. Hall, "The distribution of means for samples of size N drawn
            from a population in which the variate takes values between 0 and 1,
            all such values being equally probable",
            Biometrika, Volume 19, Issue 3-4, December 1927, Pages 240-244,
            :doi:`10.1093/biomet/19.3-4.240`.
    .. [2] J. O. Irwin, "On the frequency distribution of the means of samples
            from a population having any law of frequency with finite moments,
            with special reference to Pearson's Type II,
            Biometrika, Volume 19, Issue 3-4, December 1927, Pages 225-239,
            :doi:`0.1093/biomet/19.3-4.225`.
    .. [3] K. Buchanan, T. Adeyemi, C. Flores-Molina, S. Wheeland and D. Overturf, 
            "Sidelobe behavior and bandwidth characteristics
            of distributed antenna arrays,"
            2018 United States National Committee of
            URSI National Radio Science Meeting (USNC-URSI NRSM),
            Boulder, CO, USA, 2018, pp. 1-2.
            https://www.usnc-ursi-archive.org/nrsm/2018/papers/B15-9.pdf.
    .. [4] Amos Ron, "Lecture 1: Cardinal B-splines and convolution operators", p. 1
            https://pages.cs.wisc.edu/~deboor/887/lec1new.pdf.
    .. [5] Trefethen, N. (2012, July). B-splines and convolution. Chebfun. 
            Retrieved April 30, 2024, from http://www.chebfun.org/examples/approx/BSplineConv.html.

    %(example)s
    z        Raises a ``NotImplementedError`` for the Irwin-Hall distribution because
        the generic `fit` implementation is unreliable and no custom implementation
        is available. Consider using `scipy.stats.fit`.

r   c                 $    d}t          |          )NzThe generic `fit` implementation is unreliable for this distribution, and no custom implementation is available. Consider using `scipy.stats.fit`.)r	  )rE   rF   rG   r5   	fit_notess        r6   rC   zirwinhall_gen.fit$  s    
9	 "),,,r8   c                 X    |dk    t          |          z  t          j        |          z  S r7  )r   rP   	isrealobjra   s     r6   rc   zirwinhall_gen._argcheck$  s$    AQ'",q//99r8   c                 
    d|fS r7  r   ra   s     r6   r   zirwinhall_gen._get_support$  r[  r8   c                 @    t          dddt          j        fd          gS rf   rh   rj   s    r6   rk   zirwinhall_gen._shape_info$  rl   r8   c                 ^    d } t          j        |t           j        g          ||          S )Nc                     t          j        |t           j                  }t          j        || z   |d          t          j        || z   |d          z  S )Nr
  T)exact)rP   r   int64rw   	stirling2r  )r^  rb   s     r6   vmunpz"irwinhall_gen._munp.<locals>.vmunp$  sR    
1BH---AL5!4888gagq5556 7r8   r  r  )rE   r^  rb   r~
  s       r6   r  zirwinhall_gen._munp$  s8    	7 	7 	7 8r|E2:,777qAAAr8   c                 X    t          j        | dz             }t          j        |          S r^   )rP   rR  r   basis_element)rb   r  s     r6   	_cardbsplzirwinhall_gen._cardbspl$  s$    IacNN$Q'''r8   c                 d      fd} t          j        |t           j        g          ||          S )Nc                 @                          |          |           S rN   )r
  rq   rb   rE   s     r6   vpdfz irwinhall_gen._pdf.<locals>.vpdf$  s    $4>>!$$Q'''r8   r  r  )rE   rq   rb   r
  s   `   r6   rr   zirwinhall_gen._pdf$  sA    	( 	( 	( 	( 	(6r|D"*666q!<<<r8   c                 d      fd} t          j        |t           j        g          ||          S )Nc                 d                          |                                          |           S rN   r
  antiderivativer
  s     r6   vcdfz irwinhall_gen._cdf.<locals>.vcdf$  s+    54>>!$$3355a888r8   r  r  )rE   rq   rb   r
  s   `   r6   ru   zirwinhall_gen._cdf$  sA    	9 	9 	9 	9 	96r|D"*666q!<<<r8   c                 d      fd} t          j        |t           j        g          ||          S )Nc                 j                          |                                          || z
            S rN   r
  r
  s     r6   vsfzirwinhall_gen._sf.<locals>.vsf$  s/    54>>!$$3355ac:::r8   r  r  )rE   rq   rb   r
  s   `   r6   ry   zirwinhall_gen._sf$  sA    	; 	; 	; 	; 	;5r|C555a;;;r8   Nc                 @    t           dd            } ||||          S )Nc                     t          j        |                               t                    } || fn| g|R }|                    |                              d          S )Nr  r   r   )rP   rK  r  r  r  r  )rb   r   r   usizes       r6   _rvs1z!irwinhall_gen._rvs.<locals>._rvs1$  s\    ""3''A LQDDqj4jjE''U'3377Q7???r8   r  r  )r   )rE   rb   r   r   rG   r
  s         r6   r   zirwinhall_gen._rvs$  s>    	#	@ 	@ 	@ 
$	#	@ uQT====r8   c                 &    |dz  |dz  ddd|z  z  fS )NrU   r  r   r	  rH  r   ra   s     r6   r   zirwinhall_gen._stats$  s#     sAbD!R1X%%r8   r  )r   r   r   r   r
   r   rC   rc   r   rk   r  r  r
  rr   ru   ry   r   r   r   r8   r6   rr
  rr
  $  s       5 5n   6? @ @ @- -	@ @-: : :  C C C	B 	B 	B ( ( \(= = =
= = =
< < <
> > > >& & & & &r8   rr
  	irwinhall)r   rb   c                   8    e Zd ZdZd Zd Zd Zd Zd Zd	dZ	dS )
recipinvgauss_gena  A reciprocal inverse Gaussian continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `recipinvgauss` is:

    .. math::

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

    for :math:`x \ge 0`.

    `recipinvgauss` takes ``mu`` as a shape parameter for :math:`\mu`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   zrecipinvgauss_gen._shape_info%  r  r8   c                 R    t          j        |                     ||                    S rN   r  r  s      r6   rr   zrecipinvgauss_gen._pdf%  s"     vdll1b))***r8   c                 L    t          |dk    ||fd t          j                   S )Nr   c                     d|| z  z
  dz   d| z  |dz  z  z  dt          j        dt           j        z  | z            z  z
  S )Nr   r   rU   r   r   )rq   rD  s     r6   r  z+recipinvgauss_gen._logpdf.<locals>.<lambda>%%  sH    1r!t8c/)9QqSS[)I+.rvagai/@/@+@*A r8   r  r  r  s      r6   r   zrecipinvgauss_gen._logpdf#%  s8    !a%!RB B%'VG- - - 	-r8   c                     d|z  |z
  }d|z  |z   }dt          j        |          z  }t          | |z            t          j        d|z            t          | |z            z  z
  S Nr   r   rP   r   r   r   rE   rq   rD  trm1trm2isqxs         r6   ru   zrecipinvgauss_gen._cdf)%  se    2vz2vz271::~$t$$rvc"f~~id
6K6K'KKKr8   c                     d|z  |z
  }d|z  |z   }dt          j        |          z  }t          ||z            t          j        d|z            t          | |z            z  z   S r
  r
  r
  s         r6   ry   zrecipinvgauss_gen._sf/%  sc    2vz2vz271::~d##bfSVnnYuTz5J5J&JJJr8   Nc                 8    d|                     |d|          z  S r  r  r  s       r6   r   zrecipinvgauss_gen._rvs5%  s"    <$$R4$8888r8   r  )
r   r   r   r   rk   rr   r   ru   ry   r   r   r8   r6   r
  r
  %  s         ,F F F+ + +
- - -L L LK K K9 9 9 9 9 9r8   r
  recipinvgaussc                   D    e Zd ZdZd Zd Zd Zd Zd ZddZ	d	 Z
d
 ZdS )semicircular_gena  A semicircular continuous random variable.

    %(before_notes)s

    See Also
    --------
    rdist

    Notes
    -----
    The probability density function for `semicircular` is:

    .. math::

        f(x) = \frac{2}{\pi} \sqrt{1-x^2}

    for :math:`-1 \le x \le 1`.

    The distribution is a special case of `rdist` with ``c = 3``.

    %(after_notes)s

    References
    ----------
    .. [1] "Wigner semicircle distribution",
           https://en.wikipedia.org/wiki/Wigner_semicircle_distribution

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zsemicircular_gen._shape_info[%  r   r8   c                 V    dt           j        z  t          j        d||z  z
            z  S r  r  r   s     r6   rr   zsemicircular_gen._pdf^%  s#    25y1Q3''r8   c                 |    t          j        dt           j        z            dt          j        | |z            z  z   S r  r  r   s     r6   r   zsemicircular_gen._logpdfa%  s.    vagRXqbd^^!333r8   c                     ddt           j        z  |t          j        d||z  z
            z  t          j        |          z   z  z   S )Nr   r   r   )rP   r   r   r*  r   s     r6   ru   zsemicircular_gen._cdfd%  s:    3ru9a!A#.1=>>>r8   c                 8    t                               |d          S Nr  )r1
  r~   r   s     r6   r~   zsemicircular_gen._ppfg%  s    zz!Qr8   Nc                     t          j        |                    |                    }t          j        t           j        |                    |          z            }||z  S r9  )rP   r   r  r!  r   )rE   r   r   r  r   s        r6   r   zsemicircular_gen._rvsj%  sT     GL((d(3344F25<//T/:::;;1ur8   c                     dS )N)r   r  r   rA  r   rj   s    r6   r   zsemicircular_gen._statsq%  rr  r8   c                     dS )NgzCϑ?r   rj   s    r6   r   zsemicircular_gen._entropyt%  s    %%r8   r  )r   r   r   r   rk   rr   r   ru   r~   r   r   r   r   r8   r6   r
  r
  <%  s         <  ( ( (4 4 4? ? ?             & & & & &r8   r
  semicircularc                   >    e Zd ZdZd Zd Zd Zd Zd ZddZ	d	 Z
d
S )skewcauchy_gena  A skewed Cauchy random variable.

    %(before_notes)s

    See Also
    --------
    cauchy : Cauchy distribution

    Notes
    -----

    The probability density function for `skewcauchy` is:

    .. math::

        f(x) = \frac{1}{\pi \left(\frac{x^2}{\left(a\, \text{sign}(x) + 1
                                                   \right)^2} + 1 \right)}

    for a real number :math:`x` and skewness parameter :math:`-1 < a < 1`.

    When :math:`a=0`, the distribution reduces to the usual Cauchy
    distribution.

    %(after_notes)s

    References
    ----------
    .. [1] "Skewed generalized *t* distribution", Wikipedia
       https://en.wikipedia.org/wiki/Skewed_generalized_t_distribution#Skewed_Cauchy_distribution

    %(example)s

    c                 2    t          j        |          dk     S r^   )rP   r  r  s     r6   rc   zskewcauchy_gen._argcheck%  s    vayy1}r8   c                 (    t          dddd          gS )Nr   F)rA  r   r
  r   rj   s    r6   rk   zskewcauchy_gen._shape_info%  s    3{NCCDDr8   c                 n    dt           j        |dz  |t          j        |          z  dz   dz  z  dz   z  z  S r1  )rP   r   rQ   r  s      r6   rr   zskewcauchy_gen._pdf%  s8    BEQTQ^a%7!$;;a?@AAr8   c                    t          j        |dk    d|z
  dz  d|z
  t           j        z  t          j        |d|z
  z            z  z   d|z
  dz  d|z   t           j        z  t          j        |d|z   z            z  z             S Nr   r   rU   )rP   rT  r   r  r  s      r6   ru   zskewcauchy_gen._cdf%  s    xQQ!q1uo	!q1u+8N8N&NNQ!q1uo	!q1u+8N8N&NNP P 	Pr8   c           
      2   ||                      d|          k     }t          j        |t          j        t          j        d|z
  z  |d|z
  dz  z
  z            d|z
  z  t          j        t          j        d|z   z  |d|z
  dz  z
  z            d|z   z            S r
  )ru   rP   rT  r  r   )rE   rq   r   r  s       r6   r~   zskewcauchy_gen._ppf%  s    		!QxruA!q1uk/BCCq1uMruA!q1uk/BCCq1uMO O 	Or8   r  c                 ^    t           j        t           j        t           j        t           j        fS rN   r  )rE   r   r  s      r6   r   zskewcauchy_gen._stats%  r  r8   c                     t          |t                    r|                                }t          j        |g d          \  }}}d|||z
  dz  fS )Nr  r   rU   r  )rE   rF   r  r  r  s        r6   r  zskewcauchy_gen._fitstart%  sU     dL)) 	$>>##DdLLL99S#C#)Q&&r8   Nr  )r   r   r   r   rc   rk   rr   ru   r~   r   r  r   r8   r6   r
  r
  {%  s           B  E E EB B BP P P
O O O. . . .' ' ' ' 'r8   r
  
skewcauchyc                        e Zd ZdZd Zd Zd Zd Z fdZd Z	d Z
d	 ZddZddZed             Zd Z eed           fd            Z xZS )skewnorm_genaA  A skew-normal random variable.

    %(before_notes)s

    Notes
    -----
    The pdf is::

        skewnorm.pdf(x, a) = 2 * norm.pdf(x) * norm.cdf(a*x)

    `skewnorm` takes a real number :math:`a` as a skewness parameter
    When ``a = 0`` the distribution is identical to a normal distribution
    (`norm`). `rvs` implements the method of [1]_.

    This distribution uses routines from the Boost Math C++ library for
    the computation of ``cdf``, ``ppf`` and ``isf`` methods. [2]_

    %(after_notes)s

    References
    ----------
    .. [1] A. Azzalini and A. Capitanio (1999). Statistical applications of
        the multivariate skew-normal distribution. J. Roy. Statist. Soc.,
        B 61, 579-602. :arxiv:`0911.2093`
    .. [2] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/.

    %(example)s

    c                 *    t          j        |          S rN   r  r  s     r6   rc   zskewnorm_gen._argcheck%  r  r8   c                 V    t          ddt          j         t          j        fd          gS )Nr   Fr
  rh   rj   s    r6   rk   zskewnorm_gen._shape_info%  r  r8   c                 8    t          |dk    ||fd d           S )Nr   c                      t          |           S rN   r   rq   r   s     r6   r  z#skewnorm_gen._pdf.<locals>.<lambda>%  s    1 r8   c                 L    dt          |           z  t          || z            z  S r?  r
  r
  s     r6   r  z#skewnorm_gen._pdf.<locals>.<lambda>%  s    By||OIacNN: r8   r  r  r  s      r6   rr   zskewnorm_gen._pdf%  s2    FQF55::
 
 
 	
r8   c                 8    t          |dk    ||fd d           S )Nr   c                      t          |           S rN   r   r
  s     r6   r  z&skewnorm_gen._logpdf.<locals>.<lambda>%  s    a r8   c                 p    t          j        d          t          |           z   t          || z            z   S r  r
  r
  s     r6   r  z&skewnorm_gen._logpdf.<locals>.<lambda>%  s*    BF1IIl1oo5l1Q36G6GG r8   r  r  r  s      r6   r   zskewnorm_gen._logpdf%  s2    FQF88GG
 
 
 	
r8   c                 6   t          j        |          }t          j        |dd|          }t          j        ||j                  }|dk     |dk    z  }t                                          ||         ||                   ||<   t          j        |dd          S )Nr   r   gư>r   r   )	rP   r  rn   _skewnorm_cdfrq	  r  rA   ru   r	  )rE   rq   r   r   i_small_cdfr  s        r6   ru   zskewnorm_gen._cdf%  s    M!3Q//OAsy))Tza!e, 77<<++GGKwsAq!!!r8   c                 0    t          j        |dd|          S Nr   r   )rn   _skewnorm_ppfr  s      r6   r~   zskewnorm_gen._ppf%       Ca000r8   c                 2    |                      | |           S rN   r  r  s      r6   ry   zskewnorm_gen._sf%  s     yy!aR   r8   c                 0    t          j        |dd|          S r
  )rn   _skewnorm_isfr  s      r6   r   zskewnorm_gen._isf&  r
  r8   Nc                    |                     |          }|                     |          }|t          j        d|dz  z             z  }||z  |t          j        d|dz  z
            z  z   }t          j        |dk    ||           S )Nr  r   rU   r   )r:  rP   r   rT  )rE   r   r   r   u0r  r  r  s           r6   r   zskewnorm_gen._rvs&  s      d ++T**bga!Q$hrTAbga!Q$h''''xabS)))r8   r  c                    g d}t          j        dt           j        z            |z  t          j        d|dz  z             z  }d|v r||d<   d|v rd|dz  z
  |d<   d|v r6dt           j        z
  dz  |t          j        d|dz  z
            z  d	z  z  |d<   d
|v r'dt           j        d	z
  z  |dz  d|dz  z
  dz  z  z  |d	<   |S )Nrt  rU   r   rD  r   r  r  r$  r  r  rZ  )rE   r   r  r2  consts        r6   r   zskewnorm_gen._stats&  s    )))"%  1$RWQAX%6%66'>>F1I'>>E1HF1I'>>be)Q5UAX1F1F+F*JJF1I'>>BEAI5!8Q\A4E+EFF1Ir8   c                 J   t          dg          t          ddg          t          g d          t          g d          t          g d          t          g d          t          g d          t          g d	          t          g d
          t          g d          d
}|S )Nr   r  r  )r  ir  )i   i?   i)i  iin  ir
  )(  iSi6Q  ii  iO)i iBi/ iio ir
  ) iԷi iYei{Hx ii i!)	i!iׅi쇀iiViX'ilir
  )
is_'il   </1 ldy( l   J8D l.~ l   -Rx iWi[i0)
r   r  rH  r  r  r     r        r   )rE   skewnorm_odd_momentss     r6   _skewnorm_odd_momentsz"skewnorm_gen._skewnorm_odd_moments"&  s     1#1b'"",,,''...//77788EEEFF # # # $ $ 8 8 8 9 9 % % % & &  2 2 2 3 3 
  
$ $#r8   c                    |dz  rV|dk    rt          d          |t          j        d|dz  z             z  }| | j        |         |dz            z  t          z  S t          j        |dz   dz            d|dz  z  z  t          z  S )NrU   r
  zKskewnorm noncentral moments not implemented for odd orders greater than 19.r   )r	  rP   r   r
  r'   rw   r  r&   )rE   r^  r   r'  s       r6   r  zskewnorm_gen._munp8&  s    19 	Erzz) +5 6 6 6
 bga!Q$h'''E=D6u=eQhGGG%& ' 8UQYM**Qq\9HDDr8   a          If ``method='mm'``, parameters fixed by the user are respected, and the
        remaining parameters are used to match distribution and sample moments
        where possible. For example, if the user fixes the location with
        ``floc``, the parameters will only match the distribution skewness and
        variance to the sample skewness and variance; no attempt will be made
        to match the means or minimize a norm of the errors.
        Note that the maximum possible skewness magnitude of a
        `scipy.stats.skewnorm` distribution is approximately 0.9952717; if the
        magnitude of the data's sample skewness exceeds this, the returned
        shape parameter ``a`` will be infinite.
        

r   c           	         |                     dd          r t                      j        |g|R i |S t          |t                    rJ|                                dk    r|                                }n t                      j        |g|R i |S t          | |||          \  }}}}|                    dd          	                                }d }d }	|dk    rd	\  }
}}nEt          |          r|d         nd }
|                     d
d           }|                     dd           }||
t          j        |          }|dk    rt          j        |dd          }n" |d          }t          j        || |          } |	|          }t          j        d          5  t          j        t          j        |dz  d|dz  z
                      t          j        |          z  }
d d d            n# 1 swxY w Y   n#||n|
}
|
t          j        d|
dz  z             z  }|D|Bt          j        |          }t          j        |dd|dz  z  t          j        z  z
  z            }n||}|A|?t          j        |          }|||z  t          j        dt          j        z            z  z
  }n||}|dk    r|
||fS  t                      j        ||
f||d|S )Nr@  Fr   r1   r;   c                     dt           j        z
  dz  | t          j        dt           j        z            z  dz  dd| dz  z  t           j        z  z
  dz  z  z  S )Nr$  rU   r  r   r  r  r  s    r6   skew_dz skewnorm_gen.fit.<locals>.skew_di&  sX    beGQ;1rwq25y'9'9#9A"=%&1a4"%%73$?#@ A Ar8   c                     t          j        |           dz  }t          j        |           t          j        t           j        dz  |z  |dt           j        z
  dz  dz  z   z            z  S )Nr  rU   r$  )rP   r  rQ   r   r   )rF  s_23s     r6   d_skewz skewnorm_gen.fit.<locals>.d_skewm&  s]    6$<<#&D74==27a$$1ru9a-3)?"?@$ $  r8   r<   rG  r.   r/   gGzgGz?r   r9  r:  rU   rK  )r3   rA   rC   r?   r*   r@   r  rL  r=   r>   r  r  rF  rP   r	  r<  r   r;  rQ   r  r   r   )rE   rF   rG   r5   r  r   r   r1   r
  r
  r   r.   r/   r  s_maxr  r  rD  r  s                     r6   rC   zskewnorm_gen.fitL&  sl    88J&& 	4577;t3d333d333dL)) 	8  ""a''~~''"uww{47$777$777 "=T4=A4"I "Ib$(E**0022	A 	A 	A	 	 	 T>>,MAsEEt99.Q$A((5$''CHHWd++E:!) 
4  A GAud++q		GAvu--q		AH--- B BGBIadQq!tV5566rwqzzAB B B B B B B B B B B B B B B n!ABGA1H%%%A>emtAGAQq!tVBE\!1233EEE<CKAeAgbgag....CCCT>>c5=  577;tQECuEEEEEs   "AG44G8;G8r  r  )r   r   r   r   rc   rk   rr   r   ru   r~   ry   r   r   r   r   r
  r  r	   r   rC   r  r  s   @r6   r
  r
  %  sV        :  K K K
 
 

 
 
" " " " "1 1 1! ! !
1 1 1* * * *   * $ $ _$*E E E( } 5   GF GF GF GF GF GF GF GF GFr8   r
  skewnormc                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
trapezoid_gena  A trapezoidal continuous random variable.

    %(before_notes)s

    Notes
    -----
    The trapezoidal distribution can be represented with an up-sloping line
    from ``loc`` to ``(loc + c*scale)``, then constant to ``(loc + d*scale)``
    and then downsloping from ``(loc + d*scale)`` to ``(loc+scale)``.  This
    defines the trapezoid base from ``loc`` to ``(loc+scale)`` and the flat
    top from ``c`` to ``d`` proportional to the position along the base
    with ``0 <= c <= d <= 1``.  When ``c=d``, this is equivalent to `triang`
    with the same values for `loc`, `scale` and `c`.
    The method of [1]_ is used for computing moments.

    `trapezoid` takes :math:`c` and :math:`d` as shape parameters.

    %(after_notes)s

    The standard form is in the range [0, 1] with c the mode.
    The location parameter shifts the start to `loc`.
    The scale parameter changes the width from 1 to `scale`.

    %(example)s

    References
    ----------
    .. [1] Kacker, R.N. and Lawrence, J.F. (2007). Trapezoidal and triangular
       distributions for Type B evaluation of standard uncertainty.
       Metrologia 44, 117-127. :doi:`10.1088/0026-1394/44/2/003`


    c                 F    |dk    |dk    z  |dk    z  |dk    z  ||k    z  S r  r   rE   r  r  s      r6   rc   ztrapezoid_gen._argcheck&  s0    Q16"a1f-a8AFCCr8   c                 R    t          dddd          }t          dddd          }||gS )Nr  Fr   r   TTr  r
  r%  s      r6   rk   ztrapezoid_gen._shape_info&  s1    UHl;;UHl;;Bxr8   c                 z    d||z
  dz   z  }t          ||k     ||k    ||k    z  ||k    gd d d g||||f          S )NrU   r   c                     || z  |z  S rN   r   rq   r  r  r  s       r6   r  z$trapezoid_gen._pdf.<locals>.<lambda>&  s    q1uqy r8   c                     |S rN   r   r
  s       r6   r  z$trapezoid_gen._pdf.<locals>.<lambda>&  s    q r8   c                     |d| z
  z  d|z
  z  S r^   r   r
  s       r6   r  z$trapezoid_gen._pdf.<locals>.<lambda>&  s    qAaCyAaC/@ r8   r   )rE   rq   r  r  r  s        r6   rr   ztrapezoid_gen._pdf&  sn    1QKAE!VQ/E# 9800@@B q!Q<) ) 	)r8   c                 b    t          ||k     ||k    ||k    z  ||k    gd d d g|||f          S )Nc                 $    | dz  |z  ||z
  dz   z  S r  r   rq   r  r  s      r6   r  z$trapezoid_gen._cdf.<locals>.<lambda>&  s    AqD1H!A,> r8   c                 *    |d| |z
  z  z   ||z
  dz   z  S r  r   r
  s      r6   r  z$trapezoid_gen._cdf.<locals>.<lambda>&  s    Qac]qs1u,E r8   c                 6    dd| z
  dz  ||z
  dz   z  d|z
  z  z
  S r1  r   r
  s      r6   r  z$trapezoid_gen._cdf.<locals>.<lambda>&  s3    A!z23A#a%09<=aC0A -B r8   r
  r8  s       r6   ru   ztrapezoid_gen._cdf&  sa    AE!VQ/E# ?>EEB BC q!9& & 	&r8   c                 b   |                      |||          |                      |||          }}||k     ||k    ||k    g}t          j        ||z  d|z   |z
  z            d|z  d|z   |z
  z  d|z  z   dt          j        d|z
  ||z
  dz   z  d|z
  z            z
  g}t          j        ||          S r&  )ru   rP   r   select)rE   r}   r  r  qcqdr  r|	  s           r6   r~   ztrapezoid_gen._ppf&  s    1a##TYYq!Q%7%7BFAGQV,ga!eq1uqy122AgQ+cAg5"'1q5QUQY"71q5"ABBBD
 y:...r8   c                     |dz   z  }t          |dk    d|k     |dk     z  |dk    gd fdfdg|g          }dd|z   |z
  z  ||z
  z  dz   dz   z  z  }|S )	Nr   r   r   c                     dS r  r   r
  s    r6   r  z%trapezoid_gen._munp.<locals>.<lambda>&  s    s r8   c                 h    t          j        dz   t          j        |           z            | dz
  z  S r  )rP   r  r   r  rb   s    r6   r  z%trapezoid_gen._munp.<locals>.<lambda>&  s+    rx1q		 122ae< r8   c                     dz   S r  r   r  s    r6   r  z%trapezoid_gen._munp.<locals>.<lambda> '  s    qs r8   r   rU   r
  )rE   rb   r  r  ab_termdc_termr}  s    `     r6   r  ztrapezoid_gen._munp&  s     ac(#XaAG,a3h7]<<<<]]] C  SU1Wo7!23!!}E
r8   c                 f    dd|z
  |z   z  d|z   |z
  z  t          j        dd|z   |z
  z            z   S r   r2  r
  s      r6   r   ztrapezoid_gen._entropy'  s>     c!eAg#a%'*RVC3q57O-D-DDDr8   N)r   r   r   r   rc   rk   rr   ru   r~   r  r   r   r8   r6   r
  r
  &  s           BD D D  
	) 	) 	)& & &/ / /  2E E E E Er8   r
  zS`trapz` is deprecated in favour of `trapezoid` and will be removed in SciPy 1.16.0.c                       e Zd ZdZd ZdS )	trapz_genz

    .. deprecated:: 1.14.0
        `trapz` is deprecated and will be removed in SciPy 1.16.
        Plese use `trapezoid` instead!
    c                 ^    t          j        t          t          d            | j        |i |S NrU   rI  )rL  rM  deprmsgDeprecationWarningfreeze)rE   rG   r5   s      r6   __call__ztrapz_gen.__call__'  s1    g1a@@@@t{D)D)))r8   N)r   r   r   r   r  r   r8   r6   r  r  '  s-         * * * * *r8   r  	trapezoidtrapz)r   entropyexpectrC   intervalr  logcdfr  logsfr   r  r`  pdfr  r  r  r  stdr  c                       e Zd Zd Zd ZdS )_DeprecationWrapperc                 V    d| d| d| _         t          t          |          | _        d S )Nz`trapz.z'` is deprecated in favour of trapezoid.zt. Please replace all uses of the distribution class `trapz` with `trapezoid`. `trapz` will be removed in SciPy 1.16.)rY   getattrr  r1   )rE   r1   s     r6   rQ  z_DeprecationWrapper.__init__/'  sE    Xf X XV X X X i00r8   c                 ^    t          j        | j        t          d            | j        |i |S r
  )rL  rM  rY   r  r1   )rE   rG   kwargss      r6   r  z_DeprecationWrapper.__call__5'  s3    dh 2qAAAAt{D+F+++r8   N)r   r   r   rQ  r  r   r8   r6   r  r  .'  s2        1 1 1, , , , ,r8   r  c                   D    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 ZdS )
triang_gena5  A triangular continuous random variable.

    %(before_notes)s

    Notes
    -----
    The triangular distribution can be represented with an up-sloping line from
    ``loc`` to ``(loc + c*scale)`` and then downsloping for ``(loc + c*scale)``
    to ``(loc + scale)``.

    `triang` takes ``c`` as a shape parameter for :math:`0 \le c \le 1`.

    %(after_notes)s

    The standard form is in the range [0, 1] with c the mode.
    The location parameter shifts the start to `loc`.
    The scale parameter changes the width from 1 to `scale`.

    %(example)s

    Nc                 2    |                     d|d|          S r  )
triangularr  s       r6   r   ztriang_gen._rvsT'  s    &&q!Q555r8   c                     |dk    |dk    z  S r  r   r  s     r6   rc   ztriang_gen._argcheckW'  s    Q16""r8   c                 (    t          dddd          gS )Nr  Fr
  r
  r
  rj   s    r6   rk   ztriang_gen._shape_infoZ'  s    3x>>??r8   c                 r    t          |dk    ||k     ||k    |dk    z  |dk    gd d d d g||f          }|S )Nr   r   c                     dd| z  z
  S r  r   r  s     r6   r  z!triang_gen._pdf.<locals>.<lambda>g'  s    a!a%i r8   c                     d| z  |z  S r  r   r  s     r6   r  z!triang_gen._pdf.<locals>.<lambda>h'      a!eai r8   c                     dd| z
  z  d|z
  z  S r  r   r  s     r6   r  z!triang_gen._pdf.<locals>.<lambda>i'  s    a1q5kQU&; r8   c                     d| z  S r  r   r  s     r6   r  z!triang_gen._pdf.<locals>.<lambda>j'  
    a!e r8   r
  rE   rq   r  r  s       r6   rr   ztriang_gen._pdf]'  sk     aQq&Q!V,a! 0///;;++- A    r8   c                 r    t          |dk    ||k     ||k    |dk    z  |dk    gd d d d g||f          }|S )Nr   r   c                     d| z  | | z  z
  S r  r   r  s     r6   r  z!triang_gen._cdf.<locals>.<lambda>s'  s    acAaCi r8   c                     | | z  |z  S rN   r   r  s     r6   r  z!triang_gen._cdf.<locals>.<lambda>t'  r'  r8   c                 *    | | z  d| z  z
  |z   |dz
  z  S r  r   r  s     r6   r  z!triang_gen._cdf.<locals>.<lambda>u'  s    qsQqSy1}1&= r8   c                     | | z  S rN   r   r  s     r6   r  z!triang_gen._cdf.<locals>.<lambda>v'  r*  r8   r
  r+  s       r6   ru   ztriang_gen._cdfn'  si    aQq&Q!V,a! 0///==++- A    r8   c           
          t          j        ||k     t          j        ||z            dt          j        d|z
  d|z
  z            z
            S r^   )rP   rT  r   r  s      r6   r~   ztriang_gen._ppfz'  sA    xArwq1u~~q!A#!A#1G1G/GHHHr8   c           	          |dz   dz  d|z
  ||z  z   dz  t          j        d          d|z  dz
  z  |dz   z  |dz
  z  dt          j        d|z
  ||z  z   d          z  z  dfS )	Nr   rI     rU   r   rH  r  g333333)rP   r   r  r  s     r6   r   ztriang_gen._stats}'  sy    3QqsB

AaCE"AaC(!A#.!BHc!eAaCi#4N4N2NO 	r8   c                 0    dt          j        d          z
  S r  r2  r  s     r6   r   ztriang_gen._entropy'  s    26!99}r8   r  )r   r   r   r   r   rc   rk   rr   ru   r~   r   r   r   r8   r6   r  r  >'  s         *6 6 6 6# # #@ @ @  "
 
 
I I I      r8   r  triangc                   X     e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Z fd
Zd Z xZS )truncexpon_genad  A truncated exponential continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `truncexpon` is:

    .. math::

        f(x, b) = \frac{\exp(-x)}{1 - \exp(-b)}

    for :math:`0 <= x <= b`.

    `truncexpon` takes ``b`` as a shape parameter for :math:`b`.

    %(after_notes)s

    %(example)s

    c                 @    t          dddt          j        fd          gS r  rh   rj   s    r6   rk   ztruncexpon_gen._shape_info'  r  r8   c                     | j         |fS rN   r8  r	  s     r6   r   ztruncexpon_gen._get_support'      vqyr8   c                 Z    t          j        |           t          j        |            z  S rN   r  r  s      r6   rr   ztruncexpon_gen._pdf'  s#    vqbzzBHaRLL=))r8   c                 Z    | t          j        t          j        |                      z
  S rN   r  r  s      r6   r   ztruncexpon_gen._logpdf'  s%    rBFBHaRLL=))))r8   c                 X    t          j        |           t          j        |           z  S rN   r~  r  s      r6   ru   ztruncexpon_gen._cdf'  s!    x||BHaRLL((r8   c                 X    t          j        |t          j        |           z             S rN   )rw   r  r  r  s      r6   r~   ztruncexpon_gen._ppf'  s#    28QB<<((((r8   c                     t          j        |           t          j        |           z
  t          j        |           z  S rN   r  r  s      r6   ry   ztruncexpon_gen._sf'  s0    r

RVQBZZ'1"55r8   c                     t          j        t          j        |           |t          j        |           z  z
             S rN   )rP   r   r   rw   r  r  s      r6   r   ztruncexpon_gen._isf'  s3    rvqbzzA!$445555r8   c                 R   |dk    r5d|dz   t          j        |           z  z
  t          j        |            z  S |dk    rDddd||z  d|z  z   dz   z  t          j        |           z  z
  z  t          j        |            z  S t	                                          ||          S rK  )rP   r   rw   r  rA   r  )rE   rb   r   r  s      r6   r  ztruncexpon_gen._munp'  s     66qsBFA2JJ&&"(A2,,77!VVaQqS1WQYr

223bhrll]CC 77==A&&&r8   c                 |    t          j        |          }t          j        |dz
            d||dz
  z  z   d|z
  z  z   S r  rY
  )rE   r   eBs      r6   r   ztruncexpon_gen._entropy'  s;    VAYYvbd||Qr1S5z\CF333r8   )r   r   r   r   rk   r   rr   r   ru   r~   ry   r   r  r   r  r  s   @r6   r7  r7  '  s         *E E E  * * ** * *) ) )) ) )6 6 66 6 6	' 	' 	' 	' 	'4 4 4 4 4 4 4r8   r7  
truncexpon)r   r   c                 2    t          j        | |gd          S )Nr   r   )rw   rJ  log_plog_qs     r6   _log_sumrI  '  s    <Q////r8   c                 R    t          j        | |t          j        dz  z   gd          S )N              ?r   r   )rw   rJ  rP   r   rF  s     r6   r[
  r[
  '  s&    <beBh/a8888r8   c                    t          j        | |          \  } }|dk    }| dk    }||z   }d fd}d }t          j        | t           j        t           j                  }| |         j        r | |         ||                   ||<   | |         j        r || |         ||                   ||<   | |         j        r || |         ||                   ||<   t          j        |          S )z3Log of Gaussian probability mass within an intervalr   c                 V    t          t          |          t          |                     S rN   )r[
  r   r  s     r6   mass_case_leftz'_log_gauss_mass.<locals>.mass_case_left'  s    a,q//:::r8   c                       | |            S rN   r   )r   r   rN  s     r6   mass_case_rightz(_log_gauss_mass.<locals>.mass_case_right'  s    ~qb1"%%%r8   c                 h    t          j        t          |            t          |           z
            S rN   )rw   r  r   r  s     r6   mass_case_centralz*_log_gauss_mass.<locals>.mass_case_central'  s)     x1	1"5666r8   )r  r  )rP   r  r  r  
complex128r   r  )	r   r   	case_left
case_rightcase_centralrP  rR  r  rN  s	           @r6   _log_gauss_massrW  '  s$   q!$$DAq QIQJ+,L; ; ;& & & & &7 7 7 ,qRV2=
A
A
AC| D')a	lCCI} H)/!J-:GGJ P--aoqOOL73<<r8   c                   x     e Zd ZdZd Zd Z fdZd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZddZ xZS )truncnorm_genaw
  A truncated normal continuous random variable.

    %(before_notes)s

    Notes
    -----
    This distribution is the normal distribution centered on ``loc`` (default
    0), with standard deviation ``scale`` (default 1), and truncated at ``a``
    and ``b`` *standard deviations* from ``loc``. For arbitrary ``loc`` and
    ``scale``, ``a`` and ``b`` are *not* the abscissae at which the shifted
    and scaled distribution is truncated.

    .. note::
        If ``a_trunc`` and ``b_trunc`` are the abscissae at which we wish
        to truncate the distribution (as opposed to the number of standard
        deviations from ``loc``), then we can calculate the distribution
        parameters ``a`` and ``b`` as follows::

            a, b = (a_trunc - loc) / scale, (b_trunc - loc) / scale

        This is a common point of confusion. For additional clarification,
        please see the example below.

    %(example)s

    In the examples above, ``loc=0`` and ``scale=1``, so the plot is truncated
    at ``a`` on the left and ``b`` on the right. However, suppose we were to
    produce the same histogram with ``loc = 1`` and ``scale=0.5``.

    >>> loc, scale = 1, 0.5
    >>> rv = truncnorm(a, b, loc=loc, scale=scale)
    >>> x = np.linspace(truncnorm.ppf(0.01, a, b),
    ...                 truncnorm.ppf(0.99, a, b), 100)
    >>> r = rv.rvs(size=1000)

    >>> fig, ax = plt.subplots(1, 1)
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
    >>> ax.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2)
    >>> ax.set_xlim(a, b)
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()

    Note that the distribution is no longer appears to be truncated at
    abscissae ``a`` and ``b``. That is because the *standard* normal
    distribution is first truncated at ``a`` and ``b``, *then* the resulting
    distribution is scaled by ``scale`` and shifted by ``loc``. If we instead
    want the shifted and scaled distribution to be truncated at ``a`` and
    ``b``, we need to transform these values before passing them as the
    distribution parameters.

    >>> a_transformed, b_transformed = (a - loc) / scale, (b - loc) / scale
    >>> rv = truncnorm(a_transformed, b_transformed, loc=loc, scale=scale)
    >>> x = np.linspace(truncnorm.ppf(0.01, a, b),
    ...                 truncnorm.ppf(0.99, a, b), 100)
    >>> r = rv.rvs(size=10000)

    >>> fig, ax = plt.subplots(1, 1)
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
    >>> ax.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2)
    >>> ax.set_xlim(a-0.1, b+0.1)
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()
    c                     ||k     S rN   r   r  s      r6   rc   ztruncnorm_gen._argcheck@(  s    1ur8   c                     t          ddt          j         t          j        fd          }t          ddt          j         t          j        fd          }||gS )Nr   Frg   r   )FTrh   ri  s      r6   rk   ztruncnorm_gen._shape_infoC(  sG    UbfWbf$5}EEUbfWbf$5}EEBxr8   c                     t          |t                    r|                                }t                                          |t          j        |          t          j        |          f          S rR
  rS
  rY  s     r6   r  ztruncnorm_gen._fitstartH(  sV    dL)) 	$>>##Dww  RVD\\26$<<,H IIIr8   c                 
    ||fS rN   r   r  s      r6   r   ztruncnorm_gen._get_supportN(  r[  r8   c                 T    t          j        |                     |||                    S rN   r  ru  s       r6   rr   ztruncnorm_gen._pdfQ(  r]  r8   c                 B    t          |          t          ||          z
  S rN   )r   rW  ru  s       r6   r   ztruncnorm_gen._logpdfT(  s    AA!6!666r8   c                 T    t          j        |                     |||                    S rN   rT  ru  s       r6   ru   ztruncnorm_gen._cdfW(  r]  r8   c           
      v   t          j        |||          \  }}}t          j        t          ||          t          ||          z
            }|dk    }t          j        |          rQt          j        t          j        |                     ||         ||         ||                                        ||<   |S Ng)rP   r  r   rW  r  r  r   r   )rE   rq   r   r   r  r  s         r6   r   ztruncnorm_gen._logcdfZ(  s    %aA..1aOAq11OAq4I4IIJJTM6!99 	I"&QqT1Q41)F)F"G"G!GHHF1Ir8   c                 T    t          j        |                     |||                    S rN   r;  ru  s       r6   ry   ztruncnorm_gen._sfb(  r<  r8   c           
      v   t          j        |||          \  }}}t          j        t          ||          t          ||          z
            }|dk    }t          j        |          rQt          j        t          j        |                     ||         ||         ||                                        ||<   |S rb  )rP   r  r   rW  r  r  r   r   )rE   rq   r   r   r  r  s         r6   r   ztruncnorm_gen._logsfe(  s    %aA..1a
?1a00?1a3H3HHIIDL6!99 	IxQqT1Q41(F(F!G!G GHHE!Hr8   c                 2   t          |          }t          |          }||z
  }t          j        t          j        dt          j        z  t          j        z            |z            }|t          |          z  |t          |          z  z
  d|z  z  }||z   }|S r  )r   rP   r   r   r   ro  r   )	rE   r   r   rq  rr  r<  rF  Dr  s	            r6   r   ztruncnorm_gen._entropym(  s    aLLaLLEF271ru9rt+,,q0111IaLL 00QU;Er8   c                 ,   t          j        |||          \  }}}|dk     }| }d }d }t          j        |          }||         }	||         }
|	j        r ||	||         ||                   ||<   |
j        r ||
||         ||                   ||<   |S )Nr   c                     t          t          |          t          j        |           t	          ||          z             }t          j        |          S rN   )rI  r   rP   r   rW  rw   	ndtri_expr}   r   r   	log_Phi_xs       r6   ppf_leftz$truncnorm_gen._ppf.<locals>.ppf_left|(  sE     a!#_Q-B-B!BD DI<	***r8   c                     t          t          |           t          j        |            t	          ||          z             }t          j        |           S rN   )rI  r   rP   r  rW  rw   ri  rj  s       r6   	ppf_rightz%truncnorm_gen._ppf.<locals>.ppf_right(  sN     qb!1!1!#1"10E0E!EG GIL++++r8   rP   r  
empty_liker   )rE   r}   r   r   rT  rU  rl  rn  r  q_leftq_rights              r6   r~   ztruncnorm_gen._ppfv(  s    %aA..1aE	Z
	+ 	+ 	+
	, 	, 	,
 mA9J-; 	J%Xfa	lAiLIIC	N< 	O'i:*NNC
O
r8   c                 ,   t          j        |||          \  }}}|dk     }| }d }d }t          j        |          }||         }	||         }
|	j        r ||	||         ||                   ||<   |
j        r ||
||         ||                   ||<   |S )Nr   c                     t          t          |          t          j        |           t	          ||          z             }t          j        t          j        |                    S rN   )r[
  r   rP   r   rW  rw   ri  r  rj  s       r6   isf_leftz$truncnorm_gen._isf.<locals>.isf_left(  sO    !,q//"$&))oa.C.C"CE EI<	 2 2333r8   c                     t          t          |           t          j        |            t	          ||          z             }t          j        t          j        |                     S rN   )r[
  r   rP   r  rW  rw   ri  r  rj  s       r6   	isf_rightz%truncnorm_gen._isf.<locals>.isf_right(  sX    !,r"2"2"$(A2,,A1F1F"FH HIL!3!34444r8   ro  )rE   r}   r   r   rT  rU  ru  rw  r  rq  rr  s              r6   r   ztruncnorm_gen._isf(  s    %aA..1aE	Z
	4 	4 	4
	5 	5 	5
 mA9J-; 	J%Xfa	lAiLIIC	N< 	O'i:*NNC
O
r8   c                       fd}t          |dk    ||k    z  ||k    z  |||ft          j        |t          j        g          t          j                  S )Nc                 T  	 
                     t          j        ||g          ||          \  }}|| g}ddg}t          d| dz             D ]T	t	          ||||gg	fdd          }t          j        |          	dz
  |d         z  z   }|                    |           U|d         S )z
            Returns n-th moment. Defined only if n >= 0.
            Function cannot broadcast due to the loop over n
            r   r   c                     | |dz
  z  z  S r^   r   )rq   r  r  s     r6   r  z:truncnorm_gen._munp.<locals>.n_th_moment.<locals>.<lambda>(  s    q1qs8| r8   r  r  r  )rr   rP   r   r  r   r  r  )rb   r   r   pApBprobsr  r  mkr  rE   s            @r6   n_th_momentz(truncnorm_gen._munp.<locals>.n_th_moment(  s    
 YYrz1a&111a88FB"IE!fG1ac]] # #
 "%%!Q";";";";qJ J JVD\\QqSGBK$77r""""2;r8   r   r  rW  )rE   rb   r   r   r  s   `    r6   r  ztruncnorm_gen._munp(  sk    	 	 	 	 	& 16a1f-a81a),{BJ<HHH&" " 	"r8   r  c                     |                      t          j        ||g          ||          \  }}d }t          j        |d          } ||||||          S )Nc                 ^   ||z
  }|}|| g}t          ||| |ggd d          }dt          j        |          z   }	t          ||| |z
  ||z
  ggd d          }dt          j        |          z   }
t          ||| |ggd d          }d|z  t          j        |          z   }t          ||| |ggd d          }d	|	z  t          j        |          z   }||d
|	z  d|dz  z  z   z  z   }|t          j        |
d          z  }||d|z  d	|z  d|	z  |dz  z
  z  z   z  z   }||
dz  z  d	z
  }||
||fS )Nc                     | |z  S rN   r   r  s     r6   r  zGtruncnorm_gen._stats.<locals>._truncnorm_stats_scalar.<locals>.<lambda>(  s
    1Q3 r8   r   r  r   c                     | |z  S rN   r   r  s     r6   r  zGtruncnorm_gen._stats.<locals>._truncnorm_stats_scalar.<locals>.<lambda>(  s
    1 r8   c                     | |dz  z  S r  r   r  s     r6   r  zGtruncnorm_gen._stats.<locals>._truncnorm_stats_scalar.<locals>.<lambda>(      1QT6 r8   rU   c                     | |dz  z  S r
  r   r  s     r6   r  zGtruncnorm_gen._stats.<locals>._truncnorm_stats_scalar.<locals>.<lambda>(  r  r8   r  r  r  r  )r   rP   r  r  )r   r   r{  r|  r  rA  rD  r}  r  rB  rE  rC  m4mu3rF  mu4rG  s                    r6   _truncnorm_stats_scalarz5truncnorm_gen._stats.<locals>._truncnorm_stats_scalar(  s   bBB"IEeeaV_6F6F()+ + +DRVD\\!BeeadAbD\%:<L<L()+ + +D bfTll"CeeaV_6I6I()+ + +D2t$BeeaV_6I6I()+ + +D2t$BrRUQr1uW_--CrxS)))Br2b51R42A#6677CsAv!BsB?"r8   )r  )excluded)r  rP   r  r  )rE   r   r   r  r{  r|  r  _truncnorm_statss           r6   r   ztruncnorm_gen._stats(  sp    "(Aq6**Aq11B	# 	# 	#4 <(?1=? ? ?1b"g666r8   r  )r   r   r   r   rc   rk   r  r   rr   r   ru   r   ry   r   r   r~   r   r  r   r  r  s   @r6   rY  rY  '  s       > >@    
J J J J J  - - -7 7 7- - -  , , ,      8  :" " "07 7 7 7 7 7 7 7r8   rY  	truncnorm)r   r   c                        e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Ze ee           fd                        Z xZS )truncpareto_genac  An upper truncated Pareto continuous random variable.

    %(before_notes)s

    See Also
    --------
    pareto : Pareto distribution

    Notes
    -----
    The probability density function for `truncpareto` is:

    .. math::

        f(x, b, c) = \frac{b}{1 - c^{-b}} \frac{1}{x^{b+1}}

    for :math:`b > 0`, :math:`c > 1` and :math:`1 \le x \le c`.

    `truncpareto` takes `b` and `c` as shape parameters for :math:`b` and
    :math:`c`.

    Notice that the upper truncation value :math:`c` is defined in
    standardized form so that random values of an unscaled, unshifted variable
    are within the range ``[1, c]``.
    If ``u_r`` is the upper bound to a scaled and/or shifted variable,
    then ``c = (u_r - loc) / scale``. In other words, the support of the
    distribution becomes ``(scale + loc) <= x <= (c*scale + loc)`` when
    `scale` and/or `loc` are provided.

    %(after_notes)s

    References
    ----------
    .. [1] Burroughs, S. M., and Tebbens S. F.
        "Upper-truncated power laws in natural systems."
        Pure and Applied Geophysics 158.4 (2001): 741-757.

    %(example)s

    c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )Nr   Fr   r
  r  r   rh   )rE   rk  r&  s      r6   rk   ztruncpareto_gen._shape_info)  s=    US"&M>BBUS"&M>BBBxr8   c                     |dk    |dk    z  S r
  r   rE   r   r  s      r6   rc   ztruncpareto_gen._argcheck)  s    B1r6""r8   c                     | j         |fS rN   r8  r  s      r6   r   ztruncpareto_gen._get_support)  r:  r8   c                 2    |||dz    z  z  dd||z  z  z
  z  S r^   r   rE   rq   r   r  s       r6   rr   ztruncpareto_gen._pdf")  s'    1!f9}AadF
++r8   c           	          t          j        |          t          j        t          j        | t          j        |          z                       z
  |dz   t          j        |          z  z
  S r^   )rP   r   r  r  s       r6   r   ztruncpareto_gen._logpdf%)  sO    vayy2628QBrvayyL#9#9"9:::ac26!99_LLr8   c                 ,    d|| z  z
  dd||z  z  z
  z  S r^   r   r  s       r6   ru   ztruncpareto_gen._cdf()  s#    ArE	a!AqD&j))r8   c                 j    t          j        || z             t          j        d||z  z            z
  S r>  r>  r  s       r6   r   ztruncpareto_gen._logcdf+)  s1    xQB"(2ad7"3"333r8   c                 F    t          ddd||z  z  z
  |z  z
  d|z            S Nr   r  r9  rE   r}   r   r  s       r6   r~   ztruncpareto_gen._ppf.)  s+    1AadF
A~%r!t,,,r8   c                 8    || z  d||z  z  z
  dd||z  z  z
  z  S r^   r   r  s       r6   ry   ztruncpareto_gen._sf1)  s+    A2!Q$1qAv:..r8   c                 z    t          j        || z  d||z  z  z
            t          j        d||z  z            z
  S r  r  r  s       r6   r   ztruncpareto_gen._logsf4)  s;    va!ea1fn%%AqD(9(999r8   c                 R    t          d||z  z  dd||z  z  z
  |z  z   d|z            S r  r9  r  s       r6   r   ztruncpareto_gen._isf7)  s3    1QT6Q1a4ZN*BqD111r8   c                     t          j        |dd||z  z  z
  z            |dz   t          j        |          ||z  dz
  z  d|z  z
  z  z    S r^   r2  r  s      r6   r   ztruncpareto_gen._entropy:)  sX    1qAv:''aC"&))QTAX.1456 7 	7r8   c                     ||k                                     r#|t          j        |          z  dd||z  z  z
  z  S |||z
  z  ||z  ||z  z
  z  ||z  dz
  z  S r^   )r   rP   r   )rE   rb   r   r  s       r6   r  ztruncpareto_gen._munp>)  se    F<<>> 	:RVAYY;!a1f*--!91q!t,1q99r8   c                     t          |t                    r|                                }t                              |          \  }}}t          |          |z
  |z  }||||fS rN   )r?   r*   r  r	  rC   r  )rE   rF   r   r.   r/   r  s         r6   r  ztruncpareto_gen._fitstartD)  s]    dL)) 	$>>##D

4((3YY_e#!S%r8   c                 |    !"#$% |                     dd          r t                      j        g|R i |S d #d ""#fd%fd $%fd}$fd!d !"fd		}d
 }& fd}t           ||          }|\  }	}
}}                                                                c$%t          j        $t          j                   }|	|
||t          d          |
|| |	$ !"fd}t          j        $t          j                   }|}d}|dz
  }|t          j         k    rd ||           ||          z  dk    rI|dz  }|t          j
        d|          z
  }|t          j         k    r ||           ||          z  dk    I|t          j         k    s |g|R i |S t          |||f          }|j        s |g|R i |S |j        dz
  }|dz
  }d}|t          j         k    rd ||           ||          z  dk    rI|dz  }|t          j
        d|          z
  }|t          j         k    r ||           ||          z  dk    I|t          j         k    s |g|R i |S t          |||f          }|j        s |g|R i |S |j        } !|          }  ||          } |||          }|z
  |z  }t	          d #|          z  d "|          dz
  z            }||k     s |g|R i |S n|}|dz
  }d}|t          j         k    rX |||	           |||	          z  dk    r;|dz  }|d|z  z
  }|t          j         k    r |||	           |||	          z  dk    ;|t          j         k    s |g|R i |S t          ||	f||f          }|j        s |g|R i |S |j        } !|          }  ||          }|	}nD||n ||
|          }|p
 !|          }|
p  ||          }|-                                |z
  dk     rt          dd|          |
r>|<|r:                                |
|z  |z   k    rt          dd  ||                    |	|z
  |z  } #|          }t          j        |          }d|z  |k     s |g|R i |S d|z  d||z
  z  z   }t          j        d|z  d          }	 t          |||f||f          }|j        s |g|R i |S |j        }n# t          $ r |}Y nw xY w|	}||z   $k     sC|r!t          j        |t          j                   }n  !|          }t          j        |d          }||z  |z   %k    s+  ||          }t          j        |t          j                  }t          j                             ||                    r|dk    s |g|R i |S ||||f}|B|@ |g|R i |}                     |          }                     |          }||k     r|S |S )Nr@  Fc                 N    t          j        t          j        |                     S rN   )rP   r   r   r   s    r6   log_meanz%truncpareto_gen.fit.<locals>.log_meanQ)  s    726!99%%%r8   c                 6    dt          j        d| z            z  S r^   )rP   r   r   s    r6   	harm_meanz&truncpareto_gen.fit.<locals>.harm_meanT)  s    RWQqS\\>!r8   c                     |z
  |z  } |          } 	|          }|dz
  |z  }d|dz
  |dd| z  z
  |z  t          j        |           z  z
  z  z
  |z  S r^   r2  )
r  r.   r/   r  harm_mlog_mquotrF   r  r  s
          r6   get_bz"truncpareto_gen.fit.<locals>.get_bW)  sq    c5 AYq\\FHQKKE1He#DaDA!GV+;BF1II+E$EFFMMr8   c                     | z
  |z  S rN   r   )r.   r/   mxs     r6   get_cz"truncpareto_gen.fit.<locals>.get_c^)  s    He##r8   c                 >    |r|z
  }|S | r| z  z
  | dz
  z  }|S d S r^   r   )rN  r   r.   r  r  s      r6   get_locz$truncpareto_gen.fit.<locals>.get_loca)  sF     6k
 "urzBF+
 r8   c                     | z
  S rN   r   )r.   r  s    r6   r	  z&truncpareto_gen.fit.<locals>.get_scalei)  s    8Or8   c                      	|           } | |          }| || |          n|} 
| z
  |z            }dd|dz
  ||dz   z  |z
  z  z   dd|dz   z  z
  z  |z  z
  S r^   r   )r.   r  r/   r  r   r  rF   r  r  r	  r  s         r6   rV  z$truncpareto_gen.fit.<locals>.dL_dLoco)  s     IcNNEc5!!A(*
ae$$$AYs
E122FQUQ1X\22q1ac7{CfLLLr8   c                 N    | t          j        | |z  d| |z  z
  z            |z  z
  S r^   r>  )r   logclogms      r6   dL_dBz"truncpareto_gen.fit.<locals>.dL_dBx)  s/     rx$!af* 566===r8   c                 L     t          t                    j        | g|R i |S rN   )rA   r  rC   )rF   rG   r  r  rE   s      r6   fallbackz%truncpareto_gen.fit.<locals>.fallback~)  s0    35$//3DJ4JJJ6JJJr8   z2All parameters fixed.There is nothing to optimize.c                      |           } | |          } | z
  |z            }dd|dz
  z  z   t          j        |          z  |z  dz
  S r^   r2  )r.   r/   r  r  rF   r  r	  r  s       r6   cond_bz#truncpareto_gen.fit.<locals>.cond_b)  sb    %IcNNEc5))A&Ys
E'9::F1Q3K26!994v=AAr8   r   r   r   r$  gMbP?rU   truncparetor  rN   )r3   rA   rC   rL  r  r  rP   r\  ri   r   r  r+   r]  rM  rL  r   r   rc   rX  )'rE   rF   rG   r5   r  rV  r  r  r^  r  rN  r   r   mn_infr  rS   r  rR   r  r.   r/   r  r   std_data
up_bound_br  r  params_overrideparams_supernllf_override
nllf_superr  r  r	  r  r  r  r  r  s'   ``                             @@@@@@@r6   rC   ztruncpareto_gen.fitK)  se	    88J&& 	4577;t3d333d333	& 	& 	&	" 	" 	"	N 	N 	N 	N 	N 	N 	N	$ 	$ 	$ 	$ 	$	 	 	 	 	 		 	 	 	 		M 	M 	M 	M 	M 	M 	M 	M 	M 	M	> 	> 	>	K 	K 	K 	K 	K 	K 1tT4HH
%/"b"dFTXXZZBb26'**NN$& = > > >ZDLV^zB B B B B B B B b26'22!"&(("F6NN66&>>9Q>>FA#bhr1oo5F "&(("F6NN66&>>9Q>> ''#8D848884888!&662BCCC} 9#8D848884888 D!"&((#GFOOGGFOO;q@@FA#bhr1oo5F "&((#GFOOGGFOO;q@@ ''#8D848884888!'FF3CDDD} 9#8D848884888h!	#E#u%%E!S%(( 3J- 88H#5#5!5!"IIh$7$7$9!:< <
J#8D848884888 '
  !''#GFB//%gfb112567 7FA#ad]F	 ''#GFB//%gfb112567 7 ''#8D848884888!'B5+16*:< < <} 9#8D848884888h!	#E#u%% *$$F0C0CC,iinnE'eeC''A DHHJJ$5$9$9"=CCCC  @t'V'88::6	D 000&}A-2U3->->@ @ @ @ z 3J-x))vayy$#8D8488848884!TD[/1afa00%edD\/5v.>@ @ @C = ='x<t<<<t<<<AA!   AAA  c	R /l300!	#UA..%r!!c5!!AQ''At~~a++,, 	1%!))8D040004000QU*<FN
 $8D84888488L IIot<<M<66JM))##s   0(T! T! !T0/T0)r   r   r   r   rk   rc   r   rr   r   ru   r   r~   ry   r   r   r   r  r  rK   r   r   rC   r  r  s   @r6   r  r  (  sC       ' 'R  
# # #  , , ,M M M* * *4 4 4- - -/ / /: : :2 2 27 7 7: : :      M**Z Z Z Z +* _Z Z Z Z Zr8   r  r  )r   r  c                   P    e Zd ZdZej        Zd Zd Zd Z	d Z
d Zd Zd Zd	 Zd
S )tukeylambda_gena*  A Tukey-Lamdba continuous random variable.

    %(before_notes)s

    Notes
    -----
    A flexible distribution, able to represent and interpolate between the
    following distributions:

    - Cauchy                (:math:`lambda = -1`)
    - logistic              (:math:`lambda = 0`)
    - approx Normal         (:math:`lambda = 0.14`)
    - uniform from -1 to 1  (:math:`lambda = 1`)

    `tukeylambda` takes a real number :math:`lambda` (denoted ``lam``
    in the implementation) as a shape parameter.

    %(after_notes)s

    %(example)s

    c                 *    t          j        |          S rN   r  rE   lams     r6   rc   ztukeylambda_gen._argcheckG*  s    {3r8   c                 V    t          ddt          j         t          j        fd          gS )Nr  Fr
  rh   rj   s    r6   rk   ztukeylambda_gen._shape_infoJ*  s$    5%26'26):NKKLLr8   c                 R    t          |dk    |fd t          j                  }| |fS )Nr   c                     d| z  S r^   r   )r  s    r6   r  z.tukeylambda_gen._get_support.<locals>.<lambda>O*  s
    QsU r8   r  r  )rE   r  r   s      r6   r   ztukeylambda_gen._get_supportM*  s8    sQw**!#) ) ) r1ur8   c           	         t          j        t          j        ||                    }||dz
  z  t          j        d|z
            |dz
  z  z   }t          j        d          5  dt          j        |          z  }t          j        |dk    t          |          dt          j        |          z  k     z  |d          cd d d            S # 1 swxY w Y   d S )Nr   r   r9  r:  r   r   )rP   r   rw   tklmbdar<  rT  r  )rE   rq   r  Fxrb  s        r6   rr   ztukeylambda_gen._pdfS*  s   Z
1c**++#c']bj2..#c'::[))) 	R 	RRZ^^#B8SAX#a&&3rz#3F*FGSQQ	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	R 	Rs   #AC

CCc                 ,    t          j        ||          S rN   )rw   r  )rE   rq   r  s      r6   ru   ztukeylambda_gen._cdfZ*  s    z!S!!!r8   c                 Z    t          j        ||          t          j        | |          z
  S rN   )rw   r  r  )rE   r}   r  s      r6   r~   ztukeylambda_gen._ppf]*  s'    yC  2;r3#7#777r8   c                 B    dt          |          dt          |          fS r7  )_tlvar_tlkurtr  s     r6   r   ztukeylambda_gen._stats`*  s    &++q'#,,..r8   c                 F    fd}t          j        |dd          d         S )Nc                 |    t          j        t          | dz
            t          d| z
  dz
            z             S r^   )rP   r   r  )r  r  s    r6   integz'tukeylambda_gen._entropy.<locals>.integd*  s4    6#aQ--AaCQ7888r8   r   r   )r   r  )rE   r  r  s    ` r6   r   ztukeylambda_gen._entropyc*  s5    	9 	9 	9 	9 	9~eQ**1--r8   N)r   r   r   r   r   r  r  rc   rk   r   rr   ru   r~   r   r   r   r8   r6   r  r  .*  s         , "4M     M M M  R R R" " "8 8 8/ / /. . . . .r8   r  tukeylambdac                       e Zd Zd ZdS )FitUniformFixedScaleDataErrorc                 "    d| d| d| _         d S )NzInvalid values in `data`.  Maximum likelihood estimation with the uniform distribution and fixed scale requires that np.ptp(data) <= fscale, but np.ptp(data) = z and fscale = r2   rN  )rE   r
  r   s      r6   rQ  z&FitUniformFixedScaleDataError.__init__m*  s3    ":=" " " " " 				r8   N)r   r   r   rQ  r   r8   r6   r  r  l*  s#        
 
 
 
 
r8   r  c                   T    e Zd ZdZd ZddZd Zd Zd Zd Z	d	 Z
ed
             ZdS )uniform_gena  A uniform continuous random variable.

    In the standard form, the distribution is uniform on ``[0, 1]``. Using
    the parameters ``loc`` and ``scale``, one obtains the uniform distribution
    on ``[loc, loc + scale]``.

    %(before_notes)s

    %(example)s

    c                     g S rN   r   rj   s    r6   rk   zuniform_gen._shape_info*  r   r8   Nc                 0    |                     dd|          S r
  )r  r   s      r6   r   zuniform_gen._rvs*  s    ##Cd333r8   c                     d||k    z  S r  r   r   s     r6   rr   zuniform_gen._pdf*  s    AF|r8   c                     |S rN   r   r   s     r6   ru   zuniform_gen._cdf*      r8   c                     |S rN   r   r   s     r6   r~   zuniform_gen._ppf*  r  r8   c                     dS )N)r   gUUUUUU?r   g333333r   rj   s    r6   r   zuniform_gen._stats*  s    ##r8   c                     dS rT  r   rj   s    r6   r   zuniform_gen._entropy*  r  r8   c                 ,   t          |          dk    rt          d          |                    dd          }|                    dd          }t          |           ||t	          d          t          j        |          }t          j        |                                          st	          d          |r|)|	                                }t          j
        |          }n|}|                                |z
  }|	                                |k     rt          d|||z   	          nJt          j
        |          }||k    rt          ||
          |	                                d||z
  z  z
  }|}t          |          t          |          fS )a	  
        Maximum likelihood estimate for the location and scale parameters.

        `uniform.fit` uses only the following parameters.  Because exact
        formulas are used, the parameters related to optimization that are
        available in the `fit` method of other distributions are ignored
        here.  The only positional argument accepted is `data`.

        Parameters
        ----------
        data : array_like
            Data to use in calculating the maximum likelihood estimate.
        floc : float, optional
            Hold the location parameter fixed to the specified value.
        fscale : float, optional
            Hold the scale parameter fixed to the specified value.

        Returns
        -------
        loc, scale : float
            Maximum likelihood estimates for the location and scale.

        Notes
        -----
        An error is raised if `floc` is given and any values in `data` are
        less than `floc`, or if `fscale` is given and `fscale` is less
        than ``data.max() - data.min()``.  An error is also raised if both
        `floc` and `fscale` are given.

        Examples
        --------
        >>> import numpy as np
        >>> from scipy.stats import uniform

        We'll fit the uniform distribution to `x`:

        >>> x = np.array([2, 2.5, 3.1, 9.5, 13.0])

        For a uniform distribution MLE, the location is the minimum of the
        data, and the scale is the maximum minus the minimum.

        >>> loc, scale = uniform.fit(x)
        >>> loc
        2.0
        >>> scale
        11.0

        If we know the data comes from a uniform distribution where the support
        starts at 0, we can use ``floc=0``:

        >>> loc, scale = uniform.fit(x, floc=0)
        >>> loc
        0.0
        >>> scale
        13.0

        Alternatively, if we know the length of the support is 12, we can use
        ``fscale=12``:

        >>> loc, scale = uniform.fit(x, fscale=12)
        >>> loc
        1.5
        >>> scale
        12.0

        In that last example, the support interval is [1.5, 13.5].  This
        solution is not unique.  For example, the distribution with ``loc=2``
        and ``scale=12`` has the same likelihood as the one above.  When
        `fscale` is given and it is larger than ``data.max() - data.min()``,
        the parameters returned by the `fit` method center the support over
        the interval ``[data.min(), data.max()]``.

        r   r  r   Nr   r   r   r  r  )r
  r   r   )r  r4   r3   r7   r   rP   r   r   r   r  r
  r  rL  r  rW  )	rE   rF   rG   r5   r   r   r.   r/   r
  s	            r6   rC   zuniform_gen.fit*  s   V t99q==1222xx%%(D))$T*** 2 ) * * * z${4  $$&& 	ECDDD> >|hhjjt 

S(88::##&y3;OOOO $ &,,CV||3FKKKK ((**sFSL11CE Szz5<<''r8   r  )r   r   r   r   rk   r   rr   ru   r~   r   r   rK   rC   r   r8   r6   r  r  v*  s        
 
  4 4 4 4      $ $ $   R( R( _R( R( R(r8   r  r  c                        e Zd ZdZd Zd ZddZ ee           fd            Z	d Z
d Zd	 Zd
 Zd Z eed          	 	 d fd	            Ze eed           fd                        Z xZS )vonmises_genaU  A Von Mises continuous random variable.

    %(before_notes)s

    See Also
    --------
    scipy.stats.vonmises_fisher : Von-Mises Fisher distribution on a
                                  hypersphere

    Notes
    -----
    The probability density function for `vonmises` and `vonmises_line` is:

    .. math::

        f(x, \kappa) = \frac{ \exp(\kappa \cos(x)) }{ 2 \pi I_0(\kappa) }

    for :math:`-\pi \le x \le \pi`, :math:`\kappa \ge 0`. :math:`I_0` is the
    modified Bessel function of order zero (`scipy.special.i0`).

    `vonmises` is a circular distribution which does not restrict the
    distribution to a fixed interval. Currently, there is no circular
    distribution framework in SciPy. The ``cdf`` is implemented such that
    ``cdf(x + 2*np.pi) == cdf(x) + 1``.

    `vonmises_line` is the same distribution, defined on :math:`[-\pi, \pi]`
    on the real line. This is a regular (i.e. non-circular) distribution.

    Note about distribution parameters: `vonmises` and `vonmises_line` take
    ``kappa`` as a shape parameter (concentration) and ``loc`` as the location
    (circular mean). A ``scale`` parameter is accepted but does not have any
    effect.

    Examples
    --------
    Import the necessary modules.

    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from scipy.stats import vonmises

    Define distribution parameters.

    >>> loc = 0.5 * np.pi  # circular mean
    >>> kappa = 1  # concentration

    Compute the probability density at ``x=0`` via the ``pdf`` method.

    >>> vonmises.pdf(0, loc=loc, kappa=kappa)
    0.12570826359722018

    Verify that the percentile function ``ppf`` inverts the cumulative
    distribution function ``cdf`` up to floating point accuracy.

    >>> x = 1
    >>> cdf_value = vonmises.cdf(x, loc=loc, kappa=kappa)
    >>> ppf_value = vonmises.ppf(cdf_value, loc=loc, kappa=kappa)
    >>> x, cdf_value, ppf_value
    (1, 0.31489339900904967, 1.0000000000000004)

    Draw 1000 random variates by calling the ``rvs`` method.

    >>> sample_size = 1000
    >>> sample = vonmises(loc=loc, kappa=kappa).rvs(sample_size)

    Plot the von Mises density on a Cartesian and polar grid to emphasize
    that it is a circular distribution.

    >>> fig = plt.figure(figsize=(12, 6))
    >>> left = plt.subplot(121)
    >>> right = plt.subplot(122, projection='polar')
    >>> x = np.linspace(-np.pi, np.pi, 500)
    >>> vonmises_pdf = vonmises.pdf(x, loc=loc, kappa=kappa)
    >>> ticks = [0, 0.15, 0.3]

    The left image contains the Cartesian plot.

    >>> left.plot(x, vonmises_pdf)
    >>> left.set_yticks(ticks)
    >>> number_of_bins = int(np.sqrt(sample_size))
    >>> left.hist(sample, density=True, bins=number_of_bins)
    >>> left.set_title("Cartesian plot")
    >>> left.set_xlim(-np.pi, np.pi)
    >>> left.grid(True)

    The right image contains the polar plot.

    >>> right.plot(x, vonmises_pdf, label="PDF")
    >>> right.set_yticks(ticks)
    >>> right.hist(sample, density=True, bins=number_of_bins,
    ...            label="Histogram")
    >>> right.set_title("Polar plot")
    >>> right.legend(bbox_to_anchor=(0.15, 1.06))

    c                 @    t          dddt          j        fd          gS )Nr  Fr   rg   rh   rj   s    r6   rk   zvonmises_gen._shape_info+  s    7EArv;FFGGr8   c                     |dk    S r7  r   r  s     r6   rc   zvonmises_gen._argcheck+  s    zr8   Nc                 2    |                     d||          S )Nr   r  )vonmises)rE   r  r   r   s       r6   r   zvonmises_gen._rvs+  s    $$S%d$;;;r8   c                      t                      j        |i |}t          j        |t          j        z   dt          j        z            t          j        z
  S r  )rA   r  rP   modr   )rE   rG   r5   r  r  s       r6   r  zvonmises_gen.rvs+  sB    eggk4(4((vcBEk1RU7++be33r8   c                     t          j        |t          j        |          z            dt           j        z  t          j        |          z  z  S r  )rP   r   rw   cosm1r   rk
  r  s      r6   rr   zvonmises_gen._pdf+  s9    
 veBHQKK'((AbeGBF5MM,ABBr8   c                     |t          j        |          z  t          j        dt          j        z            z
  t          j        t          j        |                    z
  S r  )rw   r  rP   r   r   rk
  r  s      r6   r   zvonmises_gen._logpdf+  s?    rx{{"RVAbeG__4rvbfUmm7L7LLLr8   c                 ,    t          j        ||          S rN   )r   von_mises_cdfr  s      r6   ru   zvonmises_gen._cdf+  s    #E1---r8   c                     dS rq  r   r  s     r6   _stats_skipzvonmises_gen._stats_skip+  rr  r8   c                     | t          j        |          z  t          j        |          z  t          j        dt          j        z  t          j        |          z            z   |z   S r  )rw   i1erk
  rP   r   r   r  s     r6   r   zvonmises_gen._entropy+  sU     &6q25y26%==011249: 	;r8   z        The default limits of integration are endpoints of the interval
        of width ``2*pi`` centered at `loc` (e.g. ``[-pi, pi]`` when
        ``loc=0``).

r   r   r   r   Fc           	          t           j         t           j        }
}	|||	z   }|||
z   } t                      j        |||||||fi |S rN   )rP   r   rA   r  )rE   r_  rG   r.   r/   lbubconditionalr5   r  r  r  s              r6   r  zvonmises_gen.expect+  sk     %B:rB:rBuww~dD##R[B B<@B B 	Br8   a          Fit data is assumed to represent angles and will be wrapped onto the
        unit circle. `f0` and `fscale` are ignored; the returned shape is
        always the maximum likelihood estimate and the scale is always
        1. Initial guesses are ignored.

c                    |                     dd          r t                      j        |g|R i |S t          | |||          \  }}}}| j        t
          j         k    r t                      j        |g|R i |S t          j        |dt
          j        z            }d }d }||n
 ||          }	||n |||	          }
t          j        |	t
          j        z   dt
          j        z            t
          j        z
  }	|
|	dfS )Nr@  FrU   c                 *    t          j        |           S rN   )r  circmean)rF   s    r6   find_muz!vonmises_gen.fit.<locals>.find_mu+  s    >$'''r8   c                 x   t          j        t          j        || z
                      t          |           z  dk    rdS dk    rUfd}dz
  z  dz   z  }d|z  } ||          dk    r|S  ||          dk    r|S t	          |d||f          }|j        S t          j        t                    j        S )Nr   g 7yACr   c                 \    t          j        |           t          j        |           z  z
  S rN   )rw   r  rk
  )r  r  s    r6   solve_for_kappaz=vonmises_gen.fit.<locals>.find_kappa.<locals>.solve_for_kappa+  s#    6%==6::r8   rU   r@  )r1   rJ  )	rP   r  r!  r  r+   rM  r&  rW  r'  )rF   r.   r   lower_boundupper_boundroot_resr  s         @r6   
find_kappaz$vonmises_gen.fit.<locals>.find_kappa+  s     rvcDj))**3t994A Avv tQ; ; ; ; ;  1gqsmm #?;//144&&$_[11Q66&&*?84?3M O  O  OH#=( x++r8   r   )r3   rA   rC   rL  r   rP   r   r  )rE   rF   rG   r5   rQ  r   r   r  r  r.   r  r  s              r6   rC   zvonmises_gen.fit+  s5    88J&& 	4577;t3d333d333%@tAEt&M &M"fdF6beV577;t3d333d333 vdAI&&	( 	( 	(6	, 6	, 6	,r &ddGGDMM ,**T32G2GfS25[!be),,ru4c1}r8   r  )Nr   r   r   NNF)r   r   r   r   rk   rc   r   r   r   r  rr   r   ru   r  r   r	   r  rK   rC   r  r  s   @r6   r  r  0+  s       ^ ^~H H H  < < < < M**4 4 4 4 +*4C C CM M M. . .     
; 
; 
; } 5    FJ 
B 
B 
B 
B 
B	 
B } 5/ 0 0 0
N N N N0 0 _N N N N Nr8   r  r  vonmises_linec                   j    e Zd ZdZej        Zd ZddZd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd ZdS )r  aX  A Wald continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `wald` is:

    .. math::

        f(x) = \frac{1}{\sqrt{2\pi x^3}} \exp(- \frac{ (x-1)^2 }{ 2x })

    for :math:`x >= 0`.

    `wald` is a special case of `invgauss` with ``mu=1``.

    %(after_notes)s

    %(example)s
    c                     g S rN   r   rj   s    r6   rk   zwald_gen._shape_info=,  r   r8   Nc                 2    |                     dd|          S r  r  r   s      r6   r   zwald_gen._rvs@,  s      c 555r8   c                 8    t                               |d          S r  )r  rr   r   s     r6   rr   zwald_gen._pdfC,  s    }}Q$$$r8   c                 8    t                               |d          S r  )r  ru   r   s     r6   ru   zwald_gen._cdfG,      }}Q$$$r8   c                 8    t                               |d          S r  )r  ry   r   s     r6   ry   zwald_gen._sfJ,  s    ||As###r8   c                 8    t                               |d          S r  )r  r~   r   s     r6   r~   zwald_gen._ppfM,  r  r8   c                 8    t                               |d          S r  )r  r   r   s     r6   r   zwald_gen._isfP,  r  r8   c                 8    t                               |d          S r  )r  r   r   s     r6   r   zwald_gen._logpdfS,      3'''r8   c                 8    t                               |d          S r  )r  r   r   s     r6   r   zwald_gen._logcdfV,  r  r8   c                 8    t                               |d          S r  )r  r   r   s     r6   r   zwald_gen._logsfY,  s    q#&&&r8   c                     dS )N)r   r   rI  r  r   rj   s    r6   r   zwald_gen._stats\,  s    ""r8   c                 6    t                               d          S r  )r  r   rj   s    r6   r   zwald_gen._entropy_,  s      %%%r8   r  )r   r   r   r   r   r  r  rk   r   rr   ru   ry   r~   r   r   r   r   r   r   r   r8   r6   r  r  &,  s         ( "4M  6 6 6 6% % %% % %$ $ $% % %% % %( ( (( ( (' ' '# # #& & & & &r8   r  r  c                   <    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	S )
wrapcauchy_gena  A wrapped Cauchy continuous random variable.

    %(before_notes)s

    Notes
    -----
    The probability density function for `wrapcauchy` is:

    .. math::

        f(x, c) = \frac{1-c^2}{2\pi (1+c^2 - 2c \cos(x))}

    for :math:`0 \le x \le 2\pi`, :math:`0 < c < 1`.

    `wrapcauchy` takes ``c`` as a shape parameter for :math:`c`.

    %(after_notes)s

    %(example)s

    c                     |dk    |dk     z  S r  r   r  s     r6   rc   zwrapcauchy_gen._argcheck|,  rO
  r8   c                 (    t          dddd          gS )Nr  F)r   r   r
  r
  rj   s    r6   rk   zwrapcauchy_gen._shape_info,  s    3v~>>??r8   c                 z    d||z  z
  dt           j        z  d||z  z   d|z  t          j        |          z  z
  z  z  S r  r  r  s      r6   rr   zwrapcauchy_gen._pdf,  s=    AaC!BE'1QqS51RVAYY#6788r8   c                 j    d }d }d|z   d|z
  z  }t          |t          j        k     ||f||          S )Nc                 z    dt           j        z  t          j        |t          j        | dz            z            z  S r1  rP   r   r  r  rq   crs     r6   r  zwrapcauchy_gen._cdf.<locals>.f1,  s-    RU7RYr"&1++~6666r8   c           	          ddt           j        z  t          j        |t          j        dt           j        z  | z
  dz            z            z  z
  S r1  r  r  s     r6   r  zwrapcauchy_gen._cdf.<locals>.f2,  s?    qw2bfagk1_.E.E+E!F!FFFFr8   r   r  )r   rP   r   )rE   rq   r  r  r  r  s         r6   ru   zwrapcauchy_gen._cdf,  sW    	7 	7 	7	G 	G 	G !ea!e_!be)aWr::::r8   c           
      V   d|z
  d|z   z  }dt          j        |t          j        t           j        |z            z            z  }dt           j        z  dt          j        |t          j        t           j        d|z
  z            z            z  z
  }t          j        |dk     ||          S )Nr   rU   r   r   )rP   r  r  r   rT  )rE   r}   r  r}  rcqrcmqs         r6   r~   zwrapcauchy_gen._ppf,  s    1us1uo	#bfRU1Woo-...wq3rvbeQqSk':':#:;;;;xE	3---r8   c                 V    t          j        dt           j        z  d||z  z
  z            S r  r   r  s     r6   r   zwrapcauchy_gen._entropy,  s$    vagq1uo&&&r8   c                     t          |t                    r|                                }dt          j        |          t          j        |          dt          j        z  z  fS r  )r?   r*   r  rP   r  r
  r   )rE   rF   s     r6   r  zwrapcauchy_gen._fitstart,  sM     dL)) 	$>>##DBF4LL"&,,"%"888r8   N)r   r   r   r   rc   rk   rr   ru   r~   r   r  r   r8   r6   r  r  f,  s         *! ! !@ @ @9 9 9; ; ;. . .' ' '9 9 9 9 9r8   r  
wrapcauchyc                   P    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZddZdS )gennorm_gena0  A generalized normal continuous random variable.

    %(before_notes)s

    See Also
    --------
    laplace : Laplace distribution
    norm : normal distribution

    Notes
    -----
    The probability density function for `gennorm` is [1]_:

    .. math::

        f(x, \beta) = \frac{\beta}{2 \Gamma(1/\beta)} \exp(-|x|^\beta),

    where :math:`x` is a real number, :math:`\beta > 0` and
    :math:`\Gamma` is the gamma function (`scipy.special.gamma`).

    `gennorm` takes ``beta`` as a shape parameter for :math:`\beta`.
    For :math:`\beta = 1`, it is identical to a Laplace distribution.
    For :math:`\beta = 2`, it is identical to a normal distribution
    (with ``scale=1/sqrt(2)``).

    References
    ----------

    .. [1] "Generalized normal distribution, Version 1",
           https://en.wikipedia.org/wiki/Generalized_normal_distribution#Version_1

    .. [2] Nardon, Martina, and Paolo Pianca. "Simulation techniques for
           generalized Gaussian densities." Journal of Statistical
           Computation and Simulation 79.11 (2009): 1317-1329

    .. [3] Wicklin, Rick. "Simulate data from a generalized Gaussian
           distribution" in The DO Loop blog, September 21, 2016,
           https://blogs.sas.com/content/iml/2016/09/21/simulate-generalized-gaussian-sas.html

    %(example)s

    c                 @    t          dddt          j        fd          gS Nro  Fr   r
  rh   rj   s    r6   rk   zgennorm_gen._shape_info,      651bf+~FFGGr8   c                 R    t          j        |                     ||                    S rN   r  rE   rq   ro  s      r6   rr   zgennorm_gen._pdf,  s     vdll1d++,,,r8   c                     t          j        d|z            t          j        d|z            z
  t	          |          |z  z
  S r   )rP   r   rw   r  r  r,  s      r6   r   zgennorm_gen._logpdf,  s8    vc$h"*SX"6"66QEEr8   c                     dt          j        |          z  }d|z   |t          j        d|z  t	          |          |z            z  z
  S r   )rP   rQ   rw   r  r  rE   rq   ro  r  s       r6   ru   zgennorm_gen._cdf,  sB    "'!**a1r|CHc!ffdlCCCCCr8   c                     t          j        |dz
            }|t          j        d|z  d|z   d|z  |z  z
            d|z  z  z  S )Nr   r   r   )rP   rQ   rw   r  r/  s       r6   r~   zgennorm_gen._ppf,  sJ    GAG2?3t8cAgQq-@AACHMMMr8   c                 0    |                      | |          S rN   r  r,  s      r6   ry   zgennorm_gen._sf,  s    yy!T"""r8   c                 0    |                      ||           S rN   r  r,  s      r6   r   zgennorm_gen._isf,  s    		!T""""r8   c                     t          j        d|z  d|z  d|z  g          \  }}}dt          j        ||z
            dt          j        ||z   d|z  z
            dz
  fS )Nr   rI  r  r   r   )rw   r  rP   r   )rE   ro  c1c3c5s        r6   r   zgennorm_gen._stats,  sa    ZT3t8SX >??
B26"r'??BrBwR/?(@(@2(EEEr8   c                 l    d|z  t          j        d|z            z
  t          j        d|z            z   S r  r  rE   ro  s     r6   r   zgennorm_gen._entropy,  s2    Dy26"t),,,rz"t)/D/DDDr8   Nc                     |                     d|z  |          }|d|z  z  }t          j        |          }|                    |j                  dk     }||          ||<   |S )Nr   r  r   )r  rP   r   randomr  )rE   ro  r   r   r/  r  r	  s          r6   r   zgennorm_gen._rvs,  sk     qvD11!D&MJqMM"""0036T7($r8   r  )r   r   r   r   rk   rr   r   ru   r~   ry   r   r   r   r   r   r8   r6   r'  r'  ,  s        ) )TH H H- - -F F FD D D
N N N
# # ## # #F F FE E E	 	 	 	 	 	r8   r'  gennormc                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )halfgennorm_gena  The upper half of a generalized normal continuous random variable.

    %(before_notes)s

    See Also
    --------
    gennorm : generalized normal distribution
    expon : exponential distribution
    halfnorm : half normal distribution

    Notes
    -----
    The probability density function for `halfgennorm` is:

    .. math::

        f(x, \beta) = \frac{\beta}{\Gamma(1/\beta)} \exp(-|x|^\beta)

    for :math:`x, \beta > 0`. :math:`\Gamma` is the gamma function
    (`scipy.special.gamma`).

    `halfgennorm` takes ``beta`` as a shape parameter for :math:`\beta`.
    For :math:`\beta = 1`, it is identical to an exponential distribution.
    For :math:`\beta = 2`, it is identical to a half normal distribution
    (with ``scale=1/sqrt(2)``).

    References
    ----------

    .. [1] "Generalized normal distribution, Version 1",
           https://en.wikipedia.org/wiki/Generalized_normal_distribution#Version_1

    %(example)s

    c                 @    t          dddt          j        fd          gS r)  rh   rj   s    r6   rk   zhalfgennorm_gen._shape_info&-  r*  r8   c                 R    t          j        |                     ||                    S rN   r  r,  s      r6   rr   zhalfgennorm_gen._pdf)-  s"     vdll1d++,,,r8   c                 f    t          j        |          t          j        d|z            z
  ||z  z
  S r  r  r,  s      r6   r   zhalfgennorm_gen._logpdf/-  s,    vd||bjT222QW<<r8   c                 8    t          j        d|z  ||z            S r  r  r,  s      r6   ru   zhalfgennorm_gen._cdf2-  s    {3t8QW---r8   c                 >    t          j        d|z  |          d|z  z  S r  r  r,  s      r6   r~   zhalfgennorm_gen._ppf5-  s!    ~c$h**SX66r8   c                 8    t          j        d|z  ||z            S r  r  r,  s      r6   ry   zhalfgennorm_gen._sf8-  s    |CHag...r8   c                 >    t          j        d|z  |          d|z  z  S r  r0  r,  s      r6   r   zhalfgennorm_gen._isf;-  s!    s4x++c$h77r8   c                 f    d|z  t          j        |          z
  t          j        d|z            z   S r  r  r8  s     r6   r   zhalfgennorm_gen._entropy>-  s,    4x"&,,&CH)=)===r8   Nr  r   r8   r6   r=  r=  -  s        " "FH H H- - -= = =. . .7 7 7/ / /8 8 8> > > > >r8   r=  halfgennormc                   R     e Zd ZdZd Zd Z fdZd Zd Zd Z	d Z
d	 Zd
 Z xZS )crystalball_gena  
    Crystalball distribution

    %(before_notes)s

    Notes
    -----
    The probability density function for `crystalball` is:

    .. math::

        f(x, \beta, m) =  \begin{cases}
                            N \exp(-x^2 / 2),  &\text{for } x > -\beta\\
                            N A (B - x)^{-m}  &\text{for } x \le -\beta
                          \end{cases}

    where :math:`A = (m / |\beta|)^m  \exp(-\beta^2 / 2)`,
    :math:`B = m/|\beta| - |\beta|` and :math:`N` is a normalisation constant.

    `crystalball` takes :math:`\beta > 0` and :math:`m > 1` as shape
    parameters.  :math:`\beta` defines the point where the pdf changes
    from a power-law to a Gaussian distribution.  :math:`m` is the power
    of the power-law tail.

    %(after_notes)s

    .. versionadded:: 0.19.0

    References
    ----------
    .. [1] "Crystal Ball Function",
           https://en.wikipedia.org/wiki/Crystal_Ball_function

    %(example)s
    c                     |dk    |dk    z  S )z@
        Shape parameter bounds are m > 1 and beta > 0.
        r   r   r   )rE   ro  rD  s      r6   rc   zcrystalball_gen._argchecki-  s     A$(##r8   c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )Nro  Fr   r
  rD  r   rh   )rE   ibetaims      r6   rk   zcrystalball_gen._shape_infoo-  s>    651bf+~FFUQK@@r{r8   c                 J    t                                          |d          S )N)r   r  rN  rX  rY  s     r6   r  zcrystalball_gen._fitstartt-  s     ww  H 555r8   c                     d||z  |dz
  z  t          j        |dz   dz            z  t          t          |          z  z   z  }d }d }|t	          || k    |||f||          z  S )a`  
        Return PDF of the crystalball function.

                                            --
                                           | exp(-x**2 / 2),  for x > -beta
        crystalball.pdf(x, beta, m) =  N * |
                                           | A * (B - x)**(-m), for x <= -beta
                                            --
        r   r   rU   r   c                 8    t          j        | dz   dz            S r  rz  rq   ro  rD  s      r6   rhsz!crystalball_gen._pdf.<locals>.rhs-  s    61a4%!)$$$r8   c                 j    ||z  |z  t          j        |dz   dz            z  ||z  |z
  | z
  | z  z  S r   rz  rP  s      r6   lhsz!crystalball_gen._pdf.<locals>.lhs-  sG    tVaK"&$'C"8"88tVd]Q&1"-. /r8   r  rP   r   r   r   r   rE   rq   ro  rD  r  rQ  rS  s          r6   rr   zcrystalball_gen._pdfx-  s     1T6QqS>BFD!G8c>$:$::401 2	% 	% 	%	/ 	/ 	/ :a4%i!T1EEEEEr8   c                     d||z  |dz
  z  t          j        |dz   dz            z  t          t          |          z  z   z  }d }d }t          j        |          t          || k    |||f||          z   S )zH
        Return the log of the PDF of the crystalball function.
        r   r   rU   r   c                     | dz   dz  S r  r   rP  s      r6   rQ  z$crystalball_gen._logpdf.<locals>.rhs-  s    qD57Nr8   c                     |t          j        ||z            z  |dz  dz  z
  |t          j        ||z  |z
  | z
            z  z
  S r  r2  rP  s      r6   rS  z$crystalball_gen._logpdf.<locals>.lhs-  sG    RVAdF^^#dAgai/!BF1T6D=1;L4M4M2MMMr8   r  )rP   r   r   r   r   r   rU  s          r6   r   zcrystalball_gen._logpdf-  s     1T6QqS>BFD!G8c>$:$::401 2	 	 		N 	N 	N vayy:a4%i!T1MMMMMr8   c                     d||z  |dz
  z  t          j        |dz   dz            z  t          t          |          z  z   z  }d }d }|t	          || k    |||f||          z  S )z8
        Return CDF of the crystalball function
        r   r   rU   r   c                     ||z  t          j        |dz   dz            z  |dz
  z  t          t          |           t          |           z
  z  z   S NrU   r   r   rP   r   r   r   rP  s      r6   rQ  z!crystalball_gen._cdf.<locals>.rhs-  sT    tVrvtQwhn5551=9Q<<)TE2B2B#BCD Er8   c                 |    ||z  |z  t          j        |dz   dz            z  ||z  |z
  | z
  | dz   z  z  |dz
  z  S r[  rz  rP  s      r6   rS  z!crystalball_gen._cdf.<locals>.lhs-  sW    tVaK"&$'C"8"88tVd]Q&1"Q$/034Q38 9r8   r  rT  rU  s          r6   ru   zcrystalball_gen._cdf-  s     1T6QqS>BFD!G8c>$:$::401 2	E 	E 	E	9 	9 	9 :a4%i!T1EEEEEr8   c                 J     d } fd}t          || k    |||f||          S )zD
        Survival function of the crystalball distribution.
        c                     ||z  |dz
  z  t          j        |dz   dz            z  t          t          |          z  z   }t          t	          |           z  |z  S r1  )rP   r   r   r   r   )rq   ro  rD  Ms       r6   rQ  z crystalball_gen._sf.<locals>.rhs-  sR    $ArvtQwhqj111K	$4OOAx{{*1,,r8   c                 8    d                     | ||          z
  S r^   r  )rq   ro  rD  rE   s      r6   rS  z crystalball_gen._sf.<locals>.lhs-  s    tyyD!,,,,r8   r  r  )rE   rq   ro  rD  rQ  rS  s   `     r6   ry   zcrystalball_gen._sf-  sP    
	- 	- 	-
	- 	- 	- 	- 	- !te)aq\SSAAAAr8   c                    d||z  |dz
  z  t          j        |dz   dz            z  t          t          |          z  z   z  }|||z  z  t          j        |dz   dz            z  |dz
  z  }d }d }t	          ||k     |||f||          S )Nr   r   rU   r   c                     t          j        |dz   dz            }||z  |z  |dz
  z  }d|t          t          |          z  z   z  }||z  |z
  |dz
  ||z  | z  z  |z  | z  |z  dd|z
  z  z  z
  S r  r\  r  ro  rD  eb2rF  r  s         r6   ppf_lessz&crystalball_gen._ppf.<locals>.ppf_less-  s    &$'!$$C43!A#&A1{Yt__445AdFTM!eaf^+C/1!3q!A#w?@ Ar8   c                     t          j        |dz   dz            }||z  |z  |dz
  z  }d|t          t          |          z  z   z  }t	          t          |           dt          z  | |z  |z
  z  z             S r  )rP   r   r   r   r   rd  s         r6   ppf_greaterz)crystalball_gen._ppf.<locals>.ppf_greater-  sy    &$'!$$C43!A#&A1{Yt__445AYu--;1q0IIJJJr8   r  rT  )rE   r  ro  rD  r  pbetarf  rh  s           r6   r~   zcrystalball_gen._ppf-  s    1T6QqS>BFD!G8c>$:$::401 2QtVrvtQwhqj111QU;	A 	A 	A	K 	K 	K !e)aq\X+NNNNr8   c           	         d||z  |dz
  z  t          j        |dz   dz            z  t          t          |          z  z   z  }d }|t	          |dz   |k     |||ft          j        |t           j        g          t           j                  z  S )zR
        Returns the n-th non-central moment of the crystalball function.
        r   r   rU   r   c                    ||z  |z  t          j        |dz   dz            z  }||z  |z
  }d| dz
  dz  z  t          j        | dz   dz            z  dd| z  t          j        | dz   dz  |dz  dz            z  z   z  }t          j        |j                  }t          t          |           dz             D ]B}|t          j	        | |          || |z
  z  z  d|z  z  ||z
  dz
  z  ||z  | |z   dz   z  z  z  }C||z  |z   S )z
            Returns n-th moment. Defined only if n+1 < m
            Function cannot broadcast due to the loop over n
            rU   r   r   r   r  )
rP   r   rw   r  r  r  r  r  r  binom)rb   ro  rD  rq  rr  rQ  rS  r  s           r6   r  z*crystalball_gen._munp.<locals>.n_th_moment-  s(   
 4!bfdAgX^444A$A!Sy>BHac1W$5$552'BK1aq1$E$EEEGC(39%%C3q66A:&& 0 0AQqS1R!G;q1uqyI4A26A:./ 0s7S= r8   r  )rP   r   r   r   r   r  r  ri   )rE   rb   ro  rD  r  r  s         r6   r  zcrystalball_gen._munp-  s     1T6QqS>BFD!G8c>$:$::401 2	! 	! 	! :a!eai!T1 l;
|LLL f& & & 	&r8   )r   r   r   r   rc   rk   r  rr   r   ru   ry   r~   r  r  r  s   @r6   rH  rH  E-  s        " "F$ $ $  
6 6 6 6 6F F F,N N NF F F"B B B O O O(& & & & & & &r8   rH  crystalballzA Crystalball Function)r   longnamec                 >    t          j        d| dz  dz            dz  S )a  
    Utility function for the argus distribution used in the pdf, sf and
    moment calculation.
    Note that for all x > 0:
    gammainc(1.5, x**2/2) = 2 * (_norm_cdf(x) - x * _norm_pdf(x) - 0.5).
    This can be verified directly by noting that the cdf of Gamma(1.5) can
    be written as erf(sqrt(x)) - 2*sqrt(x)*exp(-x)/sqrt(Pi).
    We use gammainc instead of the usual definition because it is more precise
    for small chi.
    r  rU   r  )r  s    r6   
_argus_phirp  -  s#     ;sCF1H%%))r8   c                   F    e Zd ZdZd Zd Zd Zd Zd ZddZ	dd	Z
d
 ZdS )	argus_gena  
    Argus distribution

    %(before_notes)s

    Notes
    -----
    The probability density function for `argus` is:

    .. math::

        f(x, \chi) = \frac{\chi^3}{\sqrt{2\pi} \Psi(\chi)} x \sqrt{1-x^2}
                     \exp(-\chi^2 (1 - x^2)/2)

    for :math:`0 < x < 1` and :math:`\chi > 0`, where

    .. math::

        \Psi(\chi) = \Phi(\chi) - \chi \phi(\chi) - 1/2

    with :math:`\Phi` and :math:`\phi` being the CDF and PDF of a standard
    normal distribution, respectively.

    `argus` takes :math:`\chi` as shape a parameter. Details about sampling
    from the ARGUS distribution can be found in [2]_.

    %(after_notes)s

    References
    ----------
    .. [1] "ARGUS distribution",
           https://en.wikipedia.org/wiki/ARGUS_distribution
    .. [2] Christoph Baumgarten "Random variate generation by fast numerical
           inversion in the varying parameter case." Research in Statistics,
           vol. 1, 2023, doi:10.1080/27684520.2023.2279060.

    .. versionadded:: 0.19.0

    %(example)s
    c                 @    t          dddt          j        fd          gS )Nr  Fr   r
  rh   rj   s    r6   rk   zargus_gen._shape_info'.      5%!RVnEEFFr8   c                 p   t          j        d          5  d||z  z
  }dt          j        |          z  t          z
  t          j        t	          |                    z
  }|t          j        |          z   dt          j        | |z            z  z   |dz  |z  dz  z
  cd d d            S # 1 swxY w Y   d S )Nr9  r:  r   r  r   rU   )rP   r<  r   r   rp  r  )rE   rq   r  r  rq  s        r6   r   zargus_gen._logpdf*.  s    [))) 	G 	Gac	A"&++.
31H1HHArvayy=3rx1~~#55Q
QF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	Gs   BB++B/2B/c                 R    t          j        |                     ||                    S rN   r  rE   rq   r  s      r6   rr   zargus_gen._pdf1.  s     vdll1c**+++r8   c                 4    d|                      ||          z
  S r  r#  rw  s      r6   ru   zargus_gen._cdf4.  s    TXXa%%%%r8   c                 |    t          |t          j        d|z
  d|z   z            z            t          |          z  S r^   )rp  rP   r   rw  s      r6   ry   zargus_gen._sf7.  s6    #QQ 8 8899JsOOKKr8   Nc                   	
 t          j        |          }|j        dk    r|                     |||          }nt	          |j        |          \  }	t          t          j        |                    }t          j        |          }t          j	        |gdgdgg          

j
        st          	
fdt          t          |           d          D                       }|                     
d         ||          }|                    |          ||<   
                                 
j
        |dk    r|d         }|S )	Nr   )r  r   r  r  r  c              3   `   K   | ](}|         sj         |         nt          d           V  )d S rN   r  r  s     r6   r  z!argus_gen._rvs.<locals>.<genexpr>G.  r  r8   r   r   )rP   r   r   r  r   r  r  r  r  r  r  r  r  r  rS  r  )rE   r  r   r   r  r  r  r  r  r  r  s            @@r6   r   zargus_gen._rvs:.  sb   joo8q==""340< # > >CC #39d33GCRWS\\**J(4..CC5"/&0\N4 4 4B k  ; ; ; ; ;%*CII:q%9%9; ; ; ; ;$$RUz2> % @ @99S>>C k  2::b'C
r8   c                    t          t          j        |                    }t          t          j        |                    }t          j        |          }d}||z  }|dk    r| dz  }	||k     r||z
  }
|                    |
          }|                    |
          }|dz  }t          j        |          |	|z  k    }t          j        |          }|dk    r,t          j	        d||         z
            }|||||z   <   ||z  }||k     nN|dk    rt          j
        | dz            }||k     r||z
  }
|                    |
          }|                    |
          }dt          j        |d|z
  z  |z             z  |z  }|dz  |z   dk    }t          j        |          }|dk    r,t          j	        d||         z             }|||||z   <   ||z  }||k     n}||k     rZ||z
  }
|                    d|
          }||dz  k    }t          j        |          }|dk    r||         ||||z   <   ||z  }||k     Zt          j	        dd|z  |z  z
            }t          j        ||          S )	Nr   r   rU   r  r  r   g?r  )r  rP   r  r  r  r  r  r   r  r   r   r)  rS  )rE   r  r  r   r  r  rq   r  r  r  r  r  r  r/  r  r  r  echir  s                      r6   r  zargus_gen._rvs_scalarR.  s   h r}Z0011  HQKK	Sy#::	Aa--	M ((a(00 ((a(00H&))q1u,VF^^
>>'!ai-00C<?AiZ!789+I a-- CZZ64%!)$$Da--	M ((a(00 ((a(00tq1u~1222T9 Q$(a-VF^^
>>'!ai-00C<?AiZ!789+I a-- a--	M //!/<<tax-VF^^
>><=fIAiZ!789+I a-- AEDL())Az!V$$$r8   c                    t          j        |t                    }t          |          }t          j        t           j        dz            |z  t          j        d|dz  dz            z  |z  }t          j        |          }|dk    }||         }dd|dz  z  z
  |t          |          z  ||         z  z   ||<   ||          }g d}t          j
        ||          || <   |||dz  z
  d d fS )	Nr
  r.  r   rU   r$  g?r  )	g_1g־r   gWBar   gp|RH?r   gE'卡?r   g?)rP   r   rW  rp  r   r   rw   r	  rp  r   rK  )rE   r  r  rD  rE  r	  r  coefs           r6   r   zargus_gen._stats.  s     jE***ooGBE!Gs"RVAsAvax%8%883>mC  SyIAqDL1y||#3c$i#??D	JKKKZa((TE
#1*dD((r8   r  )r   r   r   r   rk   r   rr   ru   ry   r   r  r   r   r8   r6   rr  rr  -  s        ' 'PG G GG G G, , ,& & &L L L   0c% c% c% c%J) ) ) ) )r8   rr  arguszAn Argus Function)r   rn  r   r   c                   ^     e Zd ZdZej        Zdd fd
Zd Zd Zd Z	d Z
d	 Z fd
Z xZS )rv_histograma3  
    Generates a distribution given by a histogram.
    This is useful to generate a template distribution from a binned
    datasample.

    As a subclass of the `rv_continuous` class, `rv_histogram` inherits from it
    a collection of generic methods (see `rv_continuous` for the full list),
    and implements them based on the properties of the provided binned
    datasample.

    Parameters
    ----------
    histogram : tuple of array_like
        Tuple containing two array_like objects.
        The first containing the content of n bins,
        the second containing the (n+1) bin boundaries.
        In particular, the return value of `numpy.histogram` is accepted.

    density : bool, optional
        If False, assumes the histogram is proportional to counts per bin;
        otherwise, assumes it is proportional to a density.
        For constant bin widths, these are equivalent, but the distinction
        is important when bin widths vary (see Notes).
        If None (default), sets ``density=True`` for backwards compatibility,
        but warns if the bin widths are variable. Set `density` explicitly
        to silence the warning.

        .. versionadded:: 1.10.0

    Notes
    -----
    When a histogram has unequal bin widths, there is a distinction between
    histograms that are proportional to counts per bin and histograms that are
    proportional to probability density over a bin. If `numpy.histogram` is
    called with its default ``density=False``, the resulting histogram is the
    number of counts per bin, so ``density=False`` should be passed to
    `rv_histogram`. If `numpy.histogram` is called with ``density=True``, the
    resulting histogram is in terms of probability density, so ``density=True``
    should be passed to `rv_histogram`. To avoid warnings, always pass
    ``density`` explicitly when the input histogram has unequal bin widths.

    There are no additional shape parameters except for the loc and scale.
    The pdf is defined as a stepwise function from the provided histogram.
    The cdf is a linear interpolation of the pdf.

    .. versionadded:: 0.19.0

    Examples
    --------

    Create a scipy.stats distribution from a numpy histogram

    >>> import scipy.stats
    >>> import numpy as np
    >>> data = scipy.stats.norm.rvs(size=100000, loc=0, scale=1.5,
    ...                             random_state=123)
    >>> hist = np.histogram(data, bins=100)
    >>> hist_dist = scipy.stats.rv_histogram(hist, density=False)

    Behaves like an ordinary scipy rv_continuous distribution

    >>> hist_dist.pdf(1.0)
    0.20538577847618705
    >>> hist_dist.cdf(2.0)
    0.90818568543056499

    PDF is zero above (below) the highest (lowest) bin of the histogram,
    defined by the max (min) of the original dataset

    >>> hist_dist.pdf(np.max(data))
    0.0
    >>> hist_dist.cdf(np.max(data))
    1.0
    >>> hist_dist.pdf(np.min(data))
    7.7591907244498314e-05
    >>> hist_dist.cdf(np.min(data))
    0.0

    PDF and CDF follow the histogram

    >>> import matplotlib.pyplot as plt
    >>> X = np.linspace(-5.0, 5.0, 100)
    >>> fig, ax = plt.subplots()
    >>> ax.set_title("PDF from Template")
    >>> ax.hist(data, density=True, bins=100)
    >>> ax.plot(X, hist_dist.pdf(X), label='PDF')
    >>> ax.plot(X, hist_dist.cdf(X), label='CDF')
    >>> ax.legend()
    >>> fig.show()

    N)densityc                8   || _         || _        t          |          dk    rt          d          t	          j        |d                   | _        t	          j        |d                   | _        t          | j                  dz   t          | j                  k    rt          d          | j        dd         | j        dd         z
  | _        t	          j	        | j        | j        d                    }|#|r!d}t          j        |t          d	           d
}n|s| j        | j        z  | _        | j        t          t	          j        | j        | j        z                      z  | _        t	          j        | j        | j        z            | _        t	          j        d| j        dg          | _        t	          j        d| j        g          | _        | j        d         x|d<   | _        | j        d         x|d<   | _         t)                      j        |i | dS )a5  
        Create a new distribution using the given histogram

        Parameters
        ----------
        histogram : tuple of array_like
            Tuple containing two array_like objects.
            The first containing the content of n bins,
            the second containing the (n+1) bin boundaries.
            In particular, the return value of np.histogram is accepted.
        density : bool, optional
            If False, assumes the histogram is proportional to counts per bin;
            otherwise, assumes it is proportional to a density.
            For constant bin widths, these are equivalent.
            If None (default), sets ``density=True`` for backward
            compatibility, but warns if the bin widths are variable. Set
            `density` explicitly to silence the warning.
        rU   z)Expected length 2 for parameter histogramr   r   zbNumber of elements in histogram content and histogram boundaries do not match, expected n and n+1.Nr  zjBin widths are not constant. Assuming `density=True`.Specify `density` explicitly to silence this warning.rI  Tr   r   r   )
_histogram_densityr  r   rP   r   _hpdf_hbins_hbin_widthsallcloserL  rM  rN  rW  r  cumsum_hcdfhstackr   r   rA   rQ  )rE   	histogramr  rG   r  	bins_varyrP  r  s          r6   rQ  zrv_histogram.__init__)/  s   & $y>>QHIIIZ	!--
j1..tz??Q#dk"2"222 3 4 4 4 !KOdk#2#.>>D$5t7H7KLLL	?y?OGM'>a@@@@GG 	8d&77DJZ%tzD<M/M(N(N"O"OO
YtzD,==>>
YTZ566
YTZ011
#{1~-sdf#{2.sdf$)&)))))r8   c                 P    | j         t          j        | j        |d                   S )z&
        PDF of the histogram
        r)  )side)r  rP   searchsortedr  r   s     r6   rr   zrv_histogram._pdfY/  s$     z"/$+qwGGGHHr8   c                 B    t          j        || j        | j                  S )z3
        CDF calculated from the histogram
        )rP   interpr  r  r   s     r6   ru   zrv_histogram._cdf_/  s     yDK444r8   c                 B    t          j        || j        | j                  S )zC
        Percentile function calculated from the histogram
        )rP   r  r  r  r   s     r6   r~   zrv_histogram._ppfe/  s     yDJ444r8   c                     | j         dd         |dz   z  | j         dd         |dz   z  z
  |dz   z  }t          j        | j        dd         |z            S )z$Compute the n-th non-central moment.r   Nr  )r  rP   r  r  )rE   rb   	integralss      r6   r  zrv_histogram._munpk/  s\    [_qs+dk#2#.>1.EE!A#N	vdj2&2333r8   c                     t          | j        dd         dk    | j        dd         ft          j        d          }t          j        | j        dd         |z  | j        z             S )zCompute entropy of distributionr   r  r   )r   r  rP   r   r  r  )rE   r  s     r6   r   zrv_histogram._entropyp/  si    AbD)C/*QrT*,  tz!B$'#-0AABBBBr8   c                 p    t                                                      }| j        |d<   | j        |d<   |S )zF
        Set the histogram as additional constructor argument
        r  r  )rA   _updated_ctor_paramr  r  )rE   dctr  s     r6   r  z rv_histogram._updated_ctor_paramx/  s6     gg))++?KI
r8   )r   r   r   r   r   r  rQ  rr   ru   r~   r  r   r  r  r  s   @r6   r  r  .  s        Z Zv "/M15 .* .* .* .* .* .* .*`I I I5 5 55 5 54 4 4
C C C        r8   r  c                   @     e Zd ZdZd Zd Z fdZd Zd Zd Z	 xZ
S )studentized_range_genuO  A studentized range continuous random variable.

    %(before_notes)s

    See Also
    --------
    t: Student's t distribution

    Notes
    -----
    The probability density function for `studentized_range` is:

    .. math::

         f(x; k, \nu) = \frac{k(k-1)\nu^{\nu/2}}{\Gamma(\nu/2)
                        2^{\nu/2-1}} \int_{0}^{\infty} \int_{-\infty}^{\infty}
                        s^{\nu} e^{-\nu s^2/2} \phi(z) \phi(sx + z)
                        [\Phi(sx + z) - \Phi(z)]^{k-2} \,dz \,ds

    for :math:`x ≥ 0`, :math:`k > 1`, and :math:`\nu > 0`.

    `studentized_range` takes ``k`` for :math:`k` and ``df`` for :math:`\nu`
    as shape parameters.

    When :math:`\nu` exceeds 100,000, an asymptotic approximation (infinite
    degrees of freedom) is used to compute the cumulative distribution
    function [4]_ and probability distribution function.

    %(after_notes)s

    References
    ----------

    .. [1] "Studentized range distribution",
           https://en.wikipedia.org/wiki/Studentized_range_distribution
    .. [2] Batista, Ben Dêivide, et al. "Externally Studentized Normal Midrange
           Distribution." Ciência e Agrotecnologia, vol. 41, no. 4, 2017, pp.
           378-389., doi:10.1590/1413-70542017414047716.
    .. [3] Harter, H. Leon. "Tables of Range and Studentized Range." The Annals
           of Mathematical Statistics, vol. 31, no. 4, 1960, pp. 1122-1147.
           JSTOR, www.jstor.org/stable/2237810. Accessed 18 Feb. 2021.
    .. [4] Lund, R. E., and J. R. Lund. "Algorithm AS 190: Probabilities and
           Upper Quantiles for the Studentized Range." Journal of the Royal
           Statistical Society. Series C (Applied Statistics), vol. 32, no. 2,
           1983, pp. 204-210. JSTOR, www.jstor.org/stable/2347300. Accessed 18
           Feb. 2021.

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

    Display the probability density function (``pdf``):

    >>> k, df = 3, 10
    >>> x = np.linspace(studentized_range.ppf(0.01, k, df),
    ...                 studentized_range.ppf(0.99, k, df), 100)
    >>> ax.plot(x, studentized_range.pdf(x, k, df),
    ...         'r-', lw=5, alpha=0.6, label='studentized_range 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 = studentized_range(k, df)
    >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

    Check accuracy of ``cdf`` and ``ppf``:

    >>> vals = studentized_range.ppf([0.001, 0.5, 0.999], k, df)
    >>> np.allclose([0.001, 0.5, 0.999], studentized_range.cdf(vals, k, df))
    True

    Rather than using (``studentized_range.rvs``) to generate random variates,
    which is very slow for this distribution, we can approximate the inverse
    CDF using an interpolator, and then perform inverse transform sampling
    with this approximate inverse CDF.

    This distribution has an infinite but thin right tail, so we focus our
    attention on the leftmost 99.9 percent.

    >>> a, b = studentized_range.ppf([0, .999], k, df)
    >>> a, b
    0, 7.41058083802274

    >>> from scipy.interpolate import interp1d
    >>> rng = np.random.default_rng()
    >>> xs = np.linspace(a, b, 50)
    >>> cdf = studentized_range.cdf(xs, k, df)
    # Create an interpolant of the inverse CDF
    >>> ppf = interp1d(cdf, xs, fill_value='extrapolate')
    # Perform inverse transform sampling using the interpolant
    >>> r = ppf(rng.uniform(size=1000))

    And compare the histogram:

    >>> ax.hist(r, density=True, histtype='stepfilled', alpha=0.2)
    >>> ax.legend(loc='best', frameon=False)
    >>> plt.show()

    c                     |dk    |dk    z  S r  r   )rE   r  r  s      r6   rc   zstudentized_range_gen._argcheck/  s    A"q&!!r8   c                     t          dddt          j        fd          }t          dddt          j        fd          }||gS )Nr  Fr   r
  r  r   rh   )rE   r  r	  s      r6   rk   z!studentized_range_gen._shape_info/  s>    UQK@@uq"&k>BBCyr8   c                 J    t                                          |d          S )N)rU   r   rN  rX  rY  s     r6   r  zstudentized_range_gen._fitstart/  s     ww  F 333r8   c                     d|                                  \  fd}t          j        |dd          }t          j         ||||          t          j                  d         S )N_studentized_range_momentc                    t          j        ||          }| |||g}t          j        |t                    j                            t
          j                  }t          j	        t           |          }t          j
         t          j
        fdt          j
        f	
fg}t          dd          }t          j        |||          d         S )Nr   r  -q=r  r  rangesopts)r   _studentized_range_pdf_logconstrP   r  rW  r  r  r  r   r  ri   dictr   nquad)r  r  r  	log_constargusr_datar  r  r  r  r  cython_symbols            r6   _single_momentz3studentized_range_gen._munp.<locals>._single_moment/  s    >q"EEIaY'CxU++2::6?KKH".v}hOOCw'!RVr2h?FuU333D?3vDAAA!DDr8   r  r   r
  r   )r   rP   
frompyfuncr   r  )	rE   r  r  r  r  ufuncr  r  r  s	         @@@r6   r  zstudentized_range_gen._munp/  s    3""$$B
	E 
	E 
	E 
	E 
	E 
	E 
	E na33z%%1b//<<<R@@r8   c                     d }t          j        |dd          }t          j         ||||          t           j                  d         S )Nc                 Z   |dk     rd}t          j        ||          }| |||g}t          j        |t                    j                            t
          j                  }t          j         t          j        fdt          j        fg}n\d}| |g}t          j        |t                    j                            t
          j                  }t          j         t          j        fg}t          j
        t           ||          }t          dd          }	t          j        |||	          d         S )	N順 _studentized_range_pdfr   !_studentized_range_pdf_asymptoticr  r  r  r  )r   r  rP   r  rW  r  r  r  ri   r   r  r  r   r  
r}   r  r  r  r  r  r  r  r  r  s
             r6   _single_pdfz/studentized_range_gen._pdf.<locals>._single_pdf0  s     F{{ 8"B1bII	!R+8C//6>>vOOF7BF+a[9 !D!f8C//6>>vOOF7BF+,".v}hOOCuU333D?3vDAAA!DDr8   r  r   r
  r   )rP   r  r   r  )rE   rq   r  r  r  r  s         r6   rr   zstudentized_range_gen._pdf0  sQ    	E 	E 	E( k1a00z%%1b//<<<R@@r8   c           	          d }t          j        |dd          }t          j        t          j         ||||          t           j                  d         dd          S )Nc                 Z   |dk     rd}t          j        ||          }| |||g}t          j        |t                    j                            t
          j                  }t          j         t          j        fdt          j        fg}n\d}| |g}t          j        |t                    j                            t
          j                  }t          j         t          j        fg}t          j
        t           ||          }t          dd          }	t          j        |||	          d         S )	Nr  _studentized_range_cdfr   !_studentized_range_cdf_asymptoticr  r  r  r  )r   _studentized_range_cdf_logconstrP   r  rW  r  r  r  ri   r   r  r  r   r  r  s
             r6   _single_cdfz/studentized_range_gen._cdf.<locals>._single_cdf)0  s    
 F{{ 8"B1bII	!R+8C//6>>vOOF7BF+a[9 !D!f8C//6>>vOOF7BF+,".v}hOOCuU333D?3vDAAA!DDr8   r  r   r
  r   r   )rP   r  r	  r   r  )rE   rq   r  r  r  r  s         r6   ru   zstudentized_range_gen._cdf'0  sa    	E 	E 	E, k1a00 wrz%%1b//DDDRH!QOOOr8   )r   r   r   r   rc   rk   r  r  rr   ru   r  r  s   @r6   r  r  /  s        h hT" " "  
4 4 4 4 4A A A*A A A2P P P P P P Pr8   r  studentized_range)r   r   r   c                   h     e Zd ZdZd Zd Zd Zd Zd Zd Z	 e
e           fd            Z xZS )	rel_breitwigner_gena  A relativistic Breit-Wigner random variable.

    %(before_notes)s

    See Also
    --------
    cauchy: Cauchy distribution, also known as the Breit-Wigner distribution.

    Notes
    -----

    The probability density function for `rel_breitwigner` is

    .. math::

        f(x, \rho) = \frac{k}{(x^2 - \rho^2)^2 + \rho^2}

    where

    .. math::
        k = \frac{2\sqrt{2}\rho^2\sqrt{\rho^2 + 1}}
            {\pi\sqrt{\rho^2 + \rho\sqrt{\rho^2 + 1}}}

    The relativistic Breit-Wigner distribution is used in high energy physics
    to model resonances [1]_. It gives the uncertainty in the invariant mass,
    :math:`M` [2]_, of a resonance with characteristic mass :math:`M_0` and
    decay-width :math:`\Gamma`, where :math:`M`, :math:`M_0` and :math:`\Gamma`
    are expressed in natural units. In SciPy's parametrization, the shape
    parameter :math:`\rho` is equal to :math:`M_0/\Gamma` and takes values in
    :math:`(0, \infty)`.

    Equivalently, the relativistic Breit-Wigner distribution is said to give
    the uncertainty in the center-of-mass energy :math:`E_{\text{cm}}`. In
    natural units, the speed of light :math:`c` is equal to 1 and the invariant
    mass :math:`M` is equal to the rest energy :math:`Mc^2`. In the
    center-of-mass frame, the rest energy is equal to the total energy [3]_.

    %(after_notes)s

    :math:`\rho = M/\Gamma` and :math:`\Gamma` is the scale parameter. For
    example, if one seeks to model the :math:`Z^0` boson with :math:`M_0
    \approx 91.1876 \text{ GeV}` and :math:`\Gamma \approx 2.4952\text{ GeV}`
    [4]_ one can set ``rho=91.1876/2.4952`` and ``scale=2.4952``.

    To ensure a physically meaningful result when using the `fit` method, one
    should set ``floc=0`` to fix the location parameter to 0.

    References
    ----------
    .. [1] Relativistic Breit-Wigner distribution, Wikipedia,
           https://en.wikipedia.org/wiki/Relativistic_Breit-Wigner_distribution
    .. [2] Invariant mass, Wikipedia,
           https://en.wikipedia.org/wiki/Invariant_mass
    .. [3] Center-of-momentum frame, Wikipedia,
           https://en.wikipedia.org/wiki/Center-of-momentum_frame
    .. [4] M. Tanabashi et al. (Particle Data Group) Phys. Rev. D 98, 030001 -
           Published 17 August 2018

    %(example)s

    c                     |dk    S r7  r   rE   rhos     r6   rc   zrel_breitwigner_gen._argcheck0  s    Qwr8   c                 @    t          dddt          j        fd          gS )Nr  Fr   r
  rh   rj   s    r6   rk   zrel_breitwigner_gen._shape_info0  rt  r8   c           
      0   t          j        ddd|dz  z  z   z  dt          j        dd|dz  z  z             z   z            dz  t           j        z  }t          j        d          5  |||z
  ||z   z  |z  dz  dz   z  cd d d            S # 1 swxY w Y   d S )NrU   r   r9  rr  )rP   r   r   r<  )rE   rq   r  rF  s       r6   rr   zrel_breitwigner_gen._pdf0  s    GQsAvX!bga!CF(l&;&;";<
 
 [h''' 	: 	:!c'AG,S014q89	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   'BBBc           
      |   t          j        ddt          j        dd|dz  z  z             z   z            t           j        z  }t          j        dd|z  z             t          j        |t          j        | |dz   z            z            z  }|dz  t          j        |          z  }t          j        |d d          S )NrU   r   r  rK  )rP   r   r   r  imagr	  )rE   rq   r  rF  r  s        r6   ru   zrel_breitwigner_gen._cdf0  s    GAq271qax<000122258GBCK  i"'3$b/222334 	 Q(wvtQ'''r8   c                 4   |dk    rdS |dk    rxt          j        ddd|dz  z  z   z  dt          j        dd|dz  z  z             z   z            t           j        z  |z  }|t           j        dz  t          j        |          z   z  S |dk    rt          j        dd|dz  z  z   ddt          j        dd|dz  z  z             z   z  z            |z  }d|dz  z
  t          j        dd|z  z
            z  }d|z  t          j        |          z  S t           j        S )Nr   r   r   rU   rK  r  )rP   r   r   r  r  ri   )rE   rb   r  rF  r  s        r6   r  zrel_breitwigner_gen._munp0  s*   66266Q36\"a"'!aQh,*?*?&?@ A a")C..01166QsAvX!q271qax<+@+@'@"AB A #(lbgb2c6k&:&::Fq5276??**6Mr8   c                 6    d d t           j        t           j        fS rN   r  r  s     r6   r   zrel_breitwigner_gen._stats0  s     T2626))r8   c                    t          | |||          \  }}}}t          |t                    }|r!|                                dk    r	|j        }d}||r t                      j        |g|R i |S |7t          j        ||z
  g d          \  }}	}
|
|z
  }|	|z  }|s|g}d|vr||d<   n!t          j	        ||z
            }||z  }|s|g} t                      j        |g|R i |S )Nr   F)r  r   g      ?r/   )
rL  r?   r*   r@   rD   rA   rC   rP   quantiler  )rE   rF   rG   r5   r	  r   r   rH   r  r  r  scale_0rho_0M_0r  s                 r6   rC   zrel_breitwigner_gen.fit0  sD    !<$d!
 !
av dL11 	!  ""a'' ' <8<577;t3d333d333> Kt5F5F5FGGMCcCiG'ME wd"" 'W)D4K((C&LE wuww{4/$///$///r8   )r   r   r   r   rc   rk   rr   ru   r  r   r   r   rC   r  r  s   @r6   r  r  I0  s        < <z  G G G: : :	( 	( 	(  &* * * M** 0  0  0  0 +* 0  0  0  0  0r8   r  rel_breitwignerrN   (Q  rL  collections.abcr   	functoolsr   r   r  numpyrP   numpy.polynomialr   scipy.interpolater   scipy._lib.doccerr	   r
   r   scipy._lib._ccallbackr   scipyr   r   scipy.specialspecialrw   scipy.special._ufuncsr  rn   scipy._lib._utilr   r   rV  r   _tukeylambda_statsr   r  r   r  _distn_infrastructurer   r   r   r   r   r   r   r   r   (scipy.stats._distribution_infrastructurer   _ksstatsr   r    r!   
_constantsr"   r#   r$   r%   r&   r'   r(   r)   _censored_datar*   scipy.optimizer+   scipy.stats._warnings_errorsr,   scipy.statsr  r7   rK   rZ   r\   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r4  r6  rJ  r   rL  rW   r`  rd  rf  ro  r  r  r	  r   r"  r_  ra  rs  ru  r  r  r  r  r  r  r  r  r  r  r(  r*  rY  r[  rt  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r+  r-  r^  rR  rr  _supportrt  r  r  r  r  r  r  r  r  r  r#  r%  r  rG  rU  rW  rv  rx  r  r  r  r  r  r  r  r  r  r  r  r  r-  rK  rM  r]  rb  rn  rp  ry  r{  r  r  r  r  r  r  r2  r4  rB  rD  rY  r[  rf  rh  rx  rz  r  r  r  r  r  rL  r  r  r  r  r  r  r  r  r   r/  r3  r5  rZ  rd  rq  rs  r  r  r  r  r  r  r  r  r  r  r		  r	  r	  r<	  r>	  rW	  rY	  r  r	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r
  r
  r
  r%
  r'
  r1
  r3
  rI
  rM
  r_
  r`
  rb
  rp
  rr
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r
  r  r  r  r  _method_namesr  rD  setattrr  r5  r7  rD  rI  r[
  rW  rY  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r%  r'  r;  r=  rF  rH  rm  rp  rr  r  r  r  ri   r  r  r  listglobalsr	  itemspairs_distn_names_distn_gen_names__all__r   r8   r6   <module>r     s}$  
  $ $ $ $ $ $ , , , , , , , ,      ' ' ' ' ' ' % % % % % %7 7 7 7 7 7 7 7 7 7 3 2 2 2 2 2                   # # # # # # # # # 4 4 4 4 4 4 4 4      B B B B B B B BJ J J J J J J J J J J J J J J J J J J J J J ? > > > > > 1 1 1 1 1 1 1 1 1 1H H H H H H H H H H H H H H H H H H H H ( ( ( ( ( ( & & & & & & 1 1 1 1 1 1      7 7 7&  *   .W! W! W! W! W! W! W! W!t 		C3W---Z) Z) Z) Z) Z) Z) Z) Z)| 		!sc8885 5 5 5 5M 5 5 5p MCk222	 bgag$$+ + +( ( (            m m m m m} m m m` xV3' 3' 3' 3' 3' 3' 3' 3'l 		Cg&&&( ( ( ( ( ( ( (V 
rufQh"%'	9	9	9*' *' *' *' *'- *' *' *'Z +s
3
3
3

 

 

 

 

: 

 

 

	 	 	 	 	X 	 	 	    w! w! w! w! w!} w! w! w!t x#6***m m m m mM m m m` MCk222	4# 4# 4# 4# 4#= 4# 4# 4#n <#:666~" ~" ~" ~" ~"} ~" ~" ~"B x#F###T, T, T, T, T, T, T, T,n 
c	)	)	)O O O O Ox O O Od x#F###J" J" J" J" J" J" J" J"Z 
	"	"	"O1 O1 O1 O1 O1m O1 O1 O1d g%   V1 V1 V1 V1 V1} V1 V1 V1r x#F###4# 4# 4# 4# 4# 4# 4# 4#n 
rufH	5	5	5J6 J6 J6 J6 J6 J6 J6 J6Z 
	"	"	"D D D D D- D D DN &%0ABBBE E E E E= E E EP <Z(((j( j( j( j( j( j( j( j(Z 		Cg&&&K! K! K! K! K!M K! K! K!\ M{+++	& & &&E4 E4 E4 E4 E4M E4 E4 E4P MCk222	23 23 23 23 23= 23 23 23j <#J///J J J J Jm J J JZ o-888-. -. -. -. -.] -. -. -.` ^c555
k@ k@ k@ k@ k@M k@ k@ k@\ 
ECc; ; ; ; ;= ; ; ;| <#J///^F ^F ^F ^F ^Fm ^F ^F ^FB o-888h! h! h! h! h!= h! h! h!V ('-?@@@ &  D4 D4 D4 D4 D4m D4 D4 D4N o-888Q? Q? Q? Q? Q?m Q? Q? Q?h o=111u u u u uM u u up MCk222	=; =; =; =; =;= =; =; =;@ <#J///\" \" \" \" \"] \" \" \"~ ^...
) ) )dP P P P P P P Pf 		Cg&&&40 40 40 40 40 40 40 40n 
c	)	)	)^ ^ ^ ^ ^= ^ ^ ^B <#J////% /% /% /% /%- /% /% /%d &%2CDDDb b b b b b b bJ "!777-> -> -> -> ->= -> -> ->` <#J///* * *~ ~ ~ ~ ~= ~ ~ ~B <Z(((K K K K K= K K K\ <Z(((W W W W W] W W Wt ^c555
{ { { { {} { { {|  #N;;;P P P P P= P P Pf <#J///+ + + + +M + + +\ M{+++	5 5 5 5 5] 5 5 5p ^cS|<<<
S S S S S= S S Sl <#J///T! T! T! T! T!= T! T! T!n <#J///y y y y ym y y yx	 o-888P2 P2 P2 P2 P2} P2 P2 P2f  ^444@2 @2 @2 @2 @2] @2 @2 @2F ^al333
a
 a
 a
 a
 a
M a
 a
 a
H M{+++	56 56 56 56 56M 56 56 56p MC3[999	Z Z Z Z ZM Z Z Zz M{+++	V V V V V V V Vr 
	"	"	"E E E E E- E E EP +9
%
%
%]) ]) ]) ]) ])] ]) ]) ])@ ,+1EFFF .* .* .*bb. b. b. b. b.} b. b. b.J x#F###b. b. b. b. b. b. b. b.J 
c	)	)	)q7 q7 q7 q7 q7= q7 q7 q7h <Z(((o o o o o= o o od <Z(((^ ^ ^ ^ ^] ^ ^ ^@ ^c555
  C! C! C! C! C!- C! C! C!L +)
,
,
,:- :- :- :- :- :- :- :-z 
c	)	)	)>0 >0 >0 >0 >0- >0 >0 >0B +)
,
,
,;@ ;@ ;@ ;@ ;@ ;@ ;@ ;@| 
c	)	)	)LI LI LI LI LI LI LI LI^ 
	"	"	"JI JI JI JI JI JI JI JIZ 
c	)	)	)Y$ Y$ Y$ Y$ Y$ Y$ Y$ Y$x 		wa# a# a# a# a#= a# a# a#H <#J///   `
 `
 `
 `
 `
} `
 `
 `
F x#F###] ] ] ] ]m ] ] ]@ g%   s s s s sM s s sl 
EsOOOE E E E Em E E EP g5[! [! [! [! [! [! [! [!| 
c	)	)	)6! 6! 6! 6! 6! 6! 6! 6!r 		Cg&&&AD AD AD AD AD= AD AD ADH <Z(((W4 W4 W4 W4 W4= W4 W4 W4t <#:66640 40 40 40 40} 40 40 40n  #N;;;31 31 31 31 31M 31 31 31l M{+++	:3 :3 :3 :3 :3 :3 :3 :3z 		DCg...v v v v v= v v vr <#J///c? c? c? c? c?] c? c? c?T ^...
^...
 
  
 <& <& <& <& <&} <& <& <&~ x#F###}& }& }& }& }&M }& }& }&@ M{+++		 29 29 29 29 29 29 29 29j "!Co>>>9& 9& 9& 9& 9&} 9& 9& 9&x  $#NCCC@' @' @' @' @'] @' @' @'F ^...
^F ^F ^F ^F ^F= ^F ^F ^FB <Z(((gE gE gE gE gEM gE gE gEV2* * * * * * * * MC3[999		C3W---  	, 	, 	, 	, 	, 	, 	, 	, 
 . .AGE1))!,,----F F F F F F F FR 
cSx	0	0	0<4 <4 <4 <4 <4] <4 <4 <4~ ^c555
 
 0 0 0
9 9 9% % %Pg7 g7 g7 g7 g7M g7 g7 g7T M{A666		 z z z z zm z z zz	 o-888! 8. 8. 8. 8. 8.m 8. 8. 8.v o=111
 
 
 
 
L 
 
 
t( t( t( t( t(- t( t( t(n +s
3
3
3o o o o o= o o od <Z(((v_EEE:& :& :& :& :&| :& :& :&z x#F###<9 <9 <9 <9 <9] <9 <9 <9~ ^cQruW<@@@
T T T T T- T T Tn +9
%
%
%=> => => => =>m => => =>@ o666e& e& e& e& e&m e& e& e&P o=;STTT* * *G) G) G) G) G) G) G) G)T 		w)<sKKKt t t t t= t t tn@P @P @P @P @PM @P @P @PF *)/Ba,.F4 4 4 Q0 Q0 Q0 Q0 Q0- Q0 Q0 Q0h &%2CDDD 	WWYY^^##%%&&!7!7}!M!M 
)
)^,<
<r8   