
    (ph8                       S SK r S SKJr  S SKJrJr  S SKrS SKrS SK	J
r
  S SKJr  S SKJrJrJr  S SKJr  S SKJr  S S	KJr  S SKJr  S SKJs  Jr  S S
KJrJr  SSKJ r   SSK!J"r#J$r%  SSK&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/  S SK0J1r1  SSK2J3r3J4r4J5r5  SSK6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>  SSK?J@r@  S SKAJBrB  S SKCJDrD  S SKEJFrF  S rGS rHGSS jrI " S S\+5      rJ\J" SSSS9rK " S S\+5      rL\L" S SSS S!9rM " S" S#\+5      rN\N" SS$S%9rO\R                  " S&\R                  -  5      rR\R                  " \R5      rTS' rUS( rVS) rWS* rXS+ rYS, rZS- r[S. r\ " S/ S0\+5      r]\]" S1S29r^ " S3 S4\+5      r_\_" SS5S%9r` " S6 S7\+5      ra\a" \R                  * S8-  \R                  S8-  S9S9rb " S: S;\+5      rc\c" SSS<S9rd " S= S>\e5      rf " S? S@\D5      rgSA rhSB ri " SC SD\+5      rj\j" SSSES9rk " SF SG\+5      rl\l" SSHS%9rm " SI SJ\+5      rn\n" SSSKS9ro " SL SM\+5      rp\p" SSNS%9rq " SO SP\+5      rr\r" SSQS%9rs " SR SS\p5      rt\t" SSTS%9ru " SU SV\+5      rv\v" SWS29rw " SX SY\+5      rx\x" SSZS%9ry " S[ S\\+5      rz\z" SS]S%9r{ " S^ S_\+5      r|\|" \R                  * \R                  S`S9r} " Sa Sb\+5      r~\~" ScS29r " Sd Se\+5      r\" S SfS%9r " Sg Sh\+5      r\" SiS29r " Sj Sk\+5      r\" SSlS%9r " Sm Sn\+5      r\" SoS29rSp r " Sq Sr\+5      r\" SSsS%9r " St Su\+5      r\" SSvS%9r " Sw Sx\+5      r\" SSyS%9r " Sz S{\+5      r\" SS|S%9r " S} S~\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SS29rS\l         " S S\+5      r\" SSS9r " S S\+5      r\" SS29r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SS29rS r " S S\+5      r\" SSS%9r " S S\5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SS29r " S S\+5      r\" SSS%9rS r " S S\+5      r\" SS29r " S S\+5      r\" SS29r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SS29r " S S\+5      r\" SSSS9r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SS29r " S S\+5      r\" S SS%9r " S S\+5      r\" SS29r " S S\+5      r\" SSSS9r " S S\+5      r\" SS29r " S S\+5      r\" SS29r " S S\+5      r\" SS29r " S S\+5      r\" SS29rS r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS9r " S S\+5      r\" SS29r " S S\+5      r\" SS29r " S S\+5      r\" SSS%9rS r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SSS%9r " S S\+5      r\" SGS S%9r " GS GS\+5      r\" GSS29r " GS GS\+5      r\" SGSS%9r " GS GS\+5      r\" GS	S29r " GS
 GS\+5      r\" SGSS%9rGS r " GS GS\+5      r\" SGSS%9r " GS GS\+5      r\" SGSS%9r " GS GS\+5      r\" GSS29r " GS GS\+5      r\" GSS29r " GS GS\+5      r\" SGSS%9r " GS GS\+5      r\" SGSS%9r " GS  GS!\+5      r\" GS"S29Gr  " GS# GS$\+5      GrG\" SSGS%S9Gr " GS& GS'\+5      GrG\" SGS(S%9Gr " GS) GS*\+5      GrG\" GS+S29Gr " GS, GS-\+5      GrG\" GS.SGS/S9Gr " GS0 GS1\+5      Gr	G\	" SGS2S%9Gr
 " GS3 GS4\+5      GrG\" GS5S29GrG\" GS6S29GrSG\l        SG\l         " GS7 GS8\+5      GrG\" SGS9S%9Gr " GS: GS;\+5      GrG\" GS<S29GrGS=G\l         " GS> GS?\+5      GrG\" SGS@S%9Gr " GSA GSB\+5      GrG\" GS.SGSCS9Gr " GSD GSE\+5      GrG\" GSFS29Gr " GSG GSH\+5      GrG\" GSIS29Gr " GSJ GSK\+5      GrGSLGr " GSM GSNG\5      GrG\" SSGSOS9GrG\" SSGSPS9Gr/ GSQQGr " GSR GSS5      Gr G\ H  Gr!G\"" G\G\!G\ " G\!5      5        M      " GST GSU\+5      Gr#G\#" SSGSVS9Gr$ " GSW GSX\+5      Gr%G\%" SGSYS%9Gr&GSZG\&l        GS[ Gr'GS\ Gr(GS] Gr) " GS^ GS_\+5      Gr*G\*" GS`SGSa9Gr+SG\+l         " GSb GSc\+5      Gr,G\," SGSdS%9Gr-GSeG\-l         " GSf GSg\+5      Gr.G\." GShS29Gr/ " GSi GSj\f5      Gr0 " GSk GSl\+5      Gr1G\1" SSGSmS9Gr2 " GSn GSo\+5      Gr3G\3" GSpS29Gr4G\3" \R                  * \R                  GSqS9Gr5 " GSr GSs\5      Gr6G\6" SGStS%9Gr7 " GSu GSv\+5      Gr8G\8" SS&\R                  -  GSwS9Gr9 " GSx GSy\+5      Gr:G\:" GSzS29Gr; " GS{ GS|\+5      Gr<G\<" S GS}S%9Gr= " GS~ GS\+5      Gr>G\>" GSGSGS9Gr?GS Gr@ " GS GS\+5      GrAG\A" GSGSSSGS9GrB " GS GS\+5      GrC " GS GS\+5      GrDG\D" GSS \GR                  GS9GrF " GS GS\+5      GrGG\G" SGSS%9GrHG\I" G\J" 5       GR                  5       GR                  5       5      GrM\(" G\M\+5      u  GrNGrOG\NG\O-   GS/-   GrPg(      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                     U R                  SS5        U R                  SS5        U R                  SS5        U R                  SS5        U (       a  [        SU  S35      eg)aj  
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    Q/var/www/html/venv/lib/python3.13/site-packages/scipy/stats/_continuous_distns.py_remove_optimizer_parametersr7   '   sY     	HHUDHHWdHH[$HHXt-dV1566     c                 0   ^  [        T 5      U 4S j5       nU$ )Nc                   > UR                  SS5      R                  5       n[        U[        5      nUS:X  d  U(       a1  UR	                  5       S:  a  [
        [        U 5      U ]  " U/UQ70 UD6$ U(       a  UR                  nT" X/UQ70 UD6$ )Nr1   mlemmr   )	getlower
isinstancer*   num_censoredsupertypefit_uncensored)selfdataargsr5   r1   censoredfuns         r6   wrapper _call_super_mom.<locals>.wrapper>   s    (E*002dL1T>h4+<+<+>+BdT.tCdCdCC ''t1D1D11r8   )r   )rI   rJ   s   ` r6   _call_super_momrL   :   s"     3Z2 2 Nr8   c                    ^  U=(       d    US-
  nX-
  nU 4S jnU" X!5      (       d@  US-  nX-
  nSn[         R                  " U5      (       a  [        U5      eU" X!5      (       d  M@  U$ )Nr   c                 v   > [         R                  " T" U 5      5      [         R                  " T" U5      5      :g  $ Nnpsign)lbrackrbrackrI   s     r6   interval_contains_root1_get_left_bracket.<locals>.interval_contains_rootV   s(    wws6{#rwws6{';;;r8      zVThe solver could not find a bracket containing a root to an MLE first order condition.)rQ   isinfFitSolverError)rI   rT   rS   diffrU   msgs   `     r6   _get_left_bracketr\   O   so    !vzF?D< %V44	788F %% %V44 Mr8   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)	ksone_genf   a!  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                 @    US:  U[         R                  " U5      :H  -  $ Nr   rQ   roundrE   ns     r6   	_argcheckksone_gen._argcheck       Q1+,,r8   c                 @    [        SSS[        R                  4S5      /$ Nre   Tr   TFr   rQ   infrE   s    r6   _shape_infoksone_gen._shape_info       3q"&&k=ABBr8   c                 0    [         R                  " X!5      * $ rO   )scu	_smirnovprE   xre   s      r6   _pdfksone_gen._pdf   s    a###r8   c                 .    [         R                  " X!5      $ rO   )rs   	_smirnovcru   s      r6   _cdfksone_gen._cdf   s    }}Q""r8   c                 .    [         R                  " X!5      $ rO   )scsmirnovru   s      r6   _sfksone_gen._sf   s    zz!r8   c                 .    [         R                  " X!5      $ rO   )rs   
_smirnovcirE   qre   s      r6   _ppfksone_gen._ppf   s    ~~a##r8   c                 .    [         R                  " X!5      $ rO   )r~   smirnovir   s      r6   _isfksone_gen._isf       {{1  r8    N)__name__
__module____qualname____firstlineno____doc__rf   ro   rw   r{   r   r   r   __static_attributes__r   r8   r6   r^   r^   f   s-    BF-C$# $!r8   r^                 ?ksone)abnamec                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)	kstwo_gen   a  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                 @    US:  U[         R                  " U5      :H  -  $ ra   rb   rd   s     r6   rf   kstwo_gen._argcheck  rh   r8   c                 @    [        SSS[        R                  4S5      /$ rj   rl   rn   s    r6   ro   kstwo_gen._shape_info	  rq   r8   c                 n    S[        U[        5      (       d  U-  S4$ [        R                  " U5      -  S4$ N      ?r   )r?   r   rQ   
asanyarrayrd   s     r6   _get_supportkstwo_gen._get_support  s>    jH55QL 	2==;KL 	r8   c                     [        X!5      $ rO   )r    ru   s      r6   rw   kstwo_gen._pdf  s    ~r8   c                     [        X!5      $ rO   r   ru   s      r6   r{   kstwo_gen._cdf  s    q}r8   c                     [        X!SS9$ NFcdfr   ru   s      r6   r   kstwo_gen._sf  s    q''r8   c                     [        X!SS9$ )NTr   r!   r   s      r6   r   kstwo_gen._ppf  s    $''r8   c                     [        X!SS9$ r   r   r   s      r6   r   kstwo_gen._isf  s    %((r8   r   N)r   r   r   r   r   rf   ro   r   rw   r{   r   r   r   r   r   r8   r6   r   r      s2    AD-C(()r8   r   kstwo)momtyper   r   r   c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)kstwobign_geni$  a  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                     / $ rO   r   rn   s    r6   ro   kstwobign_gen._shape_infoI      	r8   c                 0    [         R                  " U5      * $ rO   )rs   _kolmogprE   rv   s     r6   rw   kstwobign_gen._pdfL  s    Qr8   c                 .    [         R                  " U5      $ rO   )rs   _kolmogcr   s     r6   r{   kstwobign_gen._cdfO  s    ||Ar8   c                 .    [         R                  " U5      $ rO   )r~   
kolmogorovr   s     r6   r   kstwobign_gen._sfR  s    }}Qr8   c                 .    [         R                  " U5      $ rO   )rs   	_kolmogcirE   r   s     r6   r   kstwobign_gen._ppfU  s    }}Qr8   c                 .    [         R                  " U5      $ rO   )r~   kolmogir   s     r6   r   kstwobign_gen._isfX  s    zz!}r8   r   N)r   r   r   r   r   ro   rw   r{   r   r   r   r   r   r8   r6   r   r   $  s&    #H   r8   r   	kstwobign)r   r   rW   c                 J    [         R                  " U S-  * S-  5      [        -  $ NrW          @)rQ   exp_norm_pdf_Crv   s    r6   	_norm_pdfr   h  s     661a4%){**r8   c                 "    U S-  * S-  [         -
  $ r   )_norm_pdf_logCr   s    r6   _norm_logpdfr   l  s    qD53;''r8   c                 .    [         R                  " U 5      $ rO   )r~   ndtrr   s    r6   	_norm_cdfr   p  s    771:r8   c                 .    [         R                  " U 5      $ rO   )r~   log_ndtrr   s    r6   _norm_logcdfr   t  s    ;;q>r8   c                 .    [         R                  " U 5      $ rO   )r~   ndtrir   s    r6   	_norm_ppfr   x  s    88A;r8   c                     [        U * 5      $ rO   r   r   s    r6   _norm_sfr   |  s    aR=r8   c                     [        U * 5      $ rO   r   r   s    r6   _norm_logsfr     s    r8   c                     [        U 5      * $ rO   r   r   s    r6   	_norm_isfr     s    aL=r8   c                       \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rS rS r\\" \SS9S 5       5       rS rSrg)norm_geni  a]  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                     / $ rO   r   rn   s    r6   ro   norm_gen._shape_info  r   r8   Nc                 $    UR                  U5      $ rO   )standard_normalrE   sizerandom_states      r6   _rvsnorm_gen._rvs  s    ++D11r8   c                     [        U5      $ rO   r   r   s     r6   rw   norm_gen._pdf  s    |r8   c                     [        U5      $ rO   r   r   s     r6   _logpdfnorm_gen._logpdf      Ar8   c                     [        U5      $ rO   r   r   s     r6   r{   norm_gen._cdf      |r8   c                     [        U5      $ rO   r   r   s     r6   _logcdfnorm_gen._logcdf  r   r8   c                     [        U5      $ rO   r   r   s     r6   r   norm_gen._sf  s    {r8   c                     [        U5      $ rO   )r   r   s     r6   _logsfnorm_gen._logsf  s    1~r8   c                     [        U5      $ rO   r   r   s     r6   r   norm_gen._ppf  r  r8   c                     [        U5      $ rO   r   r   s     r6   r   norm_gen._isf  r  r8   c                     g)N)r   r   r   r   r   rn   s    r6   r   norm_gen._stats      !r8   c                 \    S[         R                  " S[         R                  -  5      S-   -  $ Nr   rW   r   rQ   logpirn   s    r6   _entropynorm_gen._entropy  s"    BFF1RUU7OA%&&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                    UR                  SS 5      nUR                  SS 5      n[        U5        Ub  Ub  [        S5      e[        R                  " U5      n[        R
                  " U5      R                  5       (       d  [        S5      eUc  UR                  5       nOUnUc,  [        R                  " X-
  S-  R                  5       5      nXV4$ UnXV4$ )Nflocfscale3All parameters fixed. There is nothing to optimize.$The data contains non-finite values.rW   )	r3   r7   
ValueErrorrQ   asarrayisfiniteallmeansqrt)rE   rF   r5   r  r  r.   r/   s          r6   rC   norm_gen.fit  s     xx%(D)$T* 2  ) * * zz${{4 $$&&CDD<))+CC>GGdj1_2245E z Ezr8   c                 h    US:X  a  gUS-  S:X  a"  [         R                  " [        U5      S-
  5      $ g)zv
@returns Moments of standard normal distribution for integer n >= 0

See eq. 16 of https://arxiv.org/abs/1209.4340v2
r   r   rW   r   r   )r~   
factorial2intrd   s     r6   _munpnorm_gen._munp  s3     6q5A:==Q!,,r8   r   NN)r   r   r   r   r   ro   r   rw   r   r{   r  r   r	  r   r   r   r  rL   r
   r   rC   r+  r   r   r8   r6   r   r     sr    ,2"'  6? @@ <r8   r   norm)r   c                   T    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	rg
)	alpha_geni  a  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                 @    [        SSS[        R                  4S5      /$ Nr   Fr   FFrl   rn   s    r6   ro   alpha_gen._shape_info      3266{NCDDr8   c                 N    SUS-  -  [        U5      -  [        USU-  -
  5      -  $ Nr   rW   )r   r   rE   rv   r   s      r6   rw   alpha_gen._pdf   s+    AqDz)A,&y3q5'999r8   c                     S[         R                  " U5      -  [        USU-  -
  5      -   [         R                  " [        U5      5      -
  $ )Nr   )rQ   r  r   r   r8  s      r6   r   alpha_gen._logpdf$  s8    "&&)|l1SU733bffYq\6JJJr8   c                 <    [        USU-  -
  5      [        U5      -  $ Nr   r   r8  s      r6   r{   alpha_gen._cdf'  s    3q5!IaL00r8   c           
      d    S[         R                  " U[        U[        U5      -  5      -
  5      -  $ r>  )rQ   r"  r   r   rE   r   r   s      r6   r   alpha_gen._ppf*  s(    2::a)AilN";;<<<r8   c                 T    [         R                  /S-  [         R                  /S-  -   $ NrW   rQ   rm   nanrE   r   s     r6   r   alpha_gen._stats-  s!    xzRVVHQJ&&r8   r   N)r   r   r   r   r   r   _open_support_mask_support_maskro   rw   r   r{   r   r   r   r   r8   r6   r0  r0    s4    > "44ME:K1='r8   r0  alphac                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)
anglit_geni4  zAn 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                     / $ rO   r   rn   s    r6   ro   anglit_gen._shape_infoH  r   r8   c                 4    [         R                  " SU-  5      $ rD  )rQ   cosr   s     r6   rw   anglit_gen._pdfK  s    vvac{r8   c                 \    [         R                  " U[         R                  S-  -   5      S-  $ N   r   rQ   sinr  r   s     r6   r{   anglit_gen._cdfO  s"    vvaai #%%r8   c                 \    [         R                  " U[         R                  S-  -   5      S-  $ rT  )rQ   rQ  r  r   s     r6   r   anglit_gen._sfR  s"    vva"%%!)m$++r8   c                 ~    [         R                  " [         R                  " U5      5      [         R                  S-  -
  $ NrU  )rQ   arcsinr&  r  r   s     r6   r   anglit_gen._ppfU  s&    yy$RUU1W,,r8   c                     S[         R                  [         R                  -  S-  S-
  SS[         R                  S-  S-
  -  [         R                  [         R                  -  S-
  S-  -  4$ )	Nr      r   r;  rU  `      rW   rQ   r  rn   s    r6   r   anglit_gen._statsX  sR    BEE"%%KN3&RB-?ruuQQR@R-RRRr8   c                 4    S[         R                  " S5      -
  $ Nr   rW   rQ   r  rn   s    r6   r  anglit_gen._entropy[      {r8   r   N)r   r   r   r   r   ro   rw   r{   r   r   r   r  r   r   r8   r6   rM  rM  4  s+    &&,-Sr8   rM  rU  anglitc                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)arcsine_genib  zAn 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                     / $ rO   r   rn   s    r6   ro   arcsine_gen._shape_infov  r   r8   c                     [         R                  " SS9   S[         R                  -  [         R                  " USU-
  -  5      -  sS S S 5        $ ! , (       d  f       g = f)Nignoredivider   r   )rQ   errstater  r&  r   s     r6   rw   arcsine_gen._pdfy  s;    [[)ruu9RWWQ!W-- *))s   0A
Ac                 ~    S[         R                  -  [         R                  " [         R                  " U5      5      -  $ Nr   )rQ   r  r]  r&  r   s     r6   r{   arcsine_gen._cdf~  s&    255y2771:...r8   c                 \    [         R                  " [         R                  S-  U-  5      S-  $ rv  rV  r   s     r6   r   arcsine_gen._ppf  s"    vvbeeCik"C''r8   c                     SnSnSnSnXX44$ )Nr   g      ?r         r   rE   mumu2g1g2s        r6   r   arcsine_gen._stats  s     r8   c                     g)Ngοr   rn   s    r6   r  arcsine_gen._entropy  s    &r8   r   Nr   r   r   r   r   ro   rw   r{   r   r   r  r   r   r8   r6   rl  rl  b  s%    &.
/('r8   rl  arcsinec                       \ rS rSrSrS rSrg)FitDataErrori  z=Raised when input data is inconsistent with fixed parameters.c                 .    SU< SU< SU< S34U l         g )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__FitDataError.__init__  s/    $iui @""'*@B
	r8   r  Nr   r   r   r   r   r  r   r   r8   r6   r  r    s
    G
r8   r  c                       \ rS rSrSrS rSrg)rY   i  zF
Raised when a solver fails to converge while fitting a distribution.
c                 @    SnX!R                  SS5      -  nU4U l        g )Nz1Solver for the MLE equations failed to converge: 
 )replacerG   )rE   mesgemsgs      r6   r  FitSolverError.__init__  s#    BT2&&G	r8   r  Nr  r   r8   r6   rY   rY     s    
r8   rY   c                 t    [         R                  " X-   5      nX2U* [         R                  " U 5      -   -  -
  nU$ rO   r~   psi)r   r   re   s1psiabfuncs         r6   _beta_mle_ar    s4     FF15MEeVbffQi'((DKr8   c                     U u  pE[         R                  " XE-   5      nX!U* [         R                  " U5      -   -  -
  X1U* [         R                  " U5      -   -  -
  /nU$ rO   r  )thetare   r  s2r   r   r  r  s           r6   _beta_mle_abr    sZ     DAFF15MEufrvvay())ufrvvay())+DKr8   c                      ^  \ rS rSrSrS rSS jrS rS rS r	S r
S	 rS
 rS rU 4S jr\\" \SS9U 4S j5       5       rS rSrU =r$ )beta_geni  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ Nr   Fr   r3  r   rl   rE   iaibs      r6   ro   beta_gen._shape_info  9    UQK@UQK@xr8   c                 &    UR                  XU5      $ rO   beta)rE   r   r   r   r   s        r6   r   beta_gen._rvs  s      t,,r8   c                     [         R                  " SS9   [        R                  " XU5      sS S S 5        $ ! , (       d  f       g = fNrp  over)rQ   rs  rs   	_beta_pdfrE   rv   r   r   s       r6   rw   beta_gen._pdf  s*     [[h'==q) (''	   6
Ac                     [         R                  " US-
  U* 5      [         R                  " US-
  U5      -   nU[         R                  " X#5      -  nU$ r>  )r~   xlog1pyxlogybetaln)rE   rv   r   r   lPxs        r6   r   beta_gen._logpdf  sC    jjS1"%S!(<<ryy
r8   c                 0    [         R                  " X#U5      $ rO   )r~   betaincr  s       r6   r{   beta_gen._cdf  s    zz!""r8   c                 0    [         R                  " X#U5      $ rO   )r~   betainccr  s       r6   r   beta_gen._sf  s    {{1##r8   c                 0    [         R                  " X#U5      $ rO   )r~   betainccinvr  s       r6   r   beta_gen._isf  s    ~~aA&&r8   c                 0    [         R                  " XU5      $ rO   )rs   	_beta_ppfrE   r   r   r   s       r6   r   beta_gen._ppf  s    }}Q1%%r8   c                    X-   nX-  nX-  US-  US-   -  -  nSX!-
  -  [         R                  " US-   5      -  US-   [         R                  " X-  5      -  -  nSX-
  S-  US-   -  X-  US-   -  -
  -  nX-  US-   -  US-   -  nXx-  n	UUUU	4$ )NrW   r         rQ   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   beta_gen._stats  s    5Z
!x!| <=;A)>>$qLBGGAEN:<"#zX\'B'(u1'=(> #?"#%8a<"8HqL"I 7 Q!	# 	#r8   c                    >^^ [        U[        5      (       a  UR                  5       n[        U5      m[	        U5      mUU4S jn[
        R                  " US5      u  p4[        TU ]!  XU4S9$ )Nc                 >  > U u  pSX!-
  -  [         R                  " X-   S-   5      -  X-   S-   -  [         R                  " X-  5      -  nUS-  US-  SU-  S-
  -  -
  US-  US-   -  -   SU-  U-  US-   -  -
  nXAU-  X-   S-   -  X-   S-   -  -  nUS-  nUT-
  UT-
  /$ )NrW   r   r  r  r  )rv   r   r   skkur  r  s        r6   r   beta_gen._fitstart.<locals>.func  s    DAAC++quqy9BGGACLHBA1ac!e$q!tQqSz1AaCE1Q3K?BA#qs1u+qs1u%%B!GBrE2b5>!r8   )r   r   r  )	r?   r*   	_uncensorr   r   r   fsolverA   	_fitstart)rE   rF   r  r   r   r  r  	__class__s        @@r6   r  beta_gen._fitstart  s^    dL))>>#D4[t_	" tZ0w F 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           	         > UR                  SS 5      nUR                  SS 5      nUb  Uc  [        TU ]  " U/UQ70 UD6$ UR                  SS 5        UR                  SS 5        [	        U/ SQ5      n[	        U/ SQ5      n[        U5        Ub  Ub  [        S5      e[        R                  " U5      R                  5       (       d  [        S5      e[        R                  " U5      U-
  U-  n[        R                  " US:*  5      (       d  [        R                  " US:  5      (       a  [        S	XDU-   S
9eUR                  5       nUc  Ub  Ub  Un	SU-
  nSU-
  nOUn	X-  SU-
  -  n
[        R                  " [         U
U	[#        U5      [        R$                  " U5      R'                  5       4SS9u  ppUS:w  a	  [)        US9eUS   n
Ub  XpO[        R$                  " U5      R'                  5       n[*        R,                  " U* 5      R'                  5       nUSU-
  -  UR/                  SS9-  S-
  nUU-  n
SU-
  U-  n	[        R                  " [0        X/[#        U5      UU4SS9u  ppUS:w  a	  [)        US9eUu  pXXE4$ )Nr  r  f0fafix_a)f1fbfix_br  r   r   r   r  r>   r  T)rG   full_output)r  )ddof)r=   rA   rC   r3   r   r7   r!  rQ   r#  r$  ravelanyr  r%  r   r  r  lenr  sumrY   r~   log1pvarr  )rE   rF   rG   r5   r  r  r  r  xbarr   r   r  infoierr  r  r  facr  s                     r6   rC   beta_gen.fit#  s    xx%(D)<6>7;t3d3d33 	4 !$(=>!$(=>$T*>bn ) * * {{4 $$&&CDD %/66$!)tqy 1 1vTGGyy{>R^ ~ 4x4x AH%A &.__QTBFF4L$4$4$67 &"E
 ax$$//aA~ 1 !!#B4%$$&B !d(#dhhAh&66:Cs
ATS A &.__qf$iR( &"E
 ax$$//DAT!!r8   c                     S nS nS nS nUS:  a  US:  a  U" X5      $ US::  a  X!-
  S:  a  X&" U5      :  a  U" X5      $ US::  a  X-
  S:  a  X" U5      :  a  U" X!5      $ U" X5      $ )Nc                     [         R                  " X5      U S-
  [         R                  " U 5      -  -
  US-
  [         R                  " U5      -  -
  X-   S-
  [         R                  " X-   5      -  -   $ rf  )r~   r  r  r   r   s     r6   regular"beta_gen._entropy.<locals>.regular  s`    IIaOq1uq	&99UbffQi'(+,519qu*EF Gr8   c                    X-   nS[         R                  " S[         R                  -  5      [         R                  " U 5      -   [         R                  " U5      -   S[         R                  " U5      -  -
  S-   -  nSU-  SUS-  -  -   US-  -   SUS	-  -  -
  nS
U -  SU S-  -  -
  U S-  -
  U S	-  -   nS
U-  SUS-  -  -
  US-  -
  US	-  -   nX4U-   U-   S-  -   $ )Nr   rW   r  r   n                         i
   x   r  )r   r   sum_ablog_termt1t2t3s          r6   asymptotic_ab_large.beta_gen._entropy.<locals>.asymptotic_ab_large  s    UFqw"&&)+bffQi7!BFF6N:JJQNH Vbo-<q~MBQAtG#ag-47BQAtG#ag-47BBw|s222r8   c                 
   X-   n[         R                  " U 5      U S-
  [         R                  " U 5      -  -
  nSSU-  -  SSU-  -  -   US-  S-  -
  US-  S-  -
  US-  S-  -   US	-  S
-  -   US-  S
-  -
  SU-  -   SSU-  -  -
  US-  S-  -   US-  S-  -   US-  S-  -
  US	-  S
-  -
  US-  S-  -   nU[        R                  " X-  5      -  [        R
                  " U5      -   S[        R
                  " U5      -  -
  nX4-   U-   $ )Nr   rW      r  r  r  r                  r  <   ~   )r~   gammalnr  rQ   r  r  )r   r   r  r  r  r  s         r6   asymptotic_b_large-beta_gen._entropy.<locals>.asymptotic_b_large  sG   UFA!a%266!9!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  bhhqsm+bffQi7!BFF6N:JJH7X%%r8   c                     U S:X  a  g[         R                  " U 5      n[        U5      n[        U SU-  -  5      S-   nUSSU-   -  -  $ )Nr   i  r  rW      )rQ   log10r*  )vjdigitsds       r6   threshold_large*beta_gen._entropy.<locals>.threshold_large  sL    CxAVFAf$%)AR!a%[= r8   g    RAg    (RAg    .Ar   )rE   r   r   r  r  r  r  s          r6   r  beta_gen._entropy  s    	G	3
	&	! ;1;&q,,%ZAESLQ/!2D-D%a++%ZAESLQ/!2D-D%a++1= r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r  rL   r	   r   rC   r  r   __classcell__r  s   @r6   r  r    so    >
-*
#$'&# 4" } 5+ ,
c", c"J+! +!r8   r  r  c                   d    \ rS rSrSr\R                  rS rSS jr	S r
S rS rS	 rS
 rS rSrg)betaprime_geni  a'  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ r  rl   r  s      r6   ro   betaprime_gen._shape_info  r  r8   Nc                 Z    [         R                  XUS9n[         R                  X#US9nXV-  $ Nr   r   )gammarvs)rE   r   r   r   r   u1u2s          r6   r   betaprime_gen._rvs  s-    YYq,Y?YYq,Y?wr8   c                 N    [         R                  " U R                  XU5      5      $ rO   rQ   r   r   r  s       r6   rw   betaprime_gen._pdf      vvdll1+,,r8   c                     [         R                  " US-
  U5      [         R                  " X#-   U5      -
  [         R                  " X#5      -
  $ r>  )r~   r  r  r  r  s       r6   r   betaprime_gen._logpdf  s6    xxC#bjj&::RYYq_LLr8   c                 (    [        US:  XU/S S S9$ )Nr   c                 :    [         R                  SSU -   -  X!5      $ ra   r  r   x_a_b_s      r6   <lambda>$betaprime_gen._cdf.<locals>.<lambda>  s    txx1R4"9r8   c                 :    [         R                  U SU -   -  X5      $ ra   r  r{   r6  s      r6   r:  r;    s    $))B"Ir">r8   f2r   r  s       r6   r{   betaprime_gen._cdf  s&     EA!99>@ 	@r8   c                 (    [        US:  XU/S S S9$ )Nr   c                 :    [         R                  SSU -   -  X!5      $ ra   r=  r6  s      r6   r:  #betaprime_gen._sf.<locals>.<lambda>  s    tyyAbD2:r8   c                 :    [         R                  U SU -   -  X5      $ ra   r5  r6  s      r6   r:  rD    s    $((2qt9b"=r8   r>  r@  r  s       r6   r   betaprime_gen._sf  s"    EA!9:=
 	
r8   c                    [         R                  " XU5      u  pn[        R                  R	                  XU5      n[         R
                  " SS9   USU-
  -  nS S S 5        US:  n[         R                  " U5      (       a/  U(       a&  S[        R                  R                  XU5      -  S-
  nW$ S[        R                  R                  X   X6   X&   5      -  S-
  WU'   U$ ! , (       d  f       N= f)Nrp  rq  r   gH.?)rQ   broadcast_arraysstatsr  r   rs  isscalarr   )rE   pr   r   routrnear1s          r6   r   betaprime_gen._ppf  s    %%aA.a JJOOA!$[[)q1u+C *V;;q>>

a0014 
 EJJOOAIqy!)LLqPCK
 *)s   	C!!
C/c                 H   ^ [        UT:  X#4U4S j[        R                  S9$ )Nc                    > [         R                  " [        S[        T5      S-   5       Vs/ s H  o U-   S-
  X-
  -  PM     snSS9$ s  snf )Nr   r   axis)rQ   prodranger*  )r   r   ire   s      r6   r:  %betaprime_gen._munp.<locals>.<lambda>+  s@    q#a&(9K!L9KAQ3q513-9K!LSTU!Ls   A	fillvaluer   rQ   rm   )rE   re   r   r   s    `  r6   r+  betaprime_gen._munp(  s%    EA6Uff 	r8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r   r{   r   r   r+  r   r   r8   r6   r"  r"    s?    .^ "44M

-M@
$r8   r"  	betaprimec                   @    \ rS rSrSrS rS rS rS rSS jr	S r
S	rg
)bradford_geni2  a6  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                 @    [        SSS[        R                  4S5      /$ NcFr   r3  rl   rn   s    r6   ro   bradford_gen._shape_infoH  r5  r8   c                 D    X"U-  S-   -  [         R                  " U5      -  $ r>  r~   r  rE   rv   ra  s      r6   rw   bradford_gen._pdfK  s    aC#I!,,r8   c                 `    [         R                  " X!-  5      [         R                  " U5      -  $ rO   rd  re  s      r6   r{   bradford_gen._cdfO  s    xx}rxx{**r8   c                 b    [         R                  " U[         R                  " U5      -  5      U-  $ rO   r~   expm1r  rE   r   ra  s      r6   r   bradford_gen._ppfR  s"    xxBHHQK(1,,r8   c                 j   [         R                  " SU-   5      nX-
  X-  -  nUS-   U-  SU-  -
  SU-  U-  U-  -  nS nS nSU;   a{  [         R                  " S5      SU-  U-  SU-  U-  US-   -  -
  SU-  U-  XS-   -  S-   -  -   -  nU[         R                  " XUS-
  -  SU-  -   -  5      SU-  US-
  -  SU-  -   -  -  nS	U;   ai  US-  US-
  -  USU-  S
-
  -  S-   -  SU-  U-  U-  US-
  -  US-
  -  -   SU-  U-  U-  SU-  S-
  -  -   SUS-  -  -   nUSU-  XS-
  -  SU-  -   S-  -  -  nXEXg4$ )Nr   r   rW   sr  	   r  r  kr`     rU     )rQ   r  r&  )rE   ra  momentsrq  r}  r~  r  r  s           r6   r   bradford_gen._statsU  s   FF3q5McAC[#qyQ1Qq)'>RT!VAaCE1Q3K/!AqA#wqy0AABB"''!!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#qA#wqs{Q&&&Br8   c                 p    [         R                  " SU-   5      nUS-  [         R                  " X-  5      -
  $ Nr   r   rg  )rE   ra  rq  s      r6   r  bradford_gen._entropyd  s,    FF1Q3Kurvvac{""r8   r   Nmvr  r   r8   r6   r^  r^  2  s&    *E-+-#r8   r^  bradfordc                   Z    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)burr_genil  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ Nra  Fr   r3  r  rl   rE   icids      r6   ro   burr_gen._shape_info  r  r8   c                 V    [        US:H  XU/S S S9nUR                  S:X  a  US   $ U$ )Nr   c                 0    X-  XU-  S-
  -  -  SX-  -   -  $ ra   r   r7  c_d_s      r6   r:  burr_gen._pdf.<locals>.<lambda>  s     rw""uQw-8AJGr8   c                 :    X-  X* S-
  -  -  SX* -  -   US-   -  -  $ Nr   r   r   r  s      r6   r:  r    s.    27bS3Y.?#@%&_"s($C$Er8   r>  r   r   ndimrE   rv   ra  r  outputs        r6   rw   burr_gen._pdf  s@    FQ1IGFG
 ;;!":r8   c                 V    [        US:H  XU/S S S9nUR                  S:X  a  US   $ U$ )Nr   c                     [         R                  " U5      [         R                  " U5      -   [        R                  " X-  S-
  U 5      -   US-   [        R                  " X-  5      -  -
  $ ra   )rQ   r  r~   r  r  r  s      r6   r:  "burr_gen._logpdf.<locals>.<lambda>  sK    r
RVVBZ 7"((2519b:Q Q#%a4288BH+="=!>r8   c                     [         R                  " U5      [         R                  " U5      -   [        R                  " U* S-
  U 5      -   [        R                  " US-   X* -  5      -
  $ ra   rQ   r  r~   r  r  r  s      r6   r:  r    sN    266":r
#:%'XXrcAgr%:$;%'ZZ1b3i%@$Ar8   r>  r   r  r  s        r6   r   burr_gen._logpdf  sB    FQ1I?B	C ;;!":r8   c                     SX* -  -   U* -  $ ra   r   rE   rv   ra  r  s       r6   r{   burr_gen._cdf  s    AGr""r8   c                 <    [         R                  " X* -  5      U* -  $ rO   rd  r  s       r6   r  burr_gen._logcdf  s    xxB QB''r8   c                 N    [         R                  " U R                  XU5      5      $ rO   rQ   r   r	  r  s       r6   r   burr_gen._sf      vvdkk!*++r8   c                 D    [         R                  " SX* -  -   U* -  * 5      $ ra   rQ   r  r  s       r6   r	  burr_gen._logsf  s#    xx1q2w;1"--..r8   c                 $    USU-  -  S-
  SU-  -  $ N      r   r   rE   r   ra  r  s       r6   r   burr_gen._ppf  s    DFa46**r8   c                 p    [         R                  " SU-  U* 5      n[         R                  " U5      SU-  -  $ Nr  r~   r  rk  )rE   r   ra  r  _qs        r6   r   burr_gen._isf  s/    ZZq1"%xx|q))r8   c           	         [         R                  " SS5      R                  SS5      U-  n[        R                  " X#-   SU-
  5      U-  u  pEpg[         R
                  " US:  U[         R                  5      nXXS-  -
  n	[         R
                  " US:  U	[         R                  5      n
[        US:  XXVU	4S [         R                  S	9n[        US
:  XXVXy4S [         R                  S	9n[         R                  " U5      S:X  a>  UR                  5       U
R                  5       UR                  5       UR                  5       4$ XX4$ )Nr      rU  r   rW   r         @c                 ^    USU-  U-  -
  SUS-  -  -   [         R                  " US-  5      -  $ )Nr  rW   r  )ra  e1e2e3mu2_if_cs        r6   r:  !burr_gen._stats.<locals>.<lambda>  s3    b1R47lQr1uW.D/1ww1}/E.Fr8   rX        @c                 T    USU-  U-  -
  SU-  US-  -  -   SUS-  -  -
  US-  -  S-
  $ )NrU  r  rW   r  r   )ra  r  r  r  e4r  s         r6   r:  r    s=    qtBw,2b!e+aAg51DIr8   r   )
rQ   arangereshaper~   r  whererF  r   r  item)rE   ra  r  ncr  r  r  r  r}  r  r~  r  r  s                r6   r   burr_gen._stats  s   YYq!_$$Qq)A-b1A5XXa#gr266*A:hhq3w"&&1GBH%Gff GBB)Kff 771:?779chhj"'')RWWY>>r8   c                    ^ S m[         R                  " U5      [         R                  " U5      [         R                  " U5      p2n[        X!:  X:H  -  X3:H  -  X#U4U4S j[         R                  5      $ )Nc                 P    SU -  U-  nU[         R                  " SU-
  X#-   5      -  $ r>  r~   r  re   ra  r  r  s       r6   __munpburr_gen._munp.<locals>.__munp  +    a!BrwwsRx000r8   c                    > T" X U5      $ rO   r   )ra  r  re   _burr_gen__munps      r6   r:   burr_gen._munp.<locals>.<lambda>  s    &q/r8   )rQ   r"  r   rF  )rE   re   ra  r  r  s       @r6   r+  burr_gen._munp  s\    	1 **Q-A

1a15QV,7!9&&" 	"r8   r   N)r   r   r   r   r   ro   rw   r   r{   r  r   r	  r   r   r   r+  r   r   r8   r6   r}  r}  l  s?    +`
	
#(,/+*."r8   r}  burrc                   T    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)
burr12_geni  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ r  rl   r  s      r6   ro   burr12_gen._shape_info  r  r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  r  s       r6   rw   burr12_gen._pdf"  r0  r8   c                     [         R                  " U5      [         R                  " U5      -   [        R                  " US-
  U5      -   [        R                  " U* S-
  X-  5      -   $ ra   r  r  s       r6   r   burr12_gen._logpdf&  sI    vvay266!9$rxxAq'99BJJr!tQT<RRRr8   c                 P    [         R                  " U R                  XU5      5      * $ rO   r~   rk  r	  r  s       r6   r{   burr12_gen._cdf)      Q1-...r8   c                 B    [         R                  " SX-  -   U* -  * 5      $ ra   rd  r  s       r6   r  burr12_gen._logcdf,  s!    xx!ad(qb))**r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r  r  s       r6   r   burr12_gen._sf/  r  r8   c                 6    [         R                  " U* X-  5      $ rO   r~   r  r  s       r6   r	  burr12_gen._logsf2  s    zz1"ad##r8   c                 p    [         R                  " SU-  [         R                  " U* 5      -  5      SU-  -  $ Nr  r   rj  r  s       r6   r   burr12_gen._ppf5  s/     xx1rxx|+,qs33r8   c                 n    [         R                  " SU-  [        R                  " U5      -  5      SU-  -  $ r  )r~   rk  rQ   r  )rE   rK  ra  r  s       r6   r   burr12_gen._isf;  s+    xx1rvvay()AaC00r8   c                 J    S n[        X#-  U:  XU4U[        R                  S9$ )Nc                 P    SU -  U-  nU[         R                  " SU-   X#-
  5      -  $ r>  r  r  s       r6   moment_if_exists*burr12_gen._munp.<locals>.moment_if_exists?  r  r8   rX  r   rQ   rF  )rE   re   ra  r  r  s        r6   r+  burr12_gen._munp>  s.    	1 !%!)aAY0@$&FF, 	,r8   r   N)r   r   r   r   r   ro   rw   r   r{   r  r   r	  r   r   r+  r   r   r8   r6   r  r    s;    +X
-S/+,$41,r8   r  burr12c                   `    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rSrg)fisk_geniJ  aV  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   fisk_gen._shape_infou  r5  r8   c                 .    [         R                  XS5      $ r>  )r  rw   re  s      r6   rw   fisk_gen._pdfx  s    yys##r8   c                 .    [         R                  XS5      $ r>  )r  r{   re  s      r6   r{   fisk_gen._cdf|      yys##r8   c                 .    [         R                  XS5      $ r>  )r  r   re  s      r6   r   fisk_gen._sf  s    xxc""r8   c                 .    [         R                  XS5      $ r>  )r  r   re  s      r6   r   fisk_gen._logpdf  s    ||A#&&r8   c                 .    [         R                  XS5      $ r>  )r  r  re  s      r6   r  fisk_gen._logcdf  s    ||A#&&r8   c                 .    [         R                  XS5      $ r>  )r  r	  re  s      r6   r	  fisk_gen._logsf  s    {{1%%r8   c                 .    [         R                  XS5      $ r>  )r  r   re  s      r6   r   fisk_gen._ppf  r  r8   c                 .    [         R                  XS5      $ r>  )r  r   rl  s      r6   r   fisk_gen._isf  r  r8   c                 .    [         R                  XS5      $ r>  )r  r+  rE   re   ra  s      r6   r+  fisk_gen._munp  s    zz!$$r8   c                 .    [         R                  US5      $ r>  )r  r   rE   ra  s     r6   r   fisk_gen._stats  s    {{1c""r8   c                 4    S[         R                  " U5      -
  $ rD  rg  r  s     r6   r  fisk_gen._entropy      266!9}r8   r   N)r   r   r   r   r   ro   rw   r{   r   r   r  r	  r   r   r+  r   r  r   r   r8   r6   r  r  J  sE    )TE$$#''&$$%#r8   r  fiskc                   X    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSS jrSrg)
cauchy_geni  a  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                     / $ rO   r   rn   s    r6   ro   cauchy_gen._shape_info  r   r8   c                     [         R                  " SS9   S[         R                  -  SX-  -   -  sS S S 5        $ ! , (       d  f       g = f)Nrp  r  r   )rQ   rs  r  r   s     r6   rw   cauchy_gen._pdf  s0    [[h'ruu9c!#g& (''s	   :
Ac                 V    [         R                  " U5      n[        US:  U4S S S9nU$ )Nr   c                 D    [         * [        R                  " U S-  5      -
  $ rD  )r(   rQ   r  absxs    r6   r:  $cauchy_gen._logpdf.<locals>.<lambda>  s    wh$'1B&Br8   c                 ~    [         * S[        R                  " U 5      -  [        R                  " SU -  S-  5      -   -
  $ NrW   r   )r(   rQ   r  r  r  s    r6   r:  r    s1    )*266$<"((AdFQ;:O)O)Qr8   fr?  )rQ   absr   )rE   rv   r  ys       r6   r   cauchy_gen._logpdf  s8     vvay tax$BRS r8   c                 T    [         R                  " SU* 5      [         R                  -  $ ra   rQ   arctan2r  r   s     r6   r{   cauchy_gen._cdf  s    zz!aR &&r8   c                 2    [         R                  " USS5      $ Nr   r   )rs   _cauchy_ppfr   s     r6   r   cauchy_gen._ppf      q!Q''r8   c                 R    [         R                  " SU5      [         R                  -  $ ra   r  r   s     r6   r   cauchy_gen._sf  s    zz!Q%%r8   c                 2    [         R                  " USS5      $ r   )rs   _cauchy_isfr   s     r6   r   cauchy_gen._isf  r#  r8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   rQ   rF  rn   s    r6   r   cauchy_gen._stats  !    vvrvvrvvrvv--r8   c                 P    [         R                  " S[         R                  -  5      $ r\  r  rn   s    r6   r  cauchy_gen._entropy      vvagr8   Nc                     [        U[        5      (       a  UR                  5       n[        R                  " U/ SQ5      u  p4nXEU-
  S-  4$ N   2   K   rW   r?   r*   r  rQ   
percentilerE   rF   rG   p25p50p75s         r6   r  cauchy_gen._fitstart  @    dL))>>#DdL9#3YM!!r8   r   rO   )r   r   r   r   r   ro   rw   r   r{   r   r   r   r   r  r  r   r   r8   r6   r
  r
    s9    4'
 '(&(."r8   r
  cauchyc                   X    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)chi_geni  a  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                 @    [        SSS[        R                  4S5      /$ NdfFr   r3  rl   rn   s    r6   ro   chi_gen._shape_info      4BFF^DEEr8   Nc                 R    [         R                  " [        R                  XUS95      $ r&  )rQ   r&  chi2r)  rE   rC  r   r   s       r6   r   chi_gen._rvs  s    wwtxxLxIJJr8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   rC  s      r6   rw   chi_gen._pdf  s     vvdll1)**r8   c                     [         R                  " S5      S[         R                  " S5      -  U-  -
  [        R                  " SU-  5      -
  nU[        R                  " US-
  U5      -   SUS-  -  -
  $ )NrW   r   r   )rQ   r  r~   r  r  )rE   rv   rC  ls       r6   r   chi_gen._logpdf  s]    FF1I266!9R'"**RU*;;288BGQ''"QT'11r8   c                 B    [         R                  " SU-  SUS-  -  5      $ Nr   rW   r~   gammaincrK  s      r6   r{   chi_gen._cdf  s    {{2b5"QT'**r8   c                 B    [         R                  " SU-  SUS-  -  5      $ rQ  r~   	gammainccrK  s      r6   r   chi_gen._sf!  s    ||BrE2ad7++r8   c                 d    [         R                  " S[        R                  " SU-  U5      -  5      $ NrW   r   rQ   r&  r~   gammaincinvrE   r   rC  s      r6   r   chi_gen._ppf$  s%    wwq2q1122r8   c                 d    [         R                  " S[        R                  " SU-  U5      -  5      $ rZ  rQ   r&  r~   gammainccinvr]  s      r6   r   chi_gen._isf'  s%    wwqB2233r8   c                 ~   [         R                  " S5      [        R                  " SU-  S5      -  nXU-  -
  nSUS-  -  USSU-  -
  -  -   [         R                  " [         R
                  " US5      5      -  nSU-  SU-
  -  SUS-  -  -
  SUS-  -  SU-  S-
  -  -   nU[         R                  " US	-  5      -  nX#XE4$ )
NrW   r   r  r         ?r   r  rU  r   )rQ   r&  r~   pochr"  powerrE   rC  r}  r~  r  r  s         r6   r   chi_gen._stats*  s    WWQZ"''#(C00b5jCi"a"f+%rzz"((32D'EErT3r6]1RU7"Qr1uW"Q%77
bjjc""r8   c                 .    S nS n[        US:  U4UUS9$ )Nc                     [         R                  " SU -  5      SU [        R                  " S5      -
  U S-
  [         R                  " SU -  5      -  -
  -  -   $ r  )r~   r  rQ   r  digammarC  s    r6   regular_formula)chi_gen._entropy.<locals>.regular_formula5  sM    JJrBw'R"&&)^rAvC"H9M.MMNO Pr8   c                     S[         R                  " [         R                  5      S-  -   U S-  S-  -
  U S-  S-  -
  SU S-  -  -
  U S-  S	-  -   $ )
Nr   rW   r  r  r;  gll?   r  rl  s    r6   asymptotic_formula,chi_gen._entropy.<locals>.asymptotic_formula9  sY    "&&-/)RVQJ6"b&!CBFm$')2vrk2 3r8   g     r@r>  r@  )rE   rC  rm  rs  s       r6   r  chi_gen._entropy3  s+    	P	3 "s(RFO/1 	1r8   r   r-  r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r  r   r   r8   r6   r@  r@    s;    <FK+2+,341r8   r@  chic                   X    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)chi2_geniD  a|  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                 @    [        SSS[        R                  4S5      /$ rB  rl   rn   s    r6   ro   chi2_gen._shape_infof  rE  r8   Nc                 $    UR                  X5      $ rO   )	chisquarerH  s       r6   r   chi2_gen._rvsi  s    %%b//r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rK  s      r6   rw   chi2_gen._pdfl  s    vvdll1)**r8   c                     [         R                  " US-  S-
  U5      US-  -
  [         R                  " US-  5      -
  [        R                  " S5      U-  S-  -
  $ )Nr   r   rW   )r~   r  r  rQ   r  rK  s      r6   r   chi2_gen._logpdfp  sM    xx2a#ad*RZZ2->>"&&)B,PRARRRr8   c                 .    [         R                  " X!5      $ rO   )r~   chdtrrK  s      r6   r{   chi2_gen._cdfs      xxr8   c                 .    [         R                  " X!5      $ rO   )r~   chdtrcrK  s      r6   r   chi2_gen._sfv      yyr8   c                 .    [         R                  " X!5      $ rO   )r~   chdtrirE   rK  rC  s      r6   r   chi2_gen._isfy  r  r8   c                 <    S[         R                  " US-  U5      -  $ rD  r~   r\  r  s      r6   r   chi2_gen._ppf|  s    1a(((r8   c                 Z    UnSU-  nS[         R                  " SU-  5      -  nSU-  nX#XE4$ )NrW   r         (@r  rg  s         r6   r   chi2_gen._stats  s9    drwws2v"Wr8   c                 8    SU-  nS nS n[        US:  U4UUS9$ )Nr   c                     U [         R                  " S5      -   [        R                  " U 5      -   SU -
  [        R                  " U 5      -  -   $ r  )rQ   r  r~   r  r  )half_dfs    r6   rm  *chi2_gen._entropy.<locals>.regular_formula  s>    bffQi'"**W*==[BFF7O34 5r8   c                     [         R                  " S5      SS[         R                  " S[         R                  -  5      -   -  -   nSU -  nUSUSUSUS-  -   -  -   -  -   -  S[         R                  " U 5      -  -   U-   $ )NrW   r   r   gUUUUUUUUUUUUտgllg      @r  )r  ra  hs      r6   rs  -chi2_gen._entropy.<locals>.asymptotic_formula  s     q	CRVVAbeeG_!455AGAta51S5=(9!9::;w'(*+, -r8   }   r>  r@  )rE   rC  r  rm  rs  s        r6   r  chi2_gen._entropy  s4    (	5		- 'C-')/1 	1r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r  r   r   r8   r6   ry  ry  D  s<     BF0+S  )1r8   ry  rG  c                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)
cosine_geni  a0  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                     / $ rO   r   rn   s    r6   ro   cosine_gen._shape_info  r   r8   c                 \    S[         R                  -  S[         R                  " U5      -   -  $ Nr   r   rQ   r  rQ  r   s     r6   rw   cosine_gen._pdf  s!    RUU{AbffQiK((r8   c                 n    [         R                  " U5      n[        US:g  U4S [         R                  * S9$ )Nr  c                 ~    [         R                  " U 5      [         R                  " S[         R                  -  5      -
  $ rD  )rQ   r  r  r  ra  s    r6   r:  $cosine_gen._logpdf.<locals>.<lambda>  s!    BHHQK"&&255/$Ar8   rX  )rQ   rQ  r   rm   re  s      r6   r   cosine_gen._logpdf  s2    FF1I!r'A4A%'VVG- 	-r8   c                 .    [         R                  " U5      $ rO   rs   _cosine_cdfr   s     r6   r{   cosine_gen._cdf  s    q!!r8   c                 0    [         R                  " U* 5      $ rO   r  r   s     r6   r   cosine_gen._sf  s    r""r8   c                 .    [         R                  " U5      $ rO   rs   _cosine_invcdfrE   rK  s     r6   r   cosine_gen._ppf  s    !!!$$r8   c                 0    [         R                  " U5      * $ rO   r  r  s     r6   r   cosine_gen._isf  s    ""1%%%r8   c                     [         R                  [         R                  -  S-  S-
  nS[         R                  S-  S-
  -  S[         R                  [         R                  -  S-
  S-  -  -  nS	US	U4$ )
Nr  r   r  rU  Z         @r  rW   r   rc  )rE   r  rq  s      r6   r   cosine_gen._stats  sa    UURUU]S C'BEE1HrM"cRUURUU]Q->,B&BCAsA~r8   c                 V    [         R                  " S[         R                  -  5      S-
  $ )NrU  r   r  rn   s    r6   r  cosine_gen._entropy  s    vvags""r8   r   Nr   r   r   r   r   ro   rw   r   r{   r   r   r   r   r  r   r   r8   r6   r  r    s4    ()-"#%&
#r8   r  cosinec                   X    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)
dgamma_geni  a  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                 @    [        SSS[        R                  4S5      /$ r2  rl   rn   s    r6   ro   dgamma_gen._shape_info  r5  r8   Nc                     UR                  US9n[        R                  XUS9nU[        R                  " US:  SS5      -  $ Nr   r'  r   r   r  )uniformr(  r)  rQ   r  )rE   r   r   r   ugms         r6   r   dgamma_gen._rvs  sC      d +YYq,Y?BHHQ#Xq"---r8   c                     [        U5      nSS[        R                  " U5      -  -  X2S-
  -  -  [        R                  " U* 5      -  $ r7  )r  r~   r(  rQ   r   rE   rv   r   axs       r6   rw   dgamma_gen._pdf  s<    VAbhhqkM"2#;.<<r8   c                     [        U5      n[        R                  " US-
  U5      U-
  [        R                  " S5      -
  [        R
                  " U5      -
  $ r7  )r  r~   r  rQ   r  r  r  s       r6   r   dgamma_gen._logpdf  s?    VxxC$r)BFF1I5

1EEr8   c           	          [         R                  " US:  SS[        R                  " X!5      -  -   S[        R                  " X!* 5      -  5      $ Nr   r   )rQ   r  r~   rS  rW  r8  s      r6   r{   dgamma_gen._cdf  sB    xxAc"++a"333BLLB//1 	1r8   c           
          [         R                  " US:  S[        R                  " X!5      -  SS[        R                  " X!* 5      -  -   5      $ r  )rQ   r  r~   rW  rS  r8  s      r6   r   dgamma_gen._sf  sB    xxABLL..c"++a"4446 	6r8   c                 n    [         R                  R                  U5      [        R                  " S5      -
  $ Nr   )rI  r(  r  rQ   r  rG  s     r6   r  dgamma_gen._entropy  s$    {{##A&44r8   c           	          [         R                  " US:  [        R                  " USU-  S-
  5      [        R                  " USU-  5      * 5      $ r  rQ   r  r~   r\  ra  rA  s      r6   r   dgamma_gen._ppf  sD    xxCq!A#'2AaC002 	2r8   c           	          [         R                  " US:  [        R                  " USU-  S-
  5      * [        R                  " USU-  5      5      $ r  r  rA  s      r6   r   dgamma_gen._isf  sD    xxC1Q37331Q3/1 	1r8   c                 :    XS-   -  nSUSUS-   US-   -  U-  S-
  4$ )Nr   r   r   r  r   )rE   r   r~  s      r6   r   dgamma_gen._stats"  s2    3iCququoc1#555r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r  r   r   r   r   r   r8   r6   r  r    s;    >E.
=
F1
6
52
1
6r8   r  dgammac                       \ rS rSrSr\R                  r\R                  r	\R                  r\R                  r\R                  r\R                   rS rS rS rS rSS jrS	 rS
 rS r
S rS rS rS rSrg)dpareto_lognorm_geni*  a  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                 H    U R                  U5      U R                  U5      -  $ rO   )_Phic_phirE   zs     r6   _Rdpareto_lognorm_gen._Rc  s    zz!}tyy|++r8   c                 H    U R                  U5      U R                  U5      -
  $ rO   )_logPhic_logphir  s     r6   _logRdpareto_lognorm_gen._logRf  s    }}Q$,,q/11r8   c           	         [        SS[        R                  * [        R                  4S5      [        SSS[        R                  4S5      [        SSS[        R                  4S5      [        SSS[        R                  4S5      /$ )Nr  Fr3  ro  r   r   r   rl   rn   s    r6   ro   dpareto_lognorm_gen._shape_infoi  sm    3'8.I3266{NC3266{NC3266{NCE 	Er8   c                 $    US:  US:  -  US:  -  $ Nr   r   )rE   r  ro  r   r   s        r6   rf   dpareto_lognorm_gen._argchecko  s    A!a% AE**r8   Nc                     UR                  XUS9nUR                  US9nUR                  US9n	[        R                  " XxU-  -   X-  -
  5      $ Nr  )normalstandard_exponentialrQ   r   )
rE   r  ro  r   r   r   r   ZE1E2s
             r6   r   dpareto_lognorm_gen._rvsr  s[     40..D.9..D.9vvaq&j26)**r8   c                 n   [         R                  " SSS9   [         R                  " U5      UpvXg-
  U-  nXC-  U-
  n	XS-  U-   n
[         R                  " [         R                  " U5      [         R                  " U5      -   [         R                  " XE-   5      -
  U-
  5      nXR	                  U5      -  nU[         R
                  " U R                  U	5      U R                  U
5      5      -  nS S S 5        [         R                  * WUS:H  [         R                  " U5      -  '   US   $ ! , (       d  f       NA= f)Nrp  invalidrr  r   r   )	rQ   rs  r  r"  r  	logaddexpr  rm   rX   )rE   rv   r  ro  r   r   log_ymr  x1x2rM  s               r6   r   dpareto_lognorm_gen._logpdf{  s    [[(;vvay!1aABB**RVVAY2RVVAE]BUJKC<<?"C2<<

2

2??C < (*vvgQ!Vrxx{"#2w <;s   CD&&
D4c           	         [         R                  " SSS9   [         R                  " U5      UpvXg-
  U-  nXC-  U-
  n	XS-  U-   n
U R                  U5      nU R	                  U5      n[         R                  " U5      U R                  U	5      -   n[         R                  " U5      U R                  U
5      -   n[         R                  " XXS5      u  ppn[        R                  " X/X* /SSS9u  nnXU-   [         R                  " XE-   5      -
  /n[         R                  " [        R                  " UX* U-  /SS95      nS S S 5        [         R                  * WUS:H  '   US   $ ! , (       d  f       N*= f)	Nrp  r  r   r   T)r   rS  return_sign)r   rS  r   )rQ   rs  r  _logPhir  r  rH  r~   	logsumexpr"  rm   )rE   rv   r  ro  r   r   r  r  r  r  r  r  r  r  t4onet5rR   temprM  s                       r6   r  dpareto_lognorm_gen._logcdf  s5   [[(;vvay!1aABBaBaB&&)djjn,B&&)djjn,B"$"5"5bba"HBBC bX#t1RVWHBR"&&-/0D**R\\$3T	2BKLC <  vvgAF2w# <;s   D&E  
E.c           	      :    [        U R                  XX4U5      5      $ rO   )r   r  rE   rv   r  ro  r   r   s         r6   r	  dpareto_lognorm_gen._logsf  s    aA!455r8   c           	      P    [         R                  " U R                  XX4U5      5      $ rO   r.  r  s         r6   rw   dpareto_lognorm_gen._pdf      vvdll1q122r8   c           	      P    [         R                  " U R                  XX4U5      5      $ rO   rQ   r   r  r  s         r6   r{   dpareto_lognorm_gen._cdf  r  r8   c           	      P    [         R                  " U R                  XX4U5      5      $ rO   r  r  s         r6   r   dpareto_lognorm_gen._sf  s    vvdkk!a011r8   c                     U[        U5      pvXE-  XG-
  XW-   -  -  [        R                  " Xv-  US-  US-  -  S-  -   5      -  n[        R                  " U5      n[        R                  XU:*  '   U$ rD  )floatrQ   r   r"  rF  )	rE   re   r  ro  r   r   r  rq  rM  s	            r6   r+  dpareto_lognorm_gen._munp  si    %(1u!%AE*+bffQUQ!Va1f_q=P5P.QQjjoffF
r8   r   r-  )r   r   r   r   r   r.  r   r  r  r  r	  r  rw   r  r{   _Phir   r  r  r  ro   rf   r   r+  r   r   r8   r6   r  r  *  s}    0b llGllG{{H99D99DHHE,2E++
(6
332r8   r  dpareto_lognormc                   ^    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rS rSrg)dweibull_geni  aJ  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   dweibull_gen._shape_info  r5  r8   Nc                     UR                  US9n[        R                  XUS9nU[        R                  " US:  SS5      -  $ r  )r  weibull_minr)  rQ   r  )rE   ra  r   r   r  ws         r6   r   dweibull_gen._rvs  sC      d +OOA|ODBHHQ#Xq"-..r8   c                 j    [        U5      nUS-  X2S-
  -  -  [        R                  " X2-  * 5      -  nU$ Nr   r   )r  rQ   r   )rE   rv   ra  r  Pxs        r6   rw   dweibull_gen._pdf  s5    VWrcE{"RVVRUF^3	r8   c                     [        U5      n[        R                  " U5      [        R                  " S5      -
  [        R                  " US-
  U5      -   X2-  -
  $ r(  )r  rQ   r  r~   r  )rE   rv   ra  r  s       r6   r   dweibull_gen._logpdf  sA    Vvvay266#;&!c'2)>>FFr8   c                     S[         R                  " [        U5      U-  * 5      -  n[         R                  " US:  SU-
  U5      $ Nr   r   r   )rQ   r   r  r  )rE   rv   ra  Cx1s       r6   r{   dweibull_gen._cdf  s:    BFFCFAI:&&xxAq3w,,r8   c                     S[         R                  " US:*  USU-
  5      -  n[         R                  " [         R                  " U5      * SU-  5      n[         R                  " US:  X3* 5      $ Nr   r   r   )rQ   r  rf  r  )rE   r   ra  r  s       r6   r   dweibull_gen._ppf  sV    288AHaa00hhs|S1W-xxCd++r8   c                     S[         R                  R                  [        R                  " U5      U5      -  n[        R
                  " US:  USU-
  5      $ r.  )rI  r$  r   rQ   r  r  )rE   rv   ra  half_weibull_min_sfs       r6   r   dweibull_gen._sf  sF    !E$5$5$9$9"&&)Q$GGxxA2A8K4KLLr8   c                     S[         R                  " US:*  USU-
  5      -  n[        R                  R	                  X25      n[         R                  " US:  U* U5      $ r2  )rQ   r  rI  r$  r   )rE   r   ra  double_qweibull_min_isfs        r6   r   dweibull_gen._isf  sQ    c1b1f55++00=xxC/!1?CCr8   c                 R    SUS-  -
  [         R                  " SSU-  U-  -   5      -  $ )Nr   rW   r   r~   r(  r   s      r6   r+  dweibull_gen._munp  s+    QUrxxcAgk(9:::r8   c                     gN)r   Nr   Nr   r  s     r6   r   dweibull_gen._stats      r8   c                 r    [         R                  R                  U5      [        R                  " S5      -
  nU$ r  )rI  r$  r  rQ   r  )rE   ra  r  s      r6   r  dweibull_gen._entropy  s*    &&q)BFF3K7r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r+  r   r  r   r   r8   r6   r   r     sB    *E/
G-,
MD
; r8   r   dweibullc                       \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rS r\\" \SS9S 5       5       rSrg)	expon_geni  a	  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                     / $ rO   r   rn   s    r6   ro   expon_gen._shape_info  r   r8   Nc                 $    UR                  U5      $ rO   )r  r   s      r6   r   expon_gen._rvs  s    0066r8   c                 0    [         R                  " U* 5      $ rO   rQ   r   r   s     r6   rw   expon_gen._pdf   s    vvqbzr8   c                     U* $ rO   r   r   s     r6   r   expon_gen._logpdf$  	    r	r8   c                 2    [         R                  " U* 5      * $ rO   r~   rk  r   s     r6   r{   expon_gen._cdf'      !}r8   c                 2    [         R                  " U* 5      * $ rO   rd  r   s     r6   r   expon_gen._ppf*  rT  r8   c                 0    [         R                  " U* 5      $ rO   rL  r   s     r6   r   expon_gen._sf-  s    vvqbzr8   c                     U* $ rO   r   r   s     r6   r	  expon_gen._logsf0  rP  r8   c                 0    [         R                  " U5      * $ rO   rg  r   s     r6   r   expon_gen._isf3      q	zr8   c                     g)N)r   r   r         @r   rn   s    r6   r   expon_gen._stats6  r  r8   c                     gr>  r   rn   s    r6   r  expon_gen._entropy9      r8   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                    [        U5      S:  a  [        S5      eUR                  SS 5      nUR                  SS 5      n[        U5        Ub  Ub  [	        S5      e[
        R                  " U5      n[
        R                  " U5      R                  5       (       d  [	        S5      eUR                  5       nUc  UnO UnXg:  a  [        SU[
        R                  S9eUc  UR                  5       U-
  nOUn[        U5      [        U5      4$ )	Nr   Too many arguments.r  r  r  r   exponr  )r  r4   r3   r7   r!  rQ   r"  r#  r$  minr  rm   r%  r  )	rE   rF   rG   r5   r  r  data_minr.   r/   s	            r6   rC   expon_gen.fit<  s     t9q=122xx%(D)$T* 2 ) * * zz${{4 $$&&CDD88:<CC~"7$bffEE>IIK#%EE Sz5<''r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r	  r   r   r  rL   r
   r   rC   r   r   r8   r6   rF  rF    sf    47"  6 &( &(r8   rF  rf  c                   F    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rSrg)exponnorm_genio  a  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                 @    [        SSS[        R                  4S5      /$ )NKFr   r3  rl   rn   s    r6   ro   exponnorm_gen._shape_info  r5  r8   Nc                 T    UR                  U5      U-  nUR                  U5      nXE-   $ rO   )r  r   )rE   rm  r   r   expvalgvals         r6   r   exponnorm_gen._rvs  s/    22481<++D1}r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  )rE   rv   rm  s      r6   rw   exponnorm_gen._pdf      vvdll1())r8   c                 p    SU-  nUSU-  U-
  -  nU[        X-
  5      -   [        R                  " U5      -
  $ Nr   r   r   rQ   r  )rE   rv   rm  invKexpargs        r6   r   exponnorm_gen._logpdf  s<    Qwta(QX..::r8   c                     SU-  nUSU-  U-
  -  nU[        X-
  5      -   n[        U5      [        R                  " U5      -
  $ rw  r   r   rQ   r   rE   rv   rm  ry  rp  logprods         r6   r{   exponnorm_gen._cdf  sE    Qwta(<11|bffWo--r8   c                     SU-  nUSU-  U-
  -  nU[        X-
  5      -   n[        U* 5      [        R                  " U5      -   $ rw  r}  r~  s         r6   r   exponnorm_gen._sf  sG    Qwta(<11!}rvvg..r8   c                 T    X-  nSU-   nSUS-  -  US-  -  nSU-  U-  US-  -  nXXE4$ )Nr   rW   r  r{  r_  r;  r   )rE   rm  K2opK2skwkrts         r6   r   exponnorm_gen._stats  sI    URx!Q$h%BhmdRj(  r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r8   r6   rk  rk  o  s,    (RE
*;
./!r8   rk  	exponnormc                 V    [         R                  " [        R                  " X5      5      $ )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)
)rQ   rk  r~   r  rv   r  s     r6   _pow1pm1r    s      88BJJq$%%r8   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)exponweib_geni  a@  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ Nr   Fr   r3  ra  rl   rE   r  r  s      r6   ro   exponweib_gen._shape_info  r  r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  rE   rv   r   ra  s       r6   rw   exponweib_gen._pdf	       vvdll1+,,r8   c                 
   X-  * n[         R                  " U5      * n[        R                  " U5      [        R                  " U5      -   [         R                  " US-
  U5      -   U-   [         R                  " US-
  U5      -   nU$ r>  )r~   rk  rQ   r  r  )rE   rv   r   ra  negxcexm1clogps          r6   r   exponweib_gen._logpdf	  sm    % q	BFF1I%S%(@@S!,-r8   c                 >    [         R                  " X-  * 5      * nXB-  $ rO   rR  )rE   rv   r   ra  r  s        r6   r{   exponweib_gen._cdf	  s    14% xr8   c                 r    [         R                  " USU-  -  * 5      * [        R                  " SU-  5      -  $ r>  )r~   r  rQ   r"  )rE   r   r   ra  s       r6   r   exponweib_gen._ppf	  s0    1s1u:+&&CE):::r8   c                 L    [        [        R                  " X-  * 5      * U5      * $ rO   )r  rQ   r   r  s       r6   r   exponweib_gen._sf	  s     "&&!$-+++r8   c                 Z    [         R                  " [        U* SU-  5      * 5      * SU-  -  $ ra   )rQ   r  r  )rE   rK  r   ra  s       r6   r   exponweib_gen._isf	  s-    1"ac**++qs33r8   r   Nr   r   r   r   r   ro   rw   r   r{   r   r   r   r   r   r8   r6   r  r    s+    'P
-
;,4r8   r  	exponweibc                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)exponpow_geni	  aC  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                 @    [        SSS[        R                  4S5      /$ Nr   Fr   r3  rl   rn   s    r6   ro   exponpow_gen._shape_info:	  r5  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   r   s      r6   rw   exponpow_gen._pdf=	      vvdll1())r8   c                     X-  nS[         R                  " U5      -   [        R                  " US-
  U5      -   U-   [         R                  " U5      -
  nU$ Nr   r   )rQ   r  r~   r  r   )rE   rv   r   xbr  s        r6   r   exponpow_gen._logpdfA	  sE    Tq	MBHHQWa0025r
Br8   c                 ^    [         R                  " [         R                  " X-  5      * 5      * $ rO   rR  r  s      r6   r{   exponpow_gen._cdfF	  s     "((14.)))r8   c                 \    [         R                  " [        R                  " X-  5      * 5      $ rO   rQ   r   r~   rk  r  s      r6   r   exponpow_gen._sfI	  s    vvrxx~o&&r8   c                 d    [         R                  " [        R                  " U5      * 5      SU-  -  $ r>  r~   r  rQ   r  r  s      r6   r   exponpow_gen._isfL	  s$    "&&)$1--r8   c                 t    [        [        R                  " [        R                  " U* 5      * 5      SU-  5      $ r>  powr~   r  rE   r   r   s      r6   r   exponpow_gen._ppfO	  s(    288RXXqb\M*CE22r8   r   N)r   r   r   r   r   ro   rw   r   r{   r   r   r   r   r   r8   r6   r  r  	  s+    6E*
*'.3r8   r  exponpowc                   j    \ rS rSrSr\R                  rS rSS jr	S r
S rS rS	 rS
 rS rS rSrg)fatiguelife_geniV	  a  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   fatiguelife_gen._shape_infos	  r5  r8   Nc                     UR                  U5      nSU-  U-  nXU-  nSSU-  -   SU-  [        R                  " SU-   5      -  -   nU$ )Nr   r   rW   r   )r   rQ   r&  )rE   ra  r   r   r  rv   r  ts           r6   r   fatiguelife_gen._rvsv	  sR    ((.E!GS!B$J1RWWQV_,,r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  re  s      r6   rw   fatiguelife_gen._pdf}	  s     vvdll1())r8   c                    [         R                  " US-   5      US-
  S-  SU-  US-  -  -  -
  [         R                  " SU-  5      -
  S[         R                  " S[         R                  -  5      S[         R                  " U5      -  -   -  -
  $ )Nr   rW   r   r   r  r  re  s      r6   r   fatiguelife_gen._logpdf	  ss    qsqsQh#a%1*55qsCRVVAbeeG_q{234 	5r8   c                     [        SU-  [        R                  " U5      S[        R                  " U5      -  -
  -  5      $ r>  )r   rQ   r&  re  s      r6   r{   fatiguelife_gen._cdf	  s/    qBGGAJRWWQZ$?@AAr8   c                 h    U[        U5      -  nSU[        R                  " US-  S-   5      -   S-  -  $ N      ?rW   rU  r   rQ   r&  rE   r   ra  tmps       r6   r   fatiguelife_gen._ppf	  s6    )A,sRWWS!VaZ001444r8   c                     [        SU-  [        R                  " U5      S[        R                  " U5      -  -
  -  5      $ r>  )r   rQ   r&  re  s      r6   r   fatiguelife_gen._sf	  s/    a2771:BGGAJ#>?@@r8   c                 j    U* [        U5      -  nSU[        R                  " US-  S-   5      -   S-  -  $ r  r  r  s       r6   r   fatiguelife_gen._isf	  s8    b9Q<sRWWS!VaZ001444r8   c                     X-  nUS-  S-   nSU-  S-   nX$-  S-  nSU-  SU-  S-   -  [         R                  " US5      -  nS	U-  S
U-  S-   -  US-  -  nX5Xg4$ )Nr   r   r  r  rU     r_  rd  r  ]   g      D@rQ   rf  )rE   ra  c2r}  denr~  r  r  s           r6   r   fatiguelife_gen._stats	  s     S#X^BhnfslUbeck"RXXc3%77Vr"ut|$sCx/r8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r   r{   r   r   r   r   r   r   r8   r6   r  r  V	  sD    4 "44ME*
5B5A5r8   r  fatiguelifec                   F    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rSrg)foldcauchy_geni	  aG  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                     US:  $ r  r   r  s     r6   rf   foldcauchy_gen._argcheck	      Avr8   c                 @    [        SSS[        R                  4S5      /$ Nra  Fr   rk   rl   rn   s    r6   ro   foldcauchy_gen._shape_info	      3266{MBCCr8   Nc                 <    [        [        R                  XUS95      $ )Nr.   r   r   )r  r>  r)  rE   ra  r   r   s       r6   r   foldcauchy_gen._rvs	  s$    6::!+7  9 : 	:r8   c                 `    S[         R                  -  SSX-
  S-  -   -  SSX-   S-  -   -  -   -  $ Nr   r   rW   rc  re  s      r6   rw   foldcauchy_gen._pdf	  s8    255y#q!#z*S!QS1H*-==>>r8   c                     S[         R                  -  [         R                  " X-
  5      [         R                  " X-   5      -   -  $ r>  rQ   r  arctanre  s      r6   r{   foldcauchy_gen._cdf	  s.    255y"))AC.299QS>9::r8   c                     [         R                  " SX-
  5      [         R                  " SX-   5      -   [         R                  -  $ ra   r  re  s      r6   r   foldcauchy_gen._sf	  s2    
 

1ae$rzz!QU';;RUUBBr8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   rE  r  s     r6   r   foldcauchy_gen._stats	  r,  r8   r   r-  r   r   r   r   r   rf   ro   r   rw   r{   r   r   r   r   r8   r6   r  r  	  s,    &D:?;C.r8   r  
foldcauchyc                   R    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rSrg)f_geni	  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )NdfnFr   r3  dfdrl   )rE   idfnidfds      r6   ro   f_gen._shape_info	  s:    %BFF^D%BFF^D|r8   Nc                 &    UR                  XU5      $ rO   )r  )rE   r  r  r   r   s        r6   r   
f_gen._rvs
  s    ~~c--r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  rE   rv   r  r  s       r6   rw   
f_gen._pdf
  s     vvdll13/00r8   c                 L   SU-  nSU-  nUS-  [         R                  " U5      -  US-  [         R                  " U5      -  -   [        R                  " US-  S-
  U5      -   XE-   S-  [         R                  " XTU-  -   5      -  [        R                  " US-  US-  5      -   -
  nU$ Nr   rW   r   )rQ   r  r~   r  r  )rE   rv   r  r  re   r  r  s          r6   r   f_gen._logpdf
  s    #I#IsRVVAY1rvvay0288AaC!GQ3GGC7bffQ1Wo-		!A#qs0CCE
r8   c                 0    [         R                  " X#U5      $ rO   )r~   fdtrr  s       r6   r{   
f_gen._cdf
  s    wws##r8   c                 0    [         R                  " X#U5      $ rO   )r~   fdtrcr  s       r6   r   	f_gen._sf
      xx!$$r8   c                 0    [         R                  " X#U5      $ rO   )r~   fdtri)rE   r   r  r  s       r6   r   
f_gen._ppf
  r  r8   c                    SU-  SU-  pCUS-
  US-
  US-
  US-
  4u  pVpx[        US:  XE4S [        R                  5      n	[        US:  X4XV4S	 [        R                  5      n
[        US
:  X5Xg4S [        R                  5      nU[        R                  " S5      -  n[        US:  XU4S [        R                  5      nUS-  nXX4$ )Nr   r   r  r_         @rW   c                 
    X-  $ rO   r   )v2v2_2s     r6   r:  f_gen._stats.<locals>.<lambda>"
  s    RYr8   rU  c                 2    SU-  U-  X-   -  XS-  -  U-  -  $ rD  r   )v1r  r  v2_4s       r6   r:  r  '
  s$    FRK29%Ag)<=r8   r  c                 T    SU -  U-   U-  [         R                  " X X-   -  -  5      -  $ rD  r  )r  r  r  v2_6s       r6   r:  r  -
  s*    Vd]d"RWWT295E-F%GGr8   rb  c                     SX -  U-  -   U-  $ )Nrb  r   )r  r  v2_8s      r6   r:  r  4
  s    A$$6$#>r8   rd  )r   rQ   rm   rF  r&  )rE   r  r  r  r  r  r  r  r!  r}  r~  r  r  s                r6   r   f_gen._stats
  s    c28B!#b"r'27BG!CDFRJ&FF
 FRT(>FF	 FRt*HFF	
 	bggbkFRt$>FF 	gr8   c                 T   SU-  nSU-  nSX-   -  n[         R                  " U5      [         R                  " U5      -
  [        R                  " X45      -   SU-
  [        R                  " U5      -  -   SU-   [        R                  " U5      -  -
  U[        R                  " U5      -  -   $ r  )rQ   r  r~   r  r  )rE   r  r  half_dfnhalf_dfdhalf_sums         r6   r  f_gen._entropy:
  s     99#)$sbffSk)BIIh,IIX!11256\x 5!!#+bffX.>#>? 	@r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r  r   r   r8   r6   r  r  	  s6    #H
.1$%%<
@r8   r  r  c                   F    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rSrg)foldnorm_geniR
  aN  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                     US:  $ r  r   r  s     r6   rf   foldnorm_gen._argcheckh
  r  r8   c                 @    [        SSS[        R                  4S5      /$ r  rl   rn   s    r6   ro   foldnorm_gen._shape_infok
  r  r8   Nc                 <    [        UR                  U5      U-   5      $ rO   r  r   r  s       r6   r   foldnorm_gen._rvsn
  s    <//59::r8   c                 8    [        X-   5      [        X-
  5      -   $ rO   r   re  s      r6   rw   foldnorm_gen._pdfq
  s    )AC.00r8   c                     [         R                  " S5      nS[        R                  " X-
  U-  5      [        R                  " X-   U-  5      -   -  $ rZ  )rQ   r&  r~   erf)rE   rv   ra  sqrt_twos       r6   r{   foldnorm_gen._cdfu
  s?    771:bffaeX-.8H1IIJJr8   c                 8    [        X-
  5      [        X-   5      -   $ rO   r  re  s      r6   r   foldnorm_gen._sfy
  s    !%00r8   c                    X-  n[         R                  " SU-  5      [         R                  " S[         R                  -  5      -  nSU-  U[        R
                  " U[         R                  " S5      -  5      -  -   nUS-   XD-  -
  nSXD-  U-  X$-  -
  U-
  -  nU[         R                  " US5      -  nX"S-   -  S-   SU-  U-  -   nUSUS	-
  -  S	US-  -  -
  US-  -  -  nXuS-  -  S	-
  nXEXg4$ )
N      r   rW   r   rd  r_  r  r  r  )rQ   r   r&  r  r~   r4  rf  )rE   ra  r  expfacr}  r~  r  r  s           r6   r   foldnorm_gen._stats|
  s     SR2772bee8#44YRVVAbggajL1111frun258be#f,-
bhhsC  7^a"V)B,.
rR"W~RU
*b!e33s(]Rr8   r   r-  r  r   r8   r6   r)  r)  R
  s,    *D;1K1r8   r)  foldnormc                   |   ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS r\" \SS9U 4S j5       rSrU =r$ )weibull_min_geni
  a  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   weibull_min_gen._shape_info
  r5  r8   c                 f    U[        XS-
  5      -  [        R                  " [        X5      * 5      -  $ ra   r  rQ   r   re  s      r6   rw   weibull_min_gen._pdf
  s(    Q!}RVVSYJ///r8   c                 |    [         R                  " U5      [        R                  " US-
  U5      -   [	        X5      -
  $ ra   rQ   r  r~   r  r  re  s      r6   r   weibull_min_gen._logpdf
  s-    vvay288AE1--A	99r8   c                 D    [         R                  " [        X5      * 5      * $ rO   r~   rk  r  re  s      r6   r{   weibull_min_gen._cdf
  s    #a)$$$r8   c                 L    [        [        R                  " U* 5      * SU-  5      $ r>  r  rl  s      r6   r   weibull_min_gen._ppf
  s    BHHaRL=#a%((r8   c                 L    [         R                  " U R                  X5      5      $ rO   r  re  s      r6   r   weibull_min_gen._sf
      vvdkk!'((r8   c                     [        X5      * $ rO   r  re  s      r6   r	  weibull_min_gen._logsf
  s    A	zr8   c                 <    [         R                  " U5      * SU-  -  $ ra   rg  rl  s      r6   r   weibull_min_gen._isf
  s    
ac""r8   c                 @    [         R                  " SUS-  U-  -   5      $ r>  r<  r   s      r6   r+  weibull_min_gen._munp
  s    xxAcE!G$$r8   c                 X    [         * U-  [        R                  " U5      -
  [         -   S-   $ ra   r$   rQ   r  r  s     r6   r  weibull_min_gen._entropy
  %    w{RVVAY&/!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           	      z  >^^ [        U[        5      (       a9  UR                  5       S:X  a  UR                  5       nO[        TU ]  " U/UQ70 UD6$ UR                  SS5      (       a  [        TU ]  " U/UQ70 UD6$ [        XX#5      u  ppVUR                  SS5      R                  5       nS m[        R                  " U5      mSnT" U5      n	TU	:  a$  US:w  a  Uc  U(       d  [        TU ]  " U/UQ70 UD6$ US:X  a  S	u  pnO;[        U5      (       a  US   OS n
UR                  S
S 5      nUR                  SS 5      nUc   U
c  [        UU4S jSU/SS9R                  n
OUb  Un
Ucm  Ucj  [        R                   " U5      n[        R"                  " U[$        R&                  " SSU
-  -   5      [$        R&                  " SSU
-  -   5      S-  -
  -  5      nOUb  UnUc;  Uc8  [        R(                  " U5      nX[$        R&                  " SSU
-  -   5      -  -
  nOUb  UnUS:X  a  XU4$ [        TU ]  " X4XS.UD6$ )Nr   superfitFr1   r;   c                     [         R                  " SSU -  -   5      n[         R                  " SSU -  -   5      n[         R                  " SSU -  -   5      nSUS-  -  SU-  U-  -
  U-   nX!S-  -
  S-  nXE-  $ )Nr   rW   r  rd  r<  )ra  gamma1gamma2gamma3numr  s         r6   skew!weibull_min_gen.fit.<locals>.skew
  sx    XXa!e_FXXa!e_FXXa!e_Ffai-!F(6/1F:CAI%-C7Nr8   g     @r<   NNNr.   r/   c                    > T" U 5      T-
  $ rO   r   )ra  ro  rb  s    r6   r:  %weibull_min_gen.fit.<locals>.<lambda>  s    d1gkr8   g{Gz?bisect)bracketr1   r   rW   r.   r/   )r?   r*   r@   r  rA   rC   r3   _check_fit_input_parametersr=   r>   rI  rb  r  r+   rootrQ   r  r&  r~   r(  r%  )rE   rF   rG   r5   fcr  r  r1   max_cs_minra  r.   r/   r  r  ro  rb  r  s                  @@r6   rC   weibull_min_gen.fit
  s2    dL))  "a'~~'w{47$7$7788J&&7;t3d3d33 "=T=A"I$(E*002	 JJtUu94BJt7;t3d3d33 T>,MAEt99Q$A((5$'CHHWd+E:!) 1D%=#+--1T ^A>emtAGGA!AaC%288AacE?A3E!EFGEE<CKABHHQ1W---CCT>5=  7;tECEEEr8   r   )r   r   r   r   r   ro   rw   r   r{   r   r   r	  r   r+  r  r	   r   rC   r   r  r   s   @r6   r?  r?  
  s`    +XE0:%))#%4 } 5 JFJFr8   r?  r$  c                   t   ^  \ rS rSrSrS rS rU 4S jrS rS r	S r
S	 rS
 rS rS rS rS rS rSrU =r$ )truncweibull_min_geni7  a  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                 "    US:  X2:  -  US:  -  $ Nr   r   rE   ra  r   r   s       r6   rf   truncweibull_min_gen._argcheckd  s    RAE"a"f--r8   c                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      n[        SSS[        R                  4S5      nXU/$ )Nra  Fr   r3  r   rk   r   rl   )rE   r  r  r  s       r6   ro    truncweibull_min_gen._shape_infog  sT    UQK@UQK?UQK@|r8   c                     > [         TU ]  USS9$ )N)r   r   r   r  rA   r  rE   rF   r  s     r6   r  truncweibull_min_gen._fitstartm  s    w I 66r8   c                     X#4$ rO   r   rt  s       r6   r   !truncweibull_min_gen._get_supportq  	    tr8   c                     [         R                  " [        X25      * 5      [         R                  " [        XB5      * 5      -
  nU[        XS-
  5      -  [         R                  " [        X5      * 5      -  U-  $ ra   rQ   r   r  )rE   rv   ra  r   r   denums         r6   rw   truncweibull_min_gen._pdft  sU    Q
#bffc!iZ&88CQ3K"&&#a)"44==r8   c           	      ,   [         R                  " [         R                  " [        X25      * 5      [         R                  " [        XB5      * 5      -
  5      n[         R                  " U5      [        R
                  " US-
  U5      -   [        X5      -
  U-
  $ ra   )rQ   r  r   r  r~   r  )rE   rv   ra  r   r   logdenums         r6   r   truncweibull_min_gen._logpdfx  sc    66"&&#a),rvvs1yj/AABvvay288AE1--A	9HDDr8   c                    [         R                  " [        X25      * 5      [         R                  " [        X5      * 5      -
  n[         R                  " [        X25      * 5      [         R                  " [        XB5      * 5      -
  nXV-  $ rO   r  rE   rv   ra  r   r   ra  r  s          r6   r{   truncweibull_min_gen._cdf|  Z    vvs1yj!BFFCI:$66Q
#bffc!iZ&88{r8   c           	      ^   [         R                  " [         R                  " [        X25      * 5      [         R                  " [        X5      * 5      -
  5      n[         R                  " [         R                  " [        X25      * 5      [         R                  " [        XB5      * 5      -
  5      nXV-
  $ rO   rQ   r  r   r  rE   rv   ra  r   r   lognumr  s          r6   r  truncweibull_min_gen._logcdf  m    A	z*RVVSYJ-??@66"&&#a),rvvs1yj/AAB  r8   c                    [         R                  " [        X5      * 5      [         R                  " [        XB5      * 5      -
  n[         R                  " [        X25      * 5      [         R                  " [        XB5      * 5      -
  nXV-  $ rO   r  r  s          r6   r   truncweibull_min_gen._sf  r  r8   c           	      ^   [         R                  " [         R                  " [        X5      * 5      [         R                  " [        XB5      * 5      -
  5      n[         R                  " [         R                  " [        X25      * 5      [         R                  " [        XB5      * 5      -
  5      nXV-
  $ rO   r  r  s          r6   r	  truncweibull_min_gen._logsf  r  r8   c                     [        [        R                  " SU-
  [        R                  " [        XB5      * 5      -  U[        R                  " [        X25      * 5      -  -   5      * SU-  5      $ ra   r  rQ   r  r   rE   r   ra  r   r   s        r6   r   truncweibull_min_gen._isf  U    VVQUbffc!iZ001rvvs1yj7I3IIJJAaC 	r8   c                     [        [        R                  " SU-
  [        R                  " [        X25      * 5      -  U[        R                  " [        XB5      * 5      -  -   5      * SU-  5      $ ra   r  r  s        r6   r   truncweibull_min_gen._ppf  r  r8   c           	      Z   [         R                  " X-  S-   5      [         R                  " X-  S-   [        XB5      5      [         R                  " X-  S-   [        X25      5      -
  -  n[        R
                  " [        X25      * 5      [        R
                  " [        XB5      * 5      -
  nXV-  $ r>  )r~   r(  rS  r  rQ   r   )rE   re   ra  r   r   	gamma_funr  s          r6   r+  truncweibull_min_gen._munp  s    HHQS2X&KKb#a),r{{138SY/OO	 Q
#bffc!iZ&88  r8   r   )r   r   r   r   r   rf   ro   r  r   rw   r   r{   r  r   r	  r   r   r+  r   r  r   s   @r6   rq  rq  7  sP    +X.7>E
!

!


! !r8   rq  truncweibull_minr  c                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)weibull_max_geni  a  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   weibull_max_gen._shape_info  r5  r8   c                 n    U[        U* US-
  5      -  [        R                  " [        U* U5      * 5      -  $ ra   rC  re  s      r6   rw   weibull_max_gen._pdf  s0    aR1~bffc1"aj[111r8   c                     [         R                  " U5      [        R                  " US-
  U* 5      -   [	        U* U5      -
  $ ra   rF  re  s      r6   r   weibull_max_gen._logpdf  s3    vvay288AaC!,,sA2qz99r8   c                 F    [         R                  " [        U* U5      * 5      $ rO   r  re  s      r6   r{   weibull_max_gen._cdf  s    vvsA2qzk""r8   c                     [        U* U5      * $ rO   rQ  re  s      r6   r  weibull_max_gen._logcdf  s    QB
{r8   c                 H    [         R                  " [        U* U5      * 5      * $ rO   rI  re  s      r6   r   weibull_max_gen._sf  s    #qb!*%%%r8   c                 L    [        [        R                  " U5      * SU-  5      * $ r>  )r  rQ   r  rl  s      r6   r   weibull_max_gen._ppf  s     RVVAYJA&&&r8   c                 ~    [         R                  " SUS-  U-  -   5      n[        U5      S-  (       a  SnXC-  $ SnXC-  $ )Nr   rW   r  r   )r~   r(  r*  )rE   re   ra  valsgns        r6   r+  weibull_max_gen._munp  sE    hhs1S57{#q6A:C y Cyr8   c                 X    [         * U-  [        R                  " U5      -
  [         -   S-   $ ra   rX  r  s     r6   r  weibull_max_gen._entropy  rZ  r8   r   N)r   r   r   r   r   ro   rw   r   r{   r  r   r   r+  r  r   r   r8   r6   r  r    s6    #HE2:#&'4r8   r  weibull_max)r   r   c                   T    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)genlogistic_geni  a1  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   genlogistic_gen._shape_info  r5  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  re  s      r6   rw   genlogistic_gen._pdf  r  r8   c                     US-
  * US:  -  S-
  n[         R                  " U5      n[         R                  " U5      X4-  -   US-   [        R                  " [         R
                  " U* 5      5      -  -
  $ Nr   r   )rQ   r  r  r~   r  r   )rE   rv   ra  multr  s        r6   r   genlogistic_gen._logpdf  s`     Qx1q5!A%vvayvvay49$!rxxu/F'FFFr8   c                 B    S[         R                  " U* 5      -   U* -  nU$ ra   rL  )rE   rv   ra  Cxs       r6   r{   genlogistic_gen._cdf   s!    r
lqb!	r8   c                 `    U* [         R                  " [         R                  " U* 5      5      -  $ rO   )rQ   r  r   re  s      r6   r  genlogistic_gen._logcdf$  s"    rBHHRVVQBZ(((r8   c                 `    [         R                  " [        R                  " USU-  5      5      * $ r  )rQ   r  r~   powm1rl  s      r6   r   genlogistic_gen._ppf'  s#    rxx46*+++r8   c                 N    [         R                  " U R                  X5      5      * $ rO   r~   rk  r  re  s      r6   r   genlogistic_gen._sf*      a+,,,r8   c                 ,    U R                  SU-
  U5      $ ra   r   rl  s      r6   r   genlogistic_gen._isf-  s    yyQ""r8   c                    [         [        R                  " U5      -   n[        R                  [        R                  -  S-  [        R
                  " SU5      -   nS[        R
                  " SU5      -  S[        -  -   nU[        R                  " US5      -  n[        R                  S-  S-  S[        R
                  " SU5      -  -   nXSS	-  -  nX#XE4$ )
Nr_  rW   r;  r  rd  rU        .@r  r   )r$   r~   r  rQ   r  zetar%   rf  rE   ra  r}  r~  r  r  s         r6   r   genlogistic_gen._stats0  s    bffQieeBEEk#o1-1&(
bhhsC  UUAXd]Qrwwq!}_,
3hr8   c                 &    [        US:  U4S S S9$ )Ng    ^Ac                 x    [         R                  " U 5      * [        R                  " U S-   5      -   [        -   S-   $ ra   )rQ   r  r~   r  r$   r  s    r6   r:  *genlogistic_gen._entropy.<locals>.<lambda>;  s)    RVVAYJA$>$G!$Kr8   c                 &    SSU -  -  [         -   S-   $ rf  r$   r  s    r6   r:  r  A  s    q!a%y6'9A'=r8   r>  r@  r  s     r6   r  genlogistic_gen._entropy9  s!    !c'A5K >? 	?r8   r   N)r   r   r   r   r   ro   rw   r   r{   r  r   r   r   r   r  r   r   r8   r6   r  r    s<    @E*G),-#?r8   r  genlogisticc                   j    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSS jrS rS rSrg)genpareto_geniG  a=  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                 .    [         R                  " U5      $ rO   rQ   r#  r  s     r6   rf   genpareto_gen._argcheckk      {{1~r8   c                 ^    [        SS[        R                  * [        R                  4S5      /$ Nra  Fr3  rl   rn   s    r6   ro   genpareto_gen._shape_infon  %    3'8.IJJr8   c                     [         R                  " U5      n[        US:  U4S [         R                  5      n[         R                  " US:  U R
                  U R
                  5      nX24$ )Nr   c                     SU -  $ r  r   r  s    r6   r:  ,genpareto_gen._get_support.<locals>.<lambda>t  s    qr8   )rQ   r"  r   rm   r  r   )rE   ra  r   r   s       r6   r   genpareto_gen._get_supportq  sT    JJqMq1uqd(vv HHQ!VTVVTVV,tr8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  re  s      r6   rw   genpareto_gen._pdfy  r  r8   c                 4    [        X:H  US:g  -  X4S U* 5      $ )Nr   c                 B    [         R                  " US-   X-  5      * U-  $ r>  r  rv   ra  s     r6   r:  'genpareto_gen._logpdf.<locals>.<lambda>  s    

1r613(?'?!'Cr8   r@  re  s      r6   r   genpareto_gen._logpdf}  s(    16a1f-vC" 	r8   c                 6    [         R                  " U* U* 5      * $ rO   )r~   inv_boxcox1pre  s      r6   r{   genpareto_gen._cdf  s    QB'''r8   c                 4    [         R                  " U* U* 5      $ rO   )r~   
inv_boxcoxre  s      r6   r   genpareto_gen._sf  s    }}aR!$$r8   c                 4    [        X:H  US:g  -  X4S U* 5      $ )Nr   c                 :    [         R                  " X-  5      * U-  $ rO   rd  r  s     r6   r:  &genpareto_gen._logsf.<locals>.<lambda>  s    ~'9r8   r@  re  s      r6   r	  genpareto_gen._logsf  s(    16a1f-v9" 	r8   c                 6    [         R                  " U* U* 5      * $ rO   )r~   boxcox1prl  s      r6   r   genpareto_gen._ppf  s    QB###r8   c                 2    [         R                  " X* 5      * $ rO   )r~   boxcoxrl  s      r6   r   genpareto_gen._isf  s    		!R   r8   c                 Z   SU;  a  S nO![        US:  U4S [        R                  5      nSU;  a  S nO![        US:  U4S [        R                  5      nSU;  a  S nO![        US:  U4S	 [        R                  5      nS
U;  a  S nO![        US:  U4S [        R                  5      nX4XV4$ )Nr  r   c                     SSU -
  -  $ ra   r   xis    r6   r:  &genpareto_gen._stats.<locals>.<lambda>  s    aRjr8   r  r   c                 *    SSU -
  S-  -  SSU -  -
  -  $ rf  r   r  s    r6   r:  r    s    a1r6A+oQrT&Br8   ro  gUUUUUU?c                 ^    SSU -   -  [         R                  " SSU -  -
  5      -  SSU -  -
  -  $ )NrW   r   r  r  r  s    r6   r:  r    s2    qAF|bgga!B$h6G'G()AbD(2r8   rq  r  c                 `    SSSU -  -
  -  SU S-  -  U -   S-   -  SSU -  -
  -  SSU -  -
  -  S-
  $ )Nr  r   rW   rU  r   r  s    r6   r:  r    sO    qA"H~2q529I'J()AbD(2562X(?AB(Cr8   r   rQ   rm   rF  )rE   ra  rt  r  r  ro  rq  s          r6   r   genpareto_gen._stats  s    gA1q51$066#A gA1s7QDB66#A gA1s7QD366#A gA1s7QDD66#A Qzr8   c           	      h   ^^ S m[        US:g  U4UU4S j[        R                  " TS-   5      5      $ )Nc                    Sn[         R                  " SU S-   5      n[        U[        R                  " X5      5       H  u  pEX%SU-  -  SX-  -
  -  -   nM     [         R
                  " X-  S:  USU-  U -  -  [         R                  5      $ )Nr   r   r   r  r   r  )rQ   r  zipr~   combr  rm   )re   ra  r  rq  kicnks         r6   r  #genpareto_gen._munp.<locals>.__munp  s|    C		!QU#Aq"''!-02"*,af== 188AEAIsdQh1_'<bffEEr8   r   c                    > T" TU 5      $ rO   r   )ra  _genpareto_gen__munpre   s    r6   r:  %genpareto_gen._munp.<locals>.<lambda>  s    F1aLr8   r   )r   r~   r(  )rE   re   ra  r  s    ` @r6   r+  genpareto_gen._munp  s4    	F !q&1$0((1q5/+ 	+r8   c                     SU-   $ r>  r   r  s     r6   r  genpareto_gen._entropy      Avr8   r   Nry  )r   r   r   r   r   rf   ro   r   rw   r   r{   r   r	  r   r   r   r+  r  r   r   r8   r6   r  r  G  sJ    "FK*
(%
$!:	+r8   r  	genparetoc                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)genexpon_geni  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      n[        SSS[        R                  4S5      nXU/$ )Nr   Fr   r3  r   ra  rl   )rE   r  r  r  s       r6   ro   genexpon_gen._shape_info  sT    UQK@UQK@UQK@|r8   c           	          X#[         R                  " U* U-  5      * -  -   [        R                  " U* U-
  U-  U[         R                  " U* U-  5      * -  U-  -   5      -  $ rO   r~   rk  rQ   r   rE   rv   r   r   ra  s        r6   rw   genexpon_gen._pdf  sf     !A''!Aq01BHHaRTN?0CA0E1F *G G 	Gr8   c                     [         R                  " X#[        R                  " U* U-  5      * -  -   5      U* U-
  U-  -   U[        R                  " U* U-  5      * -  U-  -   $ rO   rQ   r  r~   rk  r  s        r6   r   genexpon_gen._logpdf  sW    vvaBHHaRTN?++,1ax7BHHaRTN?8KA8MMMr8   c                     [         R                  " U* U-
  U-  U[         R                  " U* U-  5      * -  U-  -   5      * $ rO   rR  r  s        r6   r{   genexpon_gen._cdf  s=    1"Q$A!A$7$99:::r8   c                     X#-   nX4[         R                  " U* 5      -  -
  U-  nU[        R                  " U* U-  [         R                  " U* 5      -  5      R
                  -   U-  $ rO   )rQ   r  r~   lambertwr   realrE   rK  r   r   ra  ro  r  s          r6   r   genexpon_gen._ppf  sX    E288QB<"BKK1rvvqbz 12777::r8   c                     [         R                  " U* U-
  U-  U[        R                  " U* U-  5      * -  U-  -   5      $ rO   r  r  s        r6   r   genexpon_gen._sf  s:    vvr!tQhRXXqbd^O!4Q!6677r8   c                     X#-   nX4[         R                  " U5      -  -
  U-  nU[        R                  " U* U-  [         R                  " U* 5      -  5      R
                  -   U-  $ rO   )rQ   r  r~   r'  r   r(  r)  s          r6   r   genexpon_gen._isf  sU    E266!9_aBKK1rvvqbz 12777::r8   r   Nr  r   r8   r6   r  r    s,    >GN;;
8;r8   r  genexponc                      ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rU 4S jrS rS rSrU =r$ )genextreme_geni  a  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                 .    [         R                  " U5      $ rO   r  r  s     r6   rf   genextreme_gen._argcheck,  r  r8   c                 ^    [        SS[        R                  * [        R                  4S5      /$ r  rl   rn   s    r6   ro   genextreme_gen._shape_info/  r  r8   c                     [         R                  " US:  S[         R                  " U[        5      -  [         R                  5      n[         R                  " US:  S[         R
                  " U[        * 5      -  [         R                  * 5      nX24$ Nr   r   )rQ   r  maximumr"   rm   minimum)rE   ra  _b_as       r6   r   genextreme_gen._get_support2  sa    XXa!eS2::a#77@XXa!eS2::a%#88266'Bvr8   c                 4    [        X:H  US:g  -  X4S U* 5      $ )Nr   c                 <    [         R                  " U* U -  5      U-  $ rO   rd  r  s     r6   r:  +genextreme_gen._loglogcdf.<locals>.<lambda>:  s    rxx1~a'7r8   r@  re  s      r6   
_loglogcdfgenextreme_gen._loglogcdf7  s'    16a1f-v7!= 	=r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  re  s      r6   rw   genextreme_gen._pdf<  s     vvdll1())r8   c                    [        X:H  US:g  -  X4S S5      n[        R                  " U* 5      nU R                  X5      n[        R
                  " U5      n[        R                  " XRS:H  U[        R                  * :H  -  S5        [        US:H  U[        R                  * :H  -  ) XeU4S [        R                  * S9n[        R                  " XrS:H  US:H  -  S5        U$ )Nr   c                 
    X-  $ rO   r   r  s     r6   r:  (genextreme_gen._logpdf.<locals>.<lambda>C  s    !#r8   r   r   c                     U * U-   U-
  $ rO   r   )pex2lpex2lex2s      r6   r:  rF  K  s    teemd6Jr8   rX  )r   r~   r  r@  rQ   r   putmaskrm   )rE   rv   ra  cxlogex2logpex2rH  logpdfs           r6   r   genextreme_gen._logpdfB  s    AF+aV5EsK2#//!'vvg


7!VbffW5s;rQw2"&&=9:!F3J')vvg/ 	

6FqAv.4r8   c                 N    [         R                  " U R                  X5      5      * $ rO   )rQ   r   r@  re  s      r6   r  genextreme_gen._logcdfP  s    tq,---r8   c                 L    [         R                  " U R                  X5      5      $ rO   r  re  s      r6   r{   genextreme_gen._cdfS  ru  r8   c                 N    [         R                  " U R                  X5      5      * $ rO   r  re  s      r6   r   genextreme_gen._sfV  r  r8   c                     [         R                  " [         R                  " U5      * 5      * n[        X3:H  US:g  -  X24S U5      $ )Nr   c                 >    [         R                  " U* U -  5      * U-  $ rO   rR  r  s     r6   r:  %genextreme_gen._ppf.<locals>.<lambda>\      !a(8'81'<r8   )rQ   r  r   rE   r   ra  rv   s       r6   r   genextreme_gen._ppfY  sB    VVRVVAYJ16a1f-v<aA 	Ar8   c                     [         R                  " [        R                  " U* 5      * 5      * n[	        X3:H  US:g  -  X24S U5      $ )Nr   c                 >    [         R                  " U* U -  5      * U-  $ rO   rR  r  s     r6   r:  %genextreme_gen._isf.<locals>.<lambda>a  rZ  r8   )rQ   r  r~   r  r   r[  s       r6   r   genextreme_gen._isf^  sD    VVRXXqb\M""16a1f-v<aA 	Ar8   c                 4  ^ U4S jnU" S5      nU" S5      nU" S5      nU" S5      n[         R                  " [        T5      S:  T[         R                  -  S-  S-  XCS-  -
  5      nS	 n[	        [        T5      S:  T4U[         R                  S-  S-  S
9n	Sn
S n[	        [        T5      U
:  T4U[
        * S
9n[         R                  " TS:  [         R                  U* 5      n[         R                  " TS:  [         R                  US-  U	-  5      nS nS[         R                  " S5      -  [        -  [         R                  S-  -  nX4XW4n[	        [        T5      U
S-  :  T4U-   UUS
9nS nX4XVU4n[	        [        T5      U
S-  :  T4U-   USS
9nXUU4$ )Nc                 <   > [         R                  " U T-  S-   5      $ ra   r<  )re   ra  s    r6   g genextreme_gen._stats.<locals>.gd  s    88AEAI&&r8   r   rW   r  rU  gHz>r   r_  c                     [         R                  " [         R                  " SU -  S-   5      S[         R                  " U S-   5      -  -
  5      U S-  -  $ )Nr   r   rW   r~   rk  r  r  s    r6   gam2k_f&genextreme_gen._stats.<locals>.gam2k_fk  sB    88BJJs1uSy1!BJJq3w4G2GGHCOOr8   r  rY  +=c                 b    [         R                  " [         R                  " U S-   5      5      U -  $ ra   rf  r  s    r6   gamk_f%genextreme_gen._stats.<locals>.gamk_fo  s#    88BJJq1u-.q00r8   r  r:  c                 J    S n[        U S:  U 4U-   U[        R                  S9$ )Nc                 Z    [         R                  " U 5      U* USU-  -   U-  -   -  US-  -  $ NrW   rd  rP   )ra  r  r  g3g2mg12s        r6   
sk1_eval_f;genextreme_gen._stats.<locals>.sk1_eval.<locals>.sk1_eval_f{  s2    wwqzB3"qx-);#;<VS[HHr8   r  ri  r  )ra  rG   rs  s      r6   sk1_eval'genextreme_gen._stats.<locals>.sk1_evalz  s'    Ia5j1$t)zRVVTTr8   r  r  g(\?c                 @    S n[        U S:  X[        R                  S9$ )Nc                 @    USU-  SX-   -  U -  -   U -  -   US-  -  S-
  $ )Nrq  r  rW   r   )r  r  rq  g4rr  s        r6   
ku1_eval_f;genextreme_gen._stats.<locals>.ku1_eval.<locals>.ku1_eval_f  s4    beaob&88"<<faiG!KKr8   g      пrX  r  )ra  rG   rz  s      r6   ku1_eval'genextreme_gen._stats.<locals>.ku1_eval  s    La5j$bffMMr8   gq=
ףp?333333@)	rQ   r  r  r  r   r$   rF  r&  r%   )rE   ra  rc  r  r  rq  ry  rr  rg  gam2kepsrl  gamkr  r  ru  sk_fillrG   r  r|  r  s    `                   r6   r   genextreme_gen._statsc  s   	'qTqTqTqT#a&4-!BEE'C);RCZH	P3q6T>A47beeSjQTnU	1#a&C-!F7K HHQXrvvu- HHQXrvvr3wu}5	U
 RWWQZ-&ruuax/#Ad*QDIWU	N
 'Ad*QDIXVR|r8   c                    > [        U[        5      (       a  UR                  5       n[        U5      nUS:  a  SnOSn[        TU ]  X4S9$ )Nr   r   r:  r  r?   r*   r  r   rA   r  )rE   rF   rc  r   r  s       r6   r  genextreme_gen._fitstart  sK    dL))>>#D$Kq5AAw D 11r8   c                 2   [         R                  " SUS-   5      nSX!-  -  [         R                  " [        R                  " X5      SU-  -  [        R
                  " X#-  S-   5      -  SS9-  n[         R                  " X!-  S:  U[         R                  5      $ )Nr   r   r   r  rR  )rQ   r  r  r~   r  r(  r  rm   )rE   re   ra  rq  valss        r6   r+  genextreme_gen._munp  s{    IIa114x"&&GGAMR!G#bhhqsQw&77  xxb$//r8   c                      [         SU-
  -  S-   $ ra   r  r  s     r6   r  genextreme_gen._entropy  s    q1u~!!r8   r   )r   r   r   r   r   rf   ro   r   r@  rw   r   r  r{   r   r   r   r   r  r+  r  r   r  r   s   @r6   r1  r1    s]    %LK
=
*.*-A
A
)V	20" "r8   r1  
genextremec                 L  ^  SnU 4S jnT S:  a7  [         R                  " T 5      S-   nT S:  a  [        R                  " X#SS9nU$ O,T S:  a  [         R                  " T S	-  5      S
-   nO	ST * U-
  -  n[        R                  " X#SSS9u  pEpgUS:w  a  [        ST < 35      eUS   $ )a2  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                 6   > [         R                  " U 5      T-
  $ rO   )r~   rk  r  s    r6   r  _digammainv.<locals>.func  s    zz!}q  r8   g      r   r  绽|=)tolrp  g-@g뭁,?r   dy=T)xtolr  r   z _digammainv: fsolve failed, y = r   )rQ   r   r   newtonr  RuntimeError)r  _emr  x0valuer  r  r  s   `       r6   _digammainvr    s    $ &C! 	6zVVAY_r6 OOD%8EL  
RVVAeG_w&QBH%__TE9=?E
ax=aUCDD8Or8   c                      ^  \ rS rSrSrS rSS jrS rS rS r	S r
S	 rS
 rS rS rS rU 4S jr\" \SS9U 4S j5       rSrU =r$ )	gamma_geni  a3  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                 @    [        SSS[        R                  4S5      /$ r2  rl   rn   s    r6   ro   gamma_gen._shape_info  r5  r8   c                 $    UR                  X5      $ rO   standard_gamma)rE   r   r   r   s       r6   r   gamma_gen._rvs  s    **133r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  r8  s      r6   rw   gamma_gen._pdf  r  r8   c                 j    [         R                  " US-
  U5      U-
  [         R                  " U5      -
  $ r>  )r~   r  r  r8  s      r6   r   gamma_gen._logpdf  s)    xx#q!A%

155r8   c                 .    [         R                  " X!5      $ rO   rR  r8  s      r6   r{   gamma_gen._cdf  r   r8   c                 .    [         R                  " X!5      $ rO   rV  r8  s      r6   r   gamma_gen._sf  s    ||A!!r8   c                 .    [         R                  " X!5      $ rO   r  rA  s      r6   r   gamma_gen._ppf  s    ~~a##r8   c                 .    [         R                  " X!5      $ rO   r~   ra  rA  s      r6   r   gamma_gen._isf  s    q$$r8   c                 @    XS[         R                  " U5      -  SU-  4$ )Nr   r_  r  rG  s     r6   r   gamma_gen._stats  s    S^SU**r8   c                 .    [         R                  " X!5      $ rO   r~   re  rE   re   r   s      r6   r+  gamma_gen._munp  s    wwq}r8   c                 .    S nS n[        US:  U4UUS9$ )Nc                 n    [         R                  " U 5      SU -
  -  U -   [         R                  " U 5      -   $ ra   r~   r  r  r   s    r6   rm  +gamma_gen._entropy.<locals>.regular_formula#  s+    66!9!$q(2::a=88r8   c                     SS[         R                  " S[         R                  -  5      -   [         R                  " U 5      -   -  SSU -  -  -
  U S-  S-  -
  U S-  S	-  -
  U S
-  S-  -   $ )Nr   r   rW   r   r  r  r  r  r  r   r  r  r  s    r6   rs  .gamma_gen._entropy.<locals>.asymptotic_formula&  sq    
 2qw/"&&);<q!a%yH#vrk"%&VRK034c63,? @r8      r>  r@  )rE   r   rm  rs  s       r6   r  gamma_gen._entropy!  s+    	9	@ !c'A5//1 	1r8   c                    > [        U[        5      (       a  UR                  5       n[        U5      nSSUS-  -   -  n[        TU ]  X4S9$ )NrU  :0yE>rW   r  r  )rE   rF   r  r   r  s       r6   r  gamma_gen._fitstart1  sN     dL))>>#D4[Aw D 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                   >^ UR                  SS 5      nUR                  SS5      n[        U[        5      (       d  Uc(  UR                  5       S:w  a  [        TU ]  " U/UQ70 UD6$ UR                  SS 5        [        U/ SQ5      nUR                  SS 5      n[        U5        Ub  Ub  Ub  [        S5      e[        R                  " U5      n[        R                  " U5      R                  5       (       d  [        S5      eUR                  5       S:X  a  [        R                  " U5      n[        R                  " U5      n	[        R                  " X-
  S	-  5      n
XdUpnUc  Uc  Uc  U
S
U	-  -  nUc  Uc  [        R                   " X-  5      nUc
  Uc  XU-
  -  nUc
  Uc  XS
-  -  nUc  X-
  U-  nUc  XU-  -
  nUc  X-
  U-  nXU4$ [        R"                  " X:*  5      (       a  [%        SU[        R&                  S9eUS:w  a  X-
  nUR                  5       nUc  Ub  UnO[        R(                  " U5      [        R(                  " U5      R                  5       -
  mS	T-
  [        R                   " TS	-
  S
-  ST-  -   5      -   ST-  -  nUS-  nUS-  n[*        R,                  " U4S jUUSS9nX-  nOH[        R(                  " U5      R                  5       [        R(                  " U5      -
  n[/        U5      nUnXU4$ )Nr  r1   r;   r<   r  r  r  r   r  rW   r(  r  r   rr  r  g333333?gffffff?c                 d   > [         R                  " U 5      [        R                  " U 5      -
  T-
  $ rO   )rQ   r  r~   rk  )r   ro  s    r6   r:  gamma_gen.fit.<locals>.<lambda>  s    bffQi"**Q-.G!.Kr8   )disp)r=   r?   r*   r>   rA   rC   r3   r   r7   r!  rQ   r"  r#  r$  r%  r  r&  r  r  rm   r  r   brentqr  )rE   rF   rG   r5   r  r1   r  r  m1m2m3r   r.   r/   r  aestxar  ra  ro  r  s                      @r6   rC   gamma_gen.fit=  s    xx%(E*t\**4!7 7;t3d3d33 	!$(=>(D)$T*>d.63E  ) * * zz${{4 $$&&CDD <<>T!BB$))*BfEAyS[U]a"f{u}yU]3hyS[1*%yX&{u9n}Q5= 
 66$,wd"&&AA19 ;Dyy{ >~ FF4L266$<#4#4#66!bggqsQhAo662a4@5\5\OO$K$&4
 HE
 t!!#bffVn4AAAE~r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r+  r  r  r	   r   rC   r   r  r   s   @r6   r  r    sh    'PE4*6!"$%+1 
2 } 5 eer8   r  r(  c                   X   ^  \ rS rSrSrS rS rU 4S jr\" \	SS9U 4S j5       r
S	rU =r$ )

erlang_geni  a  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                     [         R                  " [         R                  " U5      U:H  5      nU(       d!  SU< S3n[        R                  " U[
        SS9  US:  $ )NzRThe shape parameter of the erlang distribution has been given a non-integer value r2   r  
stacklevelr   )rQ   r$  floorwarningswarnRuntimeWarning)rE   r   allintmessages       r6   rf   erlang_gen._argcheck  sM    q()==>EDGMM'>a@1ur8   c                 @    [        SSS[        R                  4S5      /$ )Nr   Tr   rk   rl   rn   s    r6   ro   erlang_gen._shape_info  rq   r8   c                    > [        U[        5      (       a  UR                  5       n[        SS[	        U5      S-  -   -  5      n[
        [        U ]  X4S9$ )Nr  r  rW   r  )r?   r*   r  r*  r   rA   r  r  )rE   rF   r   r  s      r6   r  erlang_gen._fitstart  sQ     dL))>>#DteDk1n,-.Y/4/@@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U ]  " U/UQ70 UD6$ rO   )rA   rC   rE   rF   rG   r5   r  s       r6   rC   erlang_gen.fit  s     w{4/$/$//r8   r   )r   r   r   r   r   rf   ro   r  r	   r   rC   r   r  r   s   @r6   r  r    s9    &CA } 5/ 0000r8   r  erlangc                   ^    \ rS rSrSrS rS rS rS rS r	SS	 jr
S
 rS rS rS rS rSrg)gengamma_geni  aq  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                     US:  US:g  -  $ r  r   )rE   r   ra  s      r6   rf   gengamma_gen._argcheck	  s    A!q&!!r8   c                     [        SSS[        R                  4S5      n[        SS[        R                  * [        R                  4S5      nX/$ r  rl   r  s      r6   ro   gengamma_gen._shape_info  @    UQK@UbffWbff$5~Fxr8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  r  s       r6   rw   gengamma_gen._pdf      vvdll1+,,r8   c                 V   ^ [        US:g  US:  -  X4U4S j[        R                  * S9$ )Nr   c                    > [         R                  " [        U5      5      [        R                  " UT-  S-
  U 5      -   X-  -
  [        R
                  " T5      -
  $ ra   )rQ   r  r  r~   r  r  )rv   ra  r   s     r6   r:  &gengamma_gen._logpdf.<locals>.<lambda>  sC    s1v!A#'19M(M*+$)/13A)?r8   rX  rZ  r  s     ` r6   r   gengamma_gen._logpdf  s2    16a!e,qf@%'VVG- 	-r8   c                     X-  n[         R                  " X$5      n[         R                  " X$5      n[        R                  " US:  XV5      $ r  r~   rS  rW  rQ   r  rE   rv   r   ra  xcval1val2s          r6   r{   gengamma_gen._cdf  :    T{{1!||A"xxAt**r8   Nc                 0    UR                  XS9nUSU-  -  $ )Nr  r   r  )rE   r   ra  r   r   rL  s         r6   r   gengamma_gen._rvs   s#    '''52a4yr8   c                     X-  n[         R                  " X$5      n[         R                  " X$5      n[        R                  " US:  Xe5      $ r  r  r  s          r6   r   gengamma_gen._sf$  r  r8   c                     [         R                  " X!5      n[         R                  " X!5      n[        R                  " US:  XE5      SU-  -  $ r7  r~   r\  ra  rQ   r  rE   r   r   ra  r  r  s         r6   r   gengamma_gen._ppf*  <    ~~a#q$xxAt*SU33r8   c                     [         R                  " X!5      n[         R                  " X!5      n[        R                  " US:  XT5      SU-  -  $ r7  r  r  s         r6   r   gengamma_gen._isf/  r  r8   c                 :    [         R                  " X!S-  U-  5      $ r>  r  )rE   re   r   ra  s       r6   r+  gengamma_gen._munp4  s    wwqC%'""r8   c                 0    S nS n[        US:  X4XCS9nU$ )Nc                     [         R                  " U 5      nU SU-
  -  X!-  -   n[         R                  " U 5      [        R                  " [        U5      5      -
  nX4-   nU$ ra   )r~   r  r  rQ   r  r  )r   ra  r  ABr  s         r6   r  &gengamma_gen._entropy.<locals>.regular9  sM    &&)CQW'A

1s1v.AAHr8   c                 B   [         R                  5       [        R                  " U 5      S-  -
  [        R                  " [        R                  " U5      5      -
  U S-  S-  -   U S-  S-  -
  [        R                  " U 5      U S-  S-  -
  U S-  S-  -
  U S-  S	-  -   U-  -   $ )
NrW   r  r  r  r  r  r  r   r  )r.  r  rQ   r  r  )r   ra  s     r6   
asymptotic)gengamma_gen._entropy.<locals>.asymptotic@  s    MMObffQik1ffRVVAY'(+,c61*5893{CvvayAsFA:-C;q#vslJAMN Or8         i@r  r@  )rE   r   ra  r  r	  r  s         r6   r  gengamma_gen._entropy8  s(    		O qCx!:Br8   r   r-  )r   r   r   r   r   rf   ro   rw   r   r{   r   r   r   r   r+  r  r   r   r8   r6   r  r    s>    >"
--++4
4
#r8   r  gengammac                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)genhalflogistic_geniM  au  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   genhalflogistic_gen._shape_infoc  r5  r8   c                 $    U R                   SU-  4$ r>  r  r  s     r6   r    genhalflogistic_gen._get_supportf  s    vvs1u}r8   c                 t    SU-  n[         R                  " SX!-  -
  5      nXCS-
  -  nXT-  nSU-  SU-   S-  -  $ r  rQ   r"  )rE   rv   ra  limitr  tmp0tmp2s          r6   rw   genhalflogistic_gen._pdfi  sJ     Ajj131W~xv4!##r8   c                 `    SU-  n[         R                  " SX!-  -
  5      nXC-  nSU-
  SU-   -  $ r  r  )rE   rv   ra  r  r  r  s         r6   r{   genhalflogistic_gen._cdfr  s9    Ajj13|DQtV$$r8   c                 0    SU-  SSU-
  SU-   -  U-  -
  -  $ r  r   rl  s      r6   r   genhalflogistic_gen._ppfx  s'    1ua#a%#a%1,,--r8   c                 F    SSU-  S-   [         R                  " S5      -  -
  $ r  rg  r  s     r6   r  genhalflogistic_gen._entropy{  s"    AaCE266!9$$$r8   r   N)r   r   r   r   r   ro   r   rw   r{   r   r  r   r   r8   r6   r  r  M  s&    *E$%.%r8   r  genhalflogisticc                   |   ^  \ rS rSrSrS rS rU 4S jrS rS r	S \
S	 5       5       rS
 rS rSS jrS rSrU =r$ )genhyperbolic_geni  u	  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                     [         R                  " [         R                  " U5      U:  US:  5      [         R                  " [         R                  " U5      U:*  US:  5      -  $ r  )rQ   logical_andr  )rE   rK  r   r   s       r6   rf   genhyperbolic_gen._argcheck  sH    rvvay1}a1f5..aQ78 	9r8   c                     [        SS[        R                  * [        R                  4S5      n[        SSS[        R                  4S5      n[        SS[        R                  * [        R                  4S5      nXU/$ )NrK  Fr3  r   r   rk   r   rl   )rE   ipr  r  s       r6   ro   genhyperbolic_gen._shape_info  sb    UbffWbff$5~FUQK?UbffWbff$5~F|r8   c                     > [         TU ]  USS9$ )N)r   r   r   r  ry  rz  s     r6   r  genhyperbolic_gen._fitstart  s     w K 88r8   c                 @    [         R                  S 5       nU" XX45      $ )Nc                 0    [         R                  " XX#5      $ rO   )r   genhyperbolic_logpdfrv   rK  r   r   s       r6   _logpdf_single1genhyperbolic_gen._logpdf.<locals>._logpdf_single  s    ..qQ::r8   rQ   	vectorize)rE   rv   rK  r   r   r/  s         r6   r   genhyperbolic_gen._logpdf  s)     
	; 
	; aA))r8   c                 @    [         R                  S 5       nU" XX45      $ )Nc                 0    [         R                  " XX#5      $ rO   )r   genhyperbolic_pdfr.  s       r6   _pdf_single+genhyperbolic_gen._pdf.<locals>._pdf_single  s    ++A!77r8   r1  )rE   rv   rK  r   r   r7  s         r6   rw   genhyperbolic_gen._pdf  s)     
	8 
	8 1&&r8   c                 J    [         R                  " U [         R                  /S9$ )NotypesrQ   r2  float64)r  s    r6   r:  genhyperbolic_gen.<lambda>   s    ",,tRZZL9r8   c           	         [         R                  " X#U/[        5      R                  R	                  [        R
                  5      n[        R                  " [        SU5      n[         R                  " X4-   X4-
  -  5      nXG-  [        R                  " US-   U5      -  [        R                  " X'5      -  nSn	Sn
Xs=:  a  U:  a7  O  O4[        R                  " X`UXS9S   [        R                  " XhUXS9S   -   nO[        R                  " X`UXS9S   n[         R                  " U5      (       a  Sn[        R                   " U["        SS9  [%        S	['        S
U5      5      $ )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  r  r   r   )rQ   arrayr  ctypesdata_asc_void_pr   from_cythonr   r&  r~   kvr   quadisnanr  r  r  maxrg  )r  r  rK  r   r   	user_datallcr  r%  rB  rC  intgrlr[   s                r6   _integrate_pdf genhyperbolic_gen._integrate_pdf   s5    HHaAY.55==fooN	**63G+46GGQUQUO$sRUU1q5!_$ruuQ{2>r>  nnSd,2CCDF!s".4EEFHHF
 ^^CR+1BBCEF88FHCMM#~!<3C())r8   c                 F    U R                  [        R                  * XX45      $ rO   rP  rQ   rm   rE   rv   rK  r   r   s        r6   r{   genhyperbolic_gen._cdf"  s    ""BFF7A!77r8   c                 F    U R                  U[        R                  X#U5      $ rO   rS  rT  s        r6   r   genhyperbolic_gen._sf%  s    ""1bffaA66r8   c                 L   [         R                  " US5      [         R                  " US5      -
  n[         R                  " US5      n[         R                  " US5      n[        R                  UUUUUS9n	[        R                  XES9n
X9-  [         R
                  " U	5      U
-  -   $ )NrW   r   r:  )rK  r   r/   r   r   r'  )rQ   float_powergeninvgaussr)  r.  r&  )rE   rK  r   r   r   r   r  r  r  gignormsts              r6   r   genhyperbolic_gen._rvs(  s    
 ^^Aq!BNN1a$88^^B$^^B&oo%   t?w...r8   c                   ^ [         R                  " XU5      u  pn[         R                  " US5      [         R                  " US5      -
  n[         R                  " US5      n[         R                  " SS5      [         R                  " US5      -  n[         R                  " SSS5      nUR	                  UR
                  SUR                  -  -   5      n[        R                  " X-   U5      u  mpxpU4S	 jXxX4 5       u  ppX5-  U-  nX[-  [         R                  " US5      [         R                  " US5      -  U[         R                  " US5      -
  -  -   n[         R                  " US
5      [         R                  " US
5      -  US
U-  U-  [         R                  " TS5      -  -
  S[         R                  " US
5      -  -   -  S
U-  [         R                  " US5      -  U[         R                  " US5      -
  -  -   nU[         R                  " US5      -  n[         R                  " US5      [         R                  " US5      -  USU	-  U-  [         R                  " TS5      -  -
  SU-  [         R                  " US5      -  [         R                  " TS5      -  -   S
[         R                  " US5      -  -
  -  [         R                  " US5      [         R                  " US
5      -  SU-  SU-  U-  [         R                  " TS5      -  -
  S[         R                  " US
5      -  -   -  -   S
[         R                  " US5      -  U-  -   nU[         R                  " US5      -  S
-
  nUUUU4$ )NrW   r   r   r  r   rU  r  )r   c              3   ,   >#    U  H	  oT-  v   M     g 7frO   r   ).0r   b0s     r6   	<genexpr>+genhyperbolic_gen._stats.<locals>.<genexpr>I  s     ;*:Qb&*:s   r  r;  r{  r  rp  r  )	rQ   rH  rY  linspacer  shaper  r~   rI  )rE   rK  r   r   r  r  integersb1b2b3b4r1r2r3r4r  r  m3ero  m4erq  ra  s                        @r6   r   genhyperbolic_gen._stats=  s    %%aA.a^^Aq!BNN1a$88^^B$^^Aq!BNN2s$;;;;q!Q'##HNNTAFF]$BCUU1<4BB;22*:;FRKGbnnQ*R^^B-BB"..Q'') ) 	

 NN1a 2>>"a#88!b&2+r2 666A&&'( EBNN2q))"..Q'')) 	 "..G,,NN1a 2>>"a#88!b&2+r3 777VbnnR++bnnR.EEFA&&'( NN1a 2>>"a#88Vb2glR^^B%<<<A&&'(	( r1%%*+ 	 "..B''!+!Qzr8   r   r-  )r   r   r   r   r   rf   ro   r  r   rw   staticmethodrP  r{   r   r   r   r   r  r   s   @r6   r"  r"    sY    Wr99
*' :*  :*@87/*' 'r8   r"  genhyperbolicc                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)gompertz_genij  aE  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   gompertz_gen._shape_info  r5  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  re  s      r6   rw   gompertz_gen._pdf  r  r8   c                 h    [         R                  " U5      U-   U[        R                  " U5      -  -
  $ rO   r"  re  s      r6   r   gompertz_gen._logpdf  s%    vvay1}q288A;..r8   c                 `    [         R                  " U* [         R                  " U5      -  5      * $ rO   rR  re  s      r6   r{   gompertz_gen._cdf  s#    !bhhqk)***r8   c                 d    [         R                  " SU-  [         R                  " U* 5      -  5      $ r  rd  rl  s      r6   r   gompertz_gen._ppf  s$    xxq288QB</00r8   c                 ^    [         R                  " U* [        R                  " U5      -  5      $ rO   r  re  s      r6   r   gompertz_gen._sf  s     vvqb288A;&''r8   c                 ^    [         R                  " [        R                  " U5      * U-  5      $ rO   r  rE   rK  ra  s      r6   r   gompertz_gen._isf  s    xx
1%%r8   c                 z    S[         R                  " U5      -
  [        R                  R	                  U5      U-  -
  $ r>  )rQ   r  r~   _ufuncs_scaled_exp1r  s     r6   r  gompertz_gen._entropy  s-    RVVAY!8!8!;A!===r8   r   Nr   r   r   r   r   ro   rw   r   r{   r   r   r   r  r   r   r8   r6   ru  ru  j  s0    *E*/+1(&>r8   ru  gompertzc                     [         R                  " U 5      n [         R                  " U5      nUR                  5       n[         R                  " X-
  5      n[         R                  " XS9$ )N)weights)rQ   r"  rL  r   average)rv   
logweightsmaxlogwr  s       r6   _average_with_log_weightsr    sI    


1AJ'JnnGffZ)*G::a))r8   c                   z    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS r\\" \5      S 5       5       rSrg)gumbel_r_geni  a  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                     / $ rO   r   rn   s    r6   ro   gumbel_r_gen._shape_info  r   r8   c                 L    [         R                  " U R                  U5      5      $ rO   r.  r   s     r6   rw   gumbel_r_gen._pdf      vvdll1o&&r8   c                 8    U* [         R                  " U* 5      -
  $ rO   rL  r   s     r6   r   gumbel_r_gen._logpdf  s    rBFFA2Jr8   c                 Z    [         R                  " [         R                  " U* 5      * 5      $ rO   rL  r   s     r6   r{   gumbel_r_gen._cdf  s    vvrvvqbzk""r8   c                 2    [         R                  " U* 5      * $ rO   rL  r   s     r6   r  gumbel_r_gen._logcdf  s    r
{r8   c                 Z    [         R                  " [         R                  " U5      * 5      * $ rO   rg  r   s     r6   r   gumbel_r_gen._ppf  s    q	z"""r8   c                 \    [         R                  " [        R                  " U* 5      * 5      * $ rO   r  r   s     r6   r   gumbel_r_gen._sf  s     "&&!*%%%r8   c                 \    [         R                  " [         R                  " U* 5      * 5      * $ rO   rQ   r  r  r  s     r6   r   gumbel_r_gen._isf  s     !}%%%r8   c                     [         [        R                  [        R                  -  S-  S[        R                  " S5      -  [        R                  S-  -  [        -  S4$ )Nr_  r  r  r  r~  r$   rQ   r  r&  r%   rn   s    r6   r   gumbel_r_gen._stats  s?    ruuRUU{32771:beeQh(>(GOOr8   c                     [         S-   $ r>  r  rn   s    r6   r  gumbel_r_gen._entropy  s    {r8   c                   ^^^ [        U TX#5      u  mpEU4S jnUb  UnU" U5      mTU4$ Ub
  UmUU4S jmOU4S jmUR                  SS5      nUS-  US-  pU4S jnU" X5      (       dO  U	S:  d  U
[        R                  :  a5  U	S-  n	U
S-  n
U" X5      (       d  U	S:  a  M  U
[        R                  :  a  M5  [        R
                  " TX4S	S	S
9nUR                  nUb  UOU" U5      mTU4$ )Nc                    > U * [         R                  " T* U -  5      [        R                  " [	        T5      5      -
  -  $ rO   )r~   r	  rQ   r  r  )r/   rF   s    r6   get_loc_from_scale,gumbel_r_gen.fit.<locals>.get_loc_from_scale  s1    6R\\4%%-8266#d);LLMMr8   c                    > TT-
  [         R                  " TT-
  U -  5      -  T-   n[        T5      TU -   -  nUR                  5       U-
  $ rO   )rQ   r   r  r  )r/   term1term2rF   r.   s      r6   r  gumbel_r_gen.fit.<locals>.func  sK     4Z2663:2F+GG$NEIu5E 99;..r8   c                 P   > T* U -  n[        TUS9nTR                  5       U-
  U -
  $ )N)r  )r  r%  )r/   sdatawavgrF   s      r6   r  r    s0    !EEME4TeLD99;-55r8   r/   r   rW   c                 v   > [         R                  " T" U 5      5      [         R                  " T" U5      5      :g  $ rO   rP   )rS   rT   r  s     r6   rU   0gumbel_r_gen.fit.<locals>.interval_contains_root  s-    V-V-. /r8   r   rj  )rh  rtolr  )rj  r=   rQ   rm   r   r+   rk  )rE   rF   rG   r5   r  r  r  r/   brack_startrS   rT   rU   resr  r.   s    `           @@r6   rC   gumbel_r_gen.fit  s    9t9=Ed	N  E$U+C\ EzU /6 ((7A.K(1_kAoF
/ .f==
frvvo!! .f==
frvvo &&tf5E,1?CHHE*$0B50ICEzr8   r   N)r   r   r   r   r   ro   rw   r   r{   r  r   r   r   r   r  rL   r   r   rC   r   r   r8   r6   r  r    s]    6'##&&P M*@ + @r8   r  gumbel_rc                   z    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS r\\" \5      S 5       5       rSrg)gumbel_l_geni)  a  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                     / $ rO   r   rn   s    r6   ro   gumbel_l_gen._shape_infoF  r   r8   c                 L    [         R                  " U R                  U5      5      $ rO   r.  r   s     r6   rw   gumbel_l_gen._pdfI  r  r8   c                 4    U[         R                  " U5      -
  $ rO   rL  r   s     r6   r   gumbel_l_gen._logpdfM  r  r8   c                 Z    [         R                  " [        R                  " U5      * 5      * $ rO   r  r   s     r6   r{   gumbel_l_gen._cdfP  s    "&&)$$$r8   c                 Z    [         R                  " [        R                  " U* 5      * 5      $ rO   rQ   r  r~   r  r   s     r6   r   gumbel_l_gen._ppfS  s    vvrxx|m$$r8   c                 0    [         R                  " U5      * $ rO   rL  r   s     r6   r	  gumbel_l_gen._logsfV  r]  r8   c                 X    [         R                  " [         R                  " U5      * 5      $ rO   rL  r   s     r6   r   gumbel_l_gen._sfY      vvrvvayj!!r8   c                 X    [         R                  " [         R                  " U5      * 5      $ rO   rg  r   s     r6   r   gumbel_l_gen._isf\  r  r8   c                     [         * [        R                  [        R                  -  S-  S[        R                  " S5      -  [        R                  S-  -  [        -  S4$ )Nr_  r  r  r~  r  rn   s    r6   r   gumbel_l_gen._stats_  sF    wbeeC2771:~beeQh&/8 	8r8   c                     [         S-   $ r>  r  rn   s    r6   r  gumbel_l_gen._entropyc  s    {r8   c                     UR                  S5      b	  US   * US'   [        R                  " [        R                  " U5      * /UQ70 UD6u  pEU* U4$ )Nr  )r=   r  rC   rQ   r"  )rE   rF   rG   r5   loc_rscale_rs         r6   rC   gumbel_l_gen.fitf  sT     88F' L=DL",,

4(8'8H4H4Hvwr8   r   N)r   r   r   r   r   ro   rw   r   r{   r   r	  r   r   r   r  rL   r   r   rC   r   r   r8   r6   r  r  )  sZ    8'%%""8 M* + r8   r  gumbel_lc                      ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS r\\" \5      U 4S j5       5       rSrU =r$ )halfcauchy_geniz  zA 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                     / $ rO   r   rn   s    r6   ro   halfcauchy_gen._shape_info  r   r8   c                 8    S[         R                  -  SX-  -   -  $ r(  rc  r   s     r6   rw   halfcauchy_gen._pdf  s    255y#ac'""r8   c                     [         R                  " S[         R                  -  5      [        R                  " X-  5      -
  $ rv  rQ   r  r  r~   r  r   s     r6   r   halfcauchy_gen._logpdf  s(    vvc"%%i 288AC=00r8   c                 V    S[         R                  -  [         R                  " U5      -  $ rv  r  r   s     r6   r{   halfcauchy_gen._cdf  s    255y1%%r8   c                 V    [         R                  " [         R                  S-  U-  5      $ rD  rQ   tanr  r   s     r6   r   halfcauchy_gen._ppf  s    vvbeeAgai  r8   c                 X    S[         R                  -  [         R                  " SU5      -  $ Nr   r   )rQ   r  r  r   s     r6   r   halfcauchy_gen._sf  s     255y2::a+++r8   c                 \    S[         R                  " [         R                  U-  S-  5      -  $ r7  r  r  s     r6   r   halfcauchy_gen._isf  s"    266"%%'!)$$$r8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   rE  rn   s    r6   r   halfcauchy_gen._stats  r,  r8   c                 P    [         R                  " S[         R                  -  5      $ rD  r  rn   s    r6   r  halfcauchy_gen._entropy  r/  r8   c                   > UR                  SS5      (       a  [        T
U ]  " U/UQ70 UD6$ [        XX#5      u  pn[        R
                  " U5      nUb!  Xd:  a  [        SU[        R                  S9eUnOUnS nUb  Un	Xy4$ U" Xq5      n	Xy4$ )Nr\  F
halfcauchyr  c                    ^^ X-
  nUR                   m[        R                  " U5      mUU4S jn[        R                  " S5      R                  S-  n[        X4[        R                  " U5      4S9nUR                  $ )Nc                 R   > U S-  T-   nS[         R                  " TU-  5      -  T-
  $ rD  rQ   r  )r/   denominatorre   shifted_data_squareds     r6   fun_to_solve<halfcauchy_gen.fit.<locals>.find_scale.<locals>.fun_to_solve  s1    #Qh)==266"6{"BCCaGGr8   r   r   rh  )r   rQ   squarefinfotinyr+   rL  rk  )r.   rF   shifted_datar  smallr  re   r  s         @@r6   
find_scale&halfcauchy_gen.fit.<locals>.find_scale  sc    :L		A#%99\#: H HHSM&&+ElBFF<<P4QRC88Or8   r3   rA   rC   rj  rQ   rg  r  rm   )rE   rF   rG   r5   r  r  rh  r.   r  r/   r  s             r6   rC   halfcauchy_gen.fit  s     88J&&7;t3d3d3389=EF 66$<"<t266JJC C	 E z s)Ezr8   r   )r   r   r   r   r   ro   rw   r   r{   r   r   r   r   r  rL   r   r   rC   r   r  r   s   @r6   r  r  z  sV    &#1&!,%. M*% + %r8   r  r  c                      ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS r\\" \5      U 4S j5       5       rSrU =r$ )halflogistic_geni  a  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                     / $ rO   r   rn   s    r6   ro   halflogistic_gen._shape_info  r   r8   c                 L    [         R                  " U R                  U5      5      $ rO   r.  r   s     r6   rw   halflogistic_gen._pdf  s     vvdll1o&&r8   c                     [         R                  " S5      U-
  S[        R                  " [         R                  " U* 5      5      -  -
  $ r   )rQ   r  r~   r  r   r   s     r6   r   halflogistic_gen._logpdf  s1    vvay1}rBHHRVVQBZ$8888r8   c                 4    [         R                  " US-  5      $ rv  )rQ   tanhr   s     r6   r{   halflogistic_gen._cdf  s    wwqu~r8   c                 4    S[         R                  " U5      -  $ rD  rQ   arctanhr   s     r6   r   halflogistic_gen._ppf  s    Ar8   c                 6    S[         R                  " U* 5      -  $ rD  r~   expitr   s     r6   r   halflogistic_gen._sf  s    288QB<r8   c                 &    [        US:  U4S S S9$ )Nr   c                 6    [         R                  " SU -  5      * $ r  r~   logitr   s    r6   r:  'halflogistic_gen._isf.<locals>.<lambda>  s    RXXcAg%6$6r8   c                 :    S[         R                  " SU -
  5      -  $ r  r  r   s    r6   r:  r    s    qAE):':r8   r>  r@  r   s     r6   r   halflogistic_gen._isf  s    !c'A56:< 	<r8   c                    US:X  a  gUS:X  a  S[         R                  " S5      -  $ US:X  a$  [         R                  [         R                  -  S-  $ US:X  a	  S[        -  $ US:X  a  S[         R                  S-  -  S	-  $ SS[	        S
SU-
  5      -
  -  [
        R                  " US-   5      -  [
        R                  " US5      -  $ )Nr   r   rW   r  r  rp  rU  r  r  r   )rQ   r  r  r%   r  r~   r(  r  rd   s     r6   r+  halflogistic_gen._munp
  s    66RVVAY;655;s?"6V8O6RUUAX:$$!CQqSM/"288AaC=0A>>r8   c                 4    S[         R                  " S5      -
  $ rD  rg  rn   s    r6   r  halflogistic_gen._entropy  ri  r8   c                   > UR                  SS5      (       a  [        T
U ]  " U/UQ70 UD6$ [        XX#5      u  pnS n[        R
                  " U5      nUb!  Xt:  a  [        SU[        R                  S9eUnOUnUb  UOU" X5      n	X4$ )Nr\  Fc                    U R                   S   n[        R                  " U SS9n[        R                  " SUS-   5      US-   -  nSU-
  nSU-   nUSU-  U-  [        R                  " Xe-  5      -  -
  nSU-  U-  nX1-
  nS[        R
                  " USS  USS  -  5      -  n	S[        R
                  " USS  USS  S-  -  5      -  n
U	[        R                  " U	S-  SU-  U
-  -   5      -   SU-  -  nSnSnUR                  5       nX:  aP  U[        R                  " U* U-  5      -  nUSU-  UR                  5       -  -
  n[        UU-
  U-  5      nUnX:  a  MP  U$ )	Nr   rR  r   r   rW   rb  rU  r  )re  rQ   sortr  r  r  r&  r%  r~   r  r  )rF   r.   n_observationssorted_datarK  r   pp1rK  r  r  Cr/   r  relative_residualshifted_meansum_term	scale_news                    r6   r  (halflogistic_gen.fit.<locals>.find_scale#  s    "ZZ]N''$Q/K		!^a/0.12DEAAAa%Ca#sw77E7S=D%+KBFF59{12677ABFF48k!"oq&8899A"''!Q$^);a)?"?@@.(*E D !&++-L $*&;,u2D)EE(1^+;hlln+LL	$'):E(A$B!!	 $*
 Lr8   halflogisticr  r  )rE   rF   rG   r5   r  r  r  rh  r.   r/   r  s             r6   rC   halflogistic_gen.fit  s     88J&&7;t3d3d3389=EF	D 66$<">RVVLLC C !,*T2Gzr8   r   )r   r   r   r   r   ro   rw   r   r{   r   r   r   r+  r  rL   r   r   rC   r   r  r   s   @r6   r  r    sV    2'
9 <
? M*6 + 6r8   r  r/  c                      ^  \ rS rSrSrS rSS jrS rS rS r	S r
S	 rS
 rS rS r\\" \5      U 4S j5       5       rSrU =r$ )halfnorm_geniX  a  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                     / $ rO   r   rn   s    r6   ro   halfnorm_gen._shape_infon  r   r8   c                 2    [        UR                  US95      $ r  r/  r   s      r6   r   halfnorm_gen._rvsq  s    <//T/:;;r8   c                     [         R                  " S[         R                  -  5      [         R                  " U* U-  S-  5      -  $ rv  rQ   r&  r  r   r   s     r6   rw   halfnorm_gen._pdft  s1    wws255y!"&&!Ac"222r8   c                 f    S[         R                  " S[         R                  -  5      -  X-  S-  -
  $ Nr   r   r  r   s     r6   r   halfnorm_gen._logpdfx  s)    RVVCI&&S00r8   c                 \    [         R                  " U[        R                  " S5      -  5      $ rD  r~   r4  rQ   r&  r   s     r6   r{   halfnorm_gen._cdf{  s    vva"''!*n%%r8   c                 $    [        SU-   S-  5      $ rw  r   r   s     r6   r   halfnorm_gen._ppf~  s    !A#s##r8   c                     S[        U5      -  $ rD  r  r   s     r6   r   halfnorm_gen._sf  s    8A;r8   c                     [        US-  5      $ rD  r  r  s     r6   r   halfnorm_gen._isf  s    1~r8   c                 T   [         R                  " S[         R                  -  5      SS[         R                  -  -
  [         R                  " S5      S[         R                  -
  -  [         R                  S-
  S-  -  S[         R                  S-
  -  [         R                  S-
  S-  -  4$ )Nr   r   rW   rU  rd  rb  r  rQ   r&  r  rn   s    r6   r   halfnorm_gen._stats  sx    BEE	"#bee)
AbeeG$beeAg^32557RUU1WqL(* 	*r8   c                 \    S[         R                  " [         R                  S-  5      -  S-   $ r;  r  rn   s    r6   r  halfnorm_gen._entropy  s#    266"%%)$$S((r8   c                 8  > UR                  SS5      (       a  [        T	U ]  " U/UQ70 UD6$ [        XX#5      u  pn[        R
                  " U5      nUb!  Xd:  a  [        SU[        R                  S9eUnOUnUb  UnXx4$ [        R                  " USUS9S-  nXx4$ )Nr\  Fhalfnormr  rW   )ordercenterr   )
r3   rA   rC   rj  rQ   rg  r  rm   rI  moment)
rE   rF   rG   r5   r  r  rh  r.   r/   r  s
            r6   rC   halfnorm_gen.fit  s     88J&&7;t3d3d3389=EF 66$<":THHCCE z LLQs;S@Ezr8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r  rL   r   r   rC   r   r  r   s   @r6   r2  r2  X  s[    *<31&$*) M* + r8   r2  rL  c                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)hypsecant_geni  zA 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                     / $ rO   r   rn   s    r6   ro   hypsecant_gen._shape_info  r   r8   c                 V    S[         R                  [         R                  " U5      -  -  $ r>  )rQ   r  coshr   s     r6   rw   hypsecant_gen._pdf  s    BEE"''!*$%%r8   c                 ~    S[         R                  -  [         R                  " [         R                  " U5      5      -  $ rv  rQ   r  r  r   r   s     r6   r{   hypsecant_gen._cdf  s&    255y266!9---r8   c                 ~    [         R                  " [         R                  " [         R                  U-  S-  5      5      $ rv  rQ   r  r  r  r   s     r6   r   hypsecant_gen._ppf  s&    vvbffRUU1WS[)**r8   c                     S[         R                  -  [         R                  " [         R                  " U* 5      5      -  $ rv  rY  r   s     r6   r   hypsecant_gen._sf  s(    255y2661":...r8   c                     [         R                  " [         R                  " [         R                  U-  S-  5      5      * $ rv  r\  r   s     r6   r   hypsecant_gen._isf  s)    rvvbeeAgck*+++r8   c                 R    S[         R                  [         R                  -  S-  SS4$ )Nr   rU  rW   rc  rn   s    r6   r   hypsecant_gen._stats  s!    "%%+a-A%%r8   c                 P    [         R                  " S[         R                  -  5      $ rD  r  rn   s    r6   r  hypsecant_gen._entropy  r/  r8   r   N)r   r   r   r   r   ro   rw   r{   r   r   r   r   r  r   r   r8   r6   rR  rR    s/    &&.+/,&r8   rR  	hypsecantc                   0    \ rS rSrSrS rS rS rS rSr	g)	gausshyper_geni  a  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                 .    US:  US:  -  X3:H  -  US:  -  $ )Nr   r  r   )rE   r   r   ra  r  s        r6   rf   gausshyper_gen._argcheck   s%    A!a% AF+q2v66r8   c                    [        SSS[        R                  4S5      n[        SSS[        R                  4S5      n[        SS[        R                  * [        R                  4S5      n[        SSS[        R                  4S5      nXX4/$ )	Nr   Fr   r3  r   ra  r  r  rl   )rE   r  r  r  izs        r6   ro   gausshyper_gen._shape_info  st    UQK@UQK@UbffWbff$5~FURL.Ar8   c                     [         R                  " X#5      [         R                  " XBX#-   U* 5      -  nSU-  XS-
  -  -  SU-
  US-
  -  -  SXQ-  -   U-  -  $ r>  r~   r  hyp2f1)rE   rv   r   r   ra  r  normalization_constants          r6   rw   gausshyper_gen._pdf  sc    !#11K!K))ABK726QW:MM9q.! 	"r8   c                     [         R                  " X-   U5      [         R                  " X#5      -  n[         R                  " XBU-   X#-   U-   U* 5      n[         R                  " XBX#-   U* 5      nXg-  U-  $ rO   ro  )	rE   re   r   r   ra  r  r  ra  r  s	            r6   r+  gausshyper_gen._munp  s`    ggac1o-iiQ3Ar*iiacA2&w}r8   r   N)
r   r   r   r   r   rf   ro   rw   r+  r   r   r8   r6   rh  rh    s    @7 "
r8   rh  
gausshyperc                   j    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rSS
 jrS rSrg)invgamma_geni  a  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                 @    [        SSS[        R                  4S5      /$ r2  rl   rn   s    r6   ro   invgamma_gen._shape_info:  r5  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  r8  s      r6   rw   invgamma_gen._pdf=  r  r8   c                 v    US-   * [         R                  " U5      -  [        R                  " U5      -
  SU-  -
  $ r  rQ   r  r~   r  r8  s      r6   r   invgamma_gen._logpdfA  s1    1vq	!BJJqM1CE99r8   c                 6    [         R                  " USU-  5      $ r>  rV  r8  s      r6   r{   invgamma_gen._cdfD  s    ||AsQw''r8   c                 4    S[         R                  " X!5      -  $ r>  r  rA  s      r6   r   invgamma_gen._ppfG  s    R__Q***r8   c                 6    [         R                  " USU-  5      $ r>  rR  r8  s      r6   r   invgamma_gen._sfJ  s    {{1cAg&&r8   c                 4    S[         R                  " X!5      -  $ r>  r  rA  s      r6   r   invgamma_gen._isfM  s    R^^A)))r8   c                 2   [        US:  U4S [        R                  5      n[        US:  U4S [        R                  5      nSu  pVSU;   a!  [        US:  U4S [        R                  5      nS	U;   a!  [        US
:  U4S [        R                  5      nX4XV4$ )Nr   c                     SU S-
  -  $ r>  r   r   s    r6   r:  %invgamma_gen._stats.<locals>.<lambda>Q  s    rQV}r8   rW   c                 $    SU S-
  S-  -  U S-
  -  $ )Nr   rW   r   r   r   s    r6   r:  r  R  s    rQVaK/?1r6/Jr8   r-  ro  r  c                 F    S[         R                  " U S-
  5      -  U S-
  -  $ )Nr  r   r  r  r   s    r6   r:  r  Y  s    "rwwq2v.!b&9r8   rq  rU  c                 0    SSU -  S-
  -  U S-
  -  U S-
  -  $ )Nr_  r  g      &@r  r  r   r   s    r6   r:  r  ]  s#    "Q-R8AFCr8   r  )rE   r   rt  r  r  r  r  s          r6   r   invgamma_gen._statsP  s    At%<bffEAt%J  '>At9266CB '>AtCRVVMB r~r8   c                 0    S nS n[        US:  U4X2S9nU$ )Nc                 p    X S-   [         R                  " U 5      -  -
  [         R                  " U 5      -   nU$ r>  r  r   r  s     r6   r  &invgamma_gen._entropy.<locals>.regulara  s-    Wq	))BJJqM9AHr8   c                    SS[         R                  " U 5      -  -
  [         R                  " S5      -   [         R                  " [         R                  5      -   S-  SU S-  -  -   U S-  S-  -   U S-  S	-  -
  U S
-  S-  -
  nU$ )Nr   r  rW   UUUUUU?r  r  r  r  r  r   r  r  r  s     r6   r	  )invgamma_gen._entropy.<locals>.asymptotice  s     aq	k/BFF1I-ruu=q@q#v: !3r	*,-sF2I6893s
CAHr8   r  r  r@  )rE   r   r  r	  r  s        r6   r  invgamma_gen._entropy`  s'    		 qCx!@r8   r   Nmvsk)r   r   r   r   r   r   rI  rJ  ro   rw   r   r{   r   r   r   r   r  r   r   r8   r6   rw  rw    sB    : "44ME*:(+'* r8   rw  invgammac                      ^  \ rS rSrSr\R                  rS rSS jr	S r
S rS rS rS	 rS
 rU 4S jrU 4S jrS r\" \5      U 4S j5       rS rSrU =r$ )invgauss_genis  a  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                 @    [        SSS[        R                  4S5      /$ Nr}  Fr   r3  rl   rn   s    r6   ro   invgauss_gen._shape_info  rE  r8   c                 $    UR                  USUS9$ Nr   r  waldrE   r}  r   r   s       r6   r   invgauss_gen._rvs  s      St 44r8   c                     S[         R                  " S[         R                  -  US-  -  5      -  [         R                  " SSU-  -  X-
  U-  S-  -  5      -  $ )Nr   rW   r  r  r8  rE   rv   r}  s      r6   rw   invgauss_gen._pdf  sM     2771RUU71c6>**266$!*qtRi!^2K+LLLr8   c                     S[         R                  " S[         R                  -  5      -  S[         R                  " U5      -  -
  X-
  U-  S-  SU-  -  -
  $ )Nr:  rW   rd  r  r  s      r6   r   invgauss_gen._logpdf  sF    BFF1RUU7O#c"&&)m3by1nac6JJJr8   c                     S[         R                  " U5      -  n[        X1U-  S-
  -  5      nSU-  [        U* X-  S-   -  5      -   nU[         R                  " [         R                  " XT-
  5      5      -   $ rf  )rQ   r&  r   r  r   rE   rv   r}  r  r   r   s         r6   r  invgauss_gen._logcdf  sf    "''!*nR1-.F\3$16Q,"788288BFF15M***r8   c                     S[         R                  " U5      -  n[        X1U-  S-
  -  5      nSU-  [        U* X-   -  U-  5      -   nU[         R                  " [         R
                  " XT-
  5      * 5      -   $ rf  )rQ   r&  r   r   r  r   r  s         r6   r	  invgauss_gen._logsf  sh    "''!*nB!|,-F\3$!&/B"677288RVVAE]N+++r8   c                 L    [         R                  " U R                  X5      5      $ rO   r  r  s      r6   r   invgauss_gen._sf  s    vvdkk!())r8   c                 L    [         R                  " U R                  X5      5      $ rO   r  r  s      r6   r{   invgauss_gen._cdf      vvdll1)**r8   c                   > [         R                  " SSSS9   [         R                  " X5      u  p[         R                  " [        R
                  " XS5      5      nUS:  n[        R                  " SX   -
  X$   S5      X4'   [         R                  " U5      n[        TU ]%  X   X%   5      X5'   S S S 5        U$ ! , (       d  f       W$ = fNrp  )rr  r  r  r   r   )
rQ   rs  rH  r"  rs   _invgauss_ppf_invgauss_isfrK  rA   r   )rE   rv   r}  ppfi_wti_nanr  s         r6   r   invgauss_gen._ppf  s    [[xJ''.EA**S..qa89Cs7D))!AG)RXqACIHHSMEah	:CJ K 
 KJ 
s   BB88
Cc                 l  > [         R                  " SSSS9   [         R                  " X5      u  p[        R                  " XS5      nUS:  n[        R
                  " SX   -
  X$   S5      X4'   [         R                  " U5      n[        TU ]!  X   X%   5      X5'   S S S 5        U$ ! , (       d  f       W$ = fr  )	rQ   rs  rH  rs   r  r  rK  rA   r   )rE   rv   r}  isfr  r  r  s         r6   r   invgauss_gen._isf  s    [[xJ''.EA##A1-Cs7D))!AG)RXqACIHHSMEah	:CJ K 
 KJ 
s   BB$$
B3c                 F    XS-  S[         R                  " U5      -  SU-  4$ )Nr  r  rr  r  )rE   r}  s     r6   r   invgauss_gen._stats  s#    s7AbggbkM2b500r8   c                 2  > UR                  SS5      n[        U[        5      (       d)  [        U [        5      (       d  UR	                  5       S:X  a  [
        T	U ]  " U/UQ70 UD6$ [        XX#5      u  ppg Ub  Ub  [
        T	U ]  " U/UQ70 UD6$ [        R                  " X-
  S:  5      (       a  [        SS[        R                  S9eX-
  n[        R                  " U5      nUc+  [        U5      [        R                  " US-  US-  -
  5      -  nX-  nXVU4$ )Nr1   r;   r<   r   invgaussr  r  )r=   r?   r*   wald_genr>   rA   rC   rj  rQ   r  r  rm   r%  r  r  )
rE   rF   rG   r5   r1   fshape_sr  r  fshape_nr  s
            r6   rC   invgauss_gen.fit  s
   (E*t\**jx.H.H<<>T)7;t3d3d33'B4CG(O$	 <8/7;t3d3d33VVDK!O$$z"&&AA;Dwwt}H~TbffTRZ(b.-H&IJ(Hv%%r8   c                     S[         R                  " S[         R                  -  5      -   S[         R                  " U5      -  -   nSU-  n[        R                  R                  U5      U-  nSU-  SU-  -
  $ )zF
Ref.: https://moser-isi.ethz.ch/docs/papers/smos-2012-10.pdf (eq. 9)
r   rW   r  r   rd  )rQ   r  r  r~   r  r  )rE   r}  r   rL  r   s        r6   r  invgauss_gen._entropy  sg     BEE	""Q^3 bDJJ##A&q(Qwq  r8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r   r  r	  r   r{   r   r   r   r   rC   r  r   r  r   s   @r6   r  r  s  st    (R "44MF5M
K+,*+1 M*& +&B! !r8   r  r  c                   X    \ rS rSrSrS rS rS rS rS r	S r
SS
 jrS rS rS rSrg	)geninvgauss_geni  a  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                     X:H  US:  -  $ r  r   rE   rK  r   s      r6   rf   geninvgauss_gen._argcheck2  s    1q5!!r8   c                     [        SS[        R                  * [        R                  4S5      n[        SSS[        R                  4S5      nX/$ )NrK  Fr3  r   r   rl   )rE   r'  r  s      r6   ro   geninvgauss_gen._shape_info5  @    UbffWbff$5~FUQK@xr8   c                     S n[         R                  " U[         R                  /S9nU" XU5      n[         R                  " U5      R	                  5       (       a  Sn[
        R                  " U[        SS9  U$ )Nc                 0    [         R                  " XU5      $ rO   )r   geninvgauss_logpdfrv   rK  r   s      r6   logpdf_single.geninvgauss_gen._logpdf.<locals>.logpdf_single>  s    ,,Q155r8   r;  zjInfinite values encountered in scipy.special.kve(p, b). Values replaced by NaN to avoid incorrect results.r  r  )rQ   r2  r>  rK  r  r  r  r  )rE   rv   rK  r   r  r  r[   s          r6   r   geninvgauss_gen._logpdf:  s]    	6 ]BJJ<H!"88A;??HCMM#~!<r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  rE   rv   rK  r   s       r6   rw   geninvgauss_gen._pdfJ  r0  r8   c                    ^ U R                  X#5      u  mnU4S jn[        R                  " U[        R                  /S9nU" XU5      $ )Nc                    > [         R                  " X/[        5      R                  R	                  [        R
                  5      n[        R                  " [        SU5      n[        R                  " UTU 5      S   $ )N_geninvgauss_pdfr   )rQ   rD  r  rE  rF  rG  r   rH  r   r   rJ  )rv   rK  r   rM  rN  r;  s        r6   _cdf_single)geninvgauss_gen._cdf.<locals>._cdf_singleQ  s\    !/66>>vOI"..v7I/8:C >>#r1-a00r8   r;  )r   rQ   r2  r>  )rE   rv   rK  r   r:  r  r;  s         @r6   r{   geninvgauss_gen._cdfN  sA    ""1(B	1 ll;

|D1##r8   c                 H    [        US:  XU4S [        R                  * 5      $ )Nr   c                 V    US-
  [         R                  " U 5      -  X SU -  -   -  S-  -
  $ rf  rg  r  s      r6   r:  .geninvgauss_gen._logquasipdf.<locals>.<lambda>_  s(    1q5"&&)*;aQqSk!m*Kr8   rZ  r  s       r6   _logquasipdfgeninvgauss_gen._logquasipdf\  s'    !a%!K66'# 	#r8   Nc                   ^	^
 [         R                  " U5      (       a/  [         R                  " U5      (       a  U R                  XX45      nGO\UR                  S:X  aA  UR                  S:X  a1  U R                  UR	                  5       UR	                  5       X45      nGO[         R
                  " X5      u  p[        UR                  U5      u  nm	[        [         R                  " U5      5      n[         R                  " U5      n[         R                  " X/S/S/S//S9m
T
R                  (       dx  [        U	U
4S j[        [        U5      * S5       5       5      nU R                  T
S   T
S   UU5      R!                  U5      XX'   T
R#                  5         T
R                  (       d  Mx  US:X  a  UR	                  5       nU$ )Nr   multi_indexreadonlyflagsop_flagsc              3   l   >#    U  H)  nTU   (       d  TR                   U   O
[        S 5      v   M+     g 7frO   r  slicer`  r  bcits     r6   rb  'geninvgauss_gen._rvs.<locals>.<genexpr>  0      ;%9 79eR^^A.tL%9   14r   r   )rQ   rJ  _rvs_scalarr   r  rH  r   re  r*  rT  emptynditerfinishedtuplerU  r  r  iternext)rE   rK  r   r   r   rM  shp
numsamplesidxr  r  s            @@r6   r   geninvgauss_gen._rvsb  sa    ;;q>>bkk!nn""1<CVVq[QVVq[""1668QVVXtJC &&q,DA #177D1GC RWWS\*J ((4.CA6"/&0\J<$@BB kk  ;%*CI:q%9; ;++BqE2a5*,8::A'#,  kkk  2:((*C
r8   c           	      6  ^ ^^^3 SnU(       d  SnTS:  a  T* mSnT R                  TT5      nSnTS:  d  TS:  a  SnO2T[        SS[        R                  " ST-
  5      -  S-  5      :  a  SnOSn[	        [        R
                  " U5      5      n	[        R                  " U	5      n
[        R                  " U
5      nSnU(       Ga  W(       Gaw  STS-   -  T-  U-
  nSU-  TS-
  -  T-  S-
  nXS-  S-  -
  nSUS-  -  S	-  X-  S-  -
  U-   n[        R                  " U* [        R                  " S
US-  -  5      -  S-  5      n[        R                  " SU-  S-  5      * nU[        R                  " US-  [        R                  S-  -   5      -  US-  -
  nU* [        R                  " US-  5      -  US-  -
  nT R                  UTT5      m3T R                  UTT5      T3-
  nT R                  UTT5      T3-
  nUU-
  [        R                  " SU-  5      -  nUU-
  [        R                  " SU-  5      -  nSnUU3UU 4S jnUnO[        R                  " ST R                  UTT5      -  5      nST-   [        R                  " ST-   S-  TS-  -   5      -   T-  nSnU[        R                  " ST R                  UTT5      -  5      -  nSnUUU 4S jnUU:  a  [        S5      eUS::  a  [        S5      eSnX:  a  X-
  nUUR                  US9-  nUR                  US9n UUU-
  U -  -   n U U-  U-   n!S[        R                  " U5      -  U" U!5      :*  n"[        R                   " U"5      n#U#S:  a  U!U"   XUU#-   & UU#-  nUS:X  a  UU
-  S:  a  SUU
-   S3n$[#        U$5      eUS-  nX:  a  M  GOTST-
  -  n%[        R$                  " U%ST-  45      n&[        R                  " T R                  UTT5      5      n'U'U%-  n(U%ST-  :  aR  [        R                  " T* 5      n)TS:  a  U)ST-  T-  U%T-  -
  -  T-  n*O%U)[        R                  " STS-  -  5      -  n*OSu  n)n*U&TS-
  -  n+SU+-  [        R                  " U&* T-  S-  5      -  T-  n,U(U*-   U,-   n-X:  Ga  X-
  n[        R                  " U5      [        R                  " U5      n!n.UR                  US9nU-UR                  US9-  n U U(:*  n/[        R&                  " U/5      U U(U*-   :*  -  n0[        R&                  " U/U0-  5      n1U%U U/   -  U(-  U!U/'   U'U.U/'   TS:  a  U%T-  U U0   U(-
  T-  U)-  -   ST-  -  U!U0'   O9T[        R                  " U U0   U(-
  [        R                  " T5      -  5      -  U!U0'   U)U!U0   TS-
  -  -  U.U0'   [        R                  " U&* T-  S-  5      TU U1   U(-
  U*-
  -  SU+-  -  -
  n2ST-  [        R                  " U25      -  U!U1'   U+[        R                  " U!U1   * T-  S-  5      -  U.U1'   [        R                  " UU.-  5      T R                  U!TT5      :*  n"[!        U"5      n#U#S:  a  U!U"   XUU#-   & UU#-  nX:  a  GM  [        R(                  " X5      n!U(       a  SU!-  n!U!$ )NFr   r   Tr   rW   r  r;     irq  c                 0   > TR                  U TT5      T-
  $ rO   r  )rv   r   lmrK  rE   s    r6   logqpdf,geninvgauss_gen._rvs_scalar.<locals>.logqpdf  s    ,,Q15::r8   c                 *   > TR                  U TT5      $ rO   r	  )rv   r   rK  rE   s    r6   r	  r	    s    ,,Q1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   )_moderg  rQ   r&  r  
atleast_1drT  zerosarccosrQ  r  r  r   r!  r  r  r  r  rL  logical_notr  )4rE   rK  r   r  r   
invert_resr  
ratio_unif
mode_shiftsize1dNrv   	simulateda2a1p1q1phir  root1root2d1d2vminvmaxumaxr	  ra  xplusrV  rq  r  r  r)  accept
num_acceptr[   r  xsk1A1k2A2k3A3r  r  cond1cond2cond3r  r	  s4   ```                                                @r6   r  geninvgauss_gen._rvs_scalar  s    
Jq5AJJJq! 
6QUJ#c1rwwq1u~-122J J r}}Z01GGFOHHQK	1q5\A%)Ua!e_q(1,a%!)^QY^bgk1A5iibggcBEk&: :Q >?ggb2gk**RVVC!Gbeeai$78826AbffS1Wo-Q6 &&q!Q/&&ua3b8&&ua3b8 	RVVC"H%55	RVVC"H%55; ;  vvc$"3"3Aq!"<<=a%277AEA:1+<#==q@rvvcD,=,=eQ,J&JKK6 t| !BCCqy !9::A-M<//Q/77 ((a(0D4K1,,!eaiBFF1I+5VVF^
><?KAZ!79+IN1!!"1 &??C 's++Q' -, a!eBQU$B))!Q23BbBAEzVVQBZq5AzBE12Q6BbffQAX..BBa!eBR"&&"q1--1BR"A -M!bhhqk3 ((a(0,,!,44Ru-b2g>uu}5!E(]R/E
%q5"$a%1U8b=A*=*B"Ba!e!LCJ!"RVVQuX]bffQi,G%H!HCJE
QU 33%FFB37Q;'!qx"}r/A*Ba"f*MM!VbffQi/E
E
{Q': ;;%&&Q-4+<+<S!Q+GG [
><?KAZ!79+I7 -: jj#c'C
r8   c                     US:  a+  U[         R                  " US-
  S-  US-  -   5      S-   U-
  -  $ [         R                  " SU-
  S-  US-  -   5      SU-
  -
  U-  $ rf  r  r  s      r6   r	  geninvgauss_gen._mode2  sf    q5Q
QT 12Q6:;;GGQUQJA-.!a%8A==r8   c                    [         R                  " X!-   U5      n[         R                  " X#5      n[        R                  " U5      [        R                  " U5      -  nUR	                  5       (       a^  Sn[
        R                  " U[        SS9  [        R                  " U[        R                  [        R                  S9nXF)    XV)    -  X) '   U$ XE-  nU$ )NzInfinite values encountered in the moment calculation involving scipy.special.kve. Values replaced by NaN to avoid incorrect results.r  r  dtype)r~   kverQ   rX   r  r  r  r  	full_likerF  r>  )	rE   re   rK  r   ra  denominf_valsr[   r  s	            r6   r+  geninvgauss_gen._munp9  s    ffQUAq88C=288E?2<<>>.C MM#~!<S"&&

;Ay>E),<<AiL  Ar8   r   r-  )r   r   r   r   r   rf   ro   r   rw   r{   r  r   r  r	  r+  r   r   r8   r6   r  r    s=    #H"
 -$#5nWr>r8   r  rZ  c                   r   ^  \ rS rSrSr\R                  rS rS r	U 4S jr
S rS rS rSS	 jrS
 rSrU =r$ )norminvgauss_geniL  a  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                 @    US:  [         R                  " U5      U:  -  $ r  )rQ   absoluterE   r   r   s      r6   rf   norminvgauss_gen._argcheck  s    A"++a.1,--r8   c                     [        SSS[        R                  4S5      n[        SS[        R                  * [        R                  4S5      nX/$ r  rl   r  s      r6   ro   norminvgauss_gen._shape_info  r  r8   c                     > [         TU ]  USS9$ )N)r   r   r  ry  rz  s     r6   r  norminvgauss_gen._fitstart  s     w H 55r8   c                    [         R                  " US-  US-  -
  5      nU[         R                  -  n[         R                  " SU5      nU[        R
                  " X&-  5      -  [         R                  " X1-  X&-  -
  U-   5      -  U-  $ r  )rQ   r&  r  hypotr~   k1er   )rE   rv   r   r   r(  fac1sqs          r6   rw   norminvgauss_gen._pdf  sm    1q!t$255yXXa^bffQVn$rvvacADj5.@'AABFFr8   c           
         [         R                  " U5      (       a3  [        R                  " U R                  U[         R
                  X#4S9S   $ [         R                  " U5      n[         R                  " U5      n/ n[        XU5       HH  u  pVnUR                  [        R                  " U R                  U[         R
                  Xg4S9S   5        MJ     [         R                  " U5      $ )Nr  r   )
rQ   rJ  r   rJ  rw   rm   r	  r  appendrD  )rE   rv   r   r   resultr  a0ra  s           r6   r   norminvgauss_gen._sf  s    ;;q>>>>$))QaVDQGGa Aa AF #A!innTYYBFF35(<<=? @ !- 88F##r8   c                    ^  U 4S jn[         R                  " U5      (       a	  U" XU5      $ / n[        XU5       H  u  pgnUR                  U" XgU5      5        M      [         R                  " U5      $ )Nc                 ^  > U
4S jnT
R                  X5      nU" XAX 5      nUS:X  a  U$ US:  a.  SnUnXF-   nU" XX 5      S:  a  SU-  nXF-   nU" XX 5      S:  a  M  O-SnUnXF-
  nU" XqX 5      S:  a  SU-  nXF-
  nU" XqX 5      S:  a  M  [        R                  " X7XX 4T
R                  S9n	U	$ )Nc                 .   > TR                  XU5      U-
  $ rO   r   )rv   r   r   r   rE   s       r6   eq6norminvgauss_gen._isf.<locals>._isf_scalar.<locals>.eq  s    xxa(1,,r8   r   r   rW   )rG   r  )r%  r   r  r  )r   r   r   rN	  xmemdeltaleftrightrG	  rE   s             r6   _isf_scalar*norminvgauss_gen._isf.<locals>._isf_scalar  s    - 1BB1BQw	Av
1(1,eGEJE 1(1,
 z!'!+eGE:D !'!+ __Ruq9*.))5FMr8   )rQ   rJ  r  rF	  rD  )	rE   r   r   r   rU	  rG	  q0rH	  ra  s	   `        r6   r   norminvgauss_gen._isf  s`    	B ;;q>>qQ''F #A!k""56 !-88F##r8   c                     [         R                  " US-  US-  -
  5      n[        R                  SU-  X4S9nX&-  [         R                  " U5      [        R                  UUS9-  -   $ )NrW   r   )r}  r   r   r'  )rQ   r&  r  r)  r.  )rE   r   r   r   r   r(  igs          r6   r   norminvgauss_gen._rvs  sk     1q!t$\\QuW4\KvdhhD<H '/ 'J J J 	Jr8   c                     [         R                  " US-  US-  -
  5      nX#-  nUS-  US-  -  nSU-  U[         R                  " U5      -  -  nSSSUS-  -  US-  -  -   -  U-  nXEXg4$ )NrW   r  r  r   rU  r  )rE   r   r   r(  r%  varianceskewnesskurtosiss           r6   r   norminvgauss_gen._stats  s~    1q!t$ya4%(?7a"''%.01!a!Q$hAo-.6x11r8   r   r-  )r   r   r   r   r   r   rI  rJ  rf   ro   r  rw   r   r   r   r   r   r  r   s   @r6   r6	  r6	  L  sF    4j "44M.
6
G$($TJ2 2r8   r6	  norminvgaussc                   x   ^  \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rS
 rSU 4S jjrSrU =r$ )invweibull_geni  uD  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   invweibull_gen._shape_info  r5  r8   c                     [         R                  " X* S-
  5      n[         R                  " X* 5      n[         R                  " U* 5      nX#-  U-  $ r>  rQ   rf  r   )rE   rv   ra  xc1xc2s        r6   rw   invweibull_gen._pdf  s@    hhq"s(#hhq"offcTlw}r8   c                 ^    [         R                  " X* 5      n[         R                  " U* 5      $ rO   rg	  )rE   rv   ra  rh	  s       r6   r{   invweibull_gen._cdf  s!    hhq"ovvsd|r8   c                 8    [         R                  " X* -  * 5      * $ rO   )rQ   rk  re  s      r6   r   invweibull_gen._sf  s    !R%   r8   c                 `    [         R                  " [         R                  " U5      * SU-  5      $ r  )rQ   rf  r  rl  s      r6   r   invweibull_gen._ppf  s!    xx
DF++r8   c                 >    [         R                  " U* 5      * SU-  -  $ Nr  r  r  s      r6   r   invweibull_gen._isf  s    1"A&&r8   c                 8    [         R                  " SX-  -
  5      $ ra   r<  r   s      r6   r+  invweibull_gen._munp  s    xxAE	""r8   c                 V    S[         -   [         U-  -   [        R                  " U5      -
  $ ra   rX  r  s     r6   r  invweibull_gen._entropy  s"    x&1*$rvvay00r8   c                 ,   > Uc  SOUn[         TU ]  XS9$ )N)r   r  ry  )rE   rF   rG   r  s      r6   r  invweibull_gen._fitstart  s!    v4w  11r8   r   rO   )r   r   r   r   r   r   rI  rJ  ro   rw   r{   r   r   r   r+  r  r  r   r  r   s   @r6   rc	  rc	    sH    : "44ME!,'#12 2r8   rc	  
invweibullc                   F    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rSrg)jf_skew_t_geni(  a   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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ r  rl   r  s      r6   ro   jf_skew_t_gen._shape_infoM  r  r8   c                 ,   SX#-   S-
  -  [         R                  " X#5      -  [        R                  " X#-   5      -  nSU[        R                  " X#-   US-  -   5      -  -   US-   -  nSU[        R                  " X#-   US-  -   5      -  -
  US-   -  nXV-  U-  $ NrW   r   r   )r~   r  rQ   r&  )rE   rv   r   r   ra  r	  r	  s          r6   rw   jf_skew_t_gen._pdfR  s    !%!)rwwq},rwwqu~=!bggaea1fn---1s7;!bggaea1fn---1s7;w{r8   Nc                     UR                  XU5      nSU-  S-
  [        R                  " X-   5      -  nS[        R                  " USU-
  -  5      -  nXg-  $ r  )r  rQ   r&  )rE   r   r   r   r   r	  r	  d3s           r6   r   jf_skew_t_gen._rvsX  sR    qT*"fqjBGGAEN*q2v''wr8   c                 ~    SU[         R                  " X#-   US-  -   5      -  -   S-  n[        R                  " X#U5      $ Nr   rW   r   )rQ   r&  r~   r  rE   rv   r   r   r  s        r6   r{   jf_skew_t_gen._cdf^  s:    RWWQUQ!V^,,,3zz!""r8   c                 ~    SU[         R                  " X#-   US-  -   5      -  -   S-  n[        R                  " X#U5      $ r	  )rQ   r&  r~   r  r	  s        r6   r   jf_skew_t_gen._sfb  s:    RWWQUQ!V^,,,3{{1##r8   c                     [         R                  XU5      nSU-  S-
  [        R                  " X#-   5      -  nS[        R                  " USU-
  -  5      -  nXV-  $ r  )r  r  rQ   r&  )rE   r   r   r   r	  r	  r	  s          r6   r   jf_skew_t_gen._ppff  sP    XXaA"fqjBGGAEN*q2v''wr8   c           	          S nUSU-  :  USU-  :  -  US:  -  n[        UXU4[        R                  " U[        R                  /S9[        R                  5      $ )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                 p   X-   SU -  -  nSU -  [         R                  " X5      -  n[        R                  " U S-   5      n[        R                  " US-  S:  SS5      n[         R                  " USU -  -   U-
  USU -  -
  U-   5      n[         R
                  " X5      U-  U-  nX4-  UR                  5       -  $ )zOComputes E[T^(n_k)] where T is skew-t distributed with
parameters a_k and b_k.
r   rW   r   r   r  )r~   r  rQ   r  r  r  r  )	n_ka_kb_kra  r2	  indicesr  r  	sum_termss	            r6   
nth_moment'jf_skew_t_gen._munp.<locals>.nth_momentu  s     9#),CHrwws00Eiia(G((7Q;?B2CcCi'13s?W3LMA-3a7I;00r8   r   r   r;  r   rQ   r2  r>  rF  )rE   re   r   r   r	  nth_moment_valids         r6   r+  jf_skew_t_gen._munpl  s_    	1 aKAaK8AFC1ILLRZZL9FF	
 	
r8   r   r-  )r   r   r   r   r   ro   rw   r   r{   r   r   r+  r   r   r8   r6   r|	  r|	  (  s+    #H
#$
r8   r|	  	jf_skew_tc                   Z    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rS
rg)johnsonsb_gen  a  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                     US:  X:H  -  $ r  r   r9	  s      r6   rf   johnsonsb_gen._argcheck      A!&!!r8   c                     [        SS[        R                  * [        R                  4S5      n[        SSS[        R                  4S5      nX/$ Nr   Fr3  r   r   rl   r  s      r6   ro   johnsonsb_gen._shape_info  r  r8   c                 l    [        X#[        R                  " U5      -  -   5      nUS-  USU-
  -  -  U-  $ r  )r   r~   r  )rE   rv   r   r   trms        r6   rw   johnsonsb_gen._pdf  s6    bhhqkM)*ua1gs""r8   c                 J    [        X#[        R                  " U5      -  -   5      $ rO   )r   r~   r  r  s       r6   r{   johnsonsb_gen._cdf  s    rxx{]*++r8   c                 R    [         R                  " SU-  [        U5      U-
  -  5      $ r>  )r~   r  r   r  s       r6   r   johnsonsb_gen._ppf  #    xxa9Q<!#3455r8   c                 J    [        X#[        R                  " U5      -  -   5      $ rO   )r   r~   r  r  s       r6   r   johnsonsb_gen._sf  s    bhhqkM)**r8   c                 R    [         R                  " SU-  [        U5      U-
  -  5      $ r>  )r~   r  r   r  s       r6   r   johnsonsb_gen._isf  r	  r8   r   N)r   r   r   r   r   r   rI  rJ  rf   ro   rw   r{   r   r   r   r   r   r8   r6   r	  r	    s7    6 "44M"
#
,6+6r8   r	  	johnsonsbc                   L    \ rS rSrSrS rS rS rS rS r	S r
S	 rSS
 jrSrg)johnsonsu_geni  a  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                     US:  X:H  -  $ r  r   r9	  s      r6   rf   johnsonsu_gen._argcheck  r	  r8   c                     [        SS[        R                  * [        R                  4S5      n[        SSS[        R                  4S5      nX/$ r	  rl   r  s      r6   ro   johnsonsu_gen._shape_info  r  r8   c                     X-  n[        X#[        R                  " U5      -  -   5      nUS-  [        R                  " US-   5      -  U-  $ r>  )r   rQ   arcsinhr&  )rE   rv   r   r   r  r	  s         r6   rw   johnsonsu_gen._pdf  sE     S

1--.uRWWRV_$S((r8   c                 J    [        X#[        R                  " U5      -  -   5      $ rO   )r   rQ   r	  r  s       r6   r{   johnsonsu_gen._cdf  s    A..//r8   c                 L    [         R                  " [        U5      U-
  U-  5      $ rO   )rQ   sinhr   r  s       r6   r   johnsonsu_gen._ppf       ww	!q(A-..r8   c                 J    [        X#[        R                  " U5      -  -   5      $ rO   )r   rQ   r	  r  s       r6   r   johnsonsu_gen._sf  s    

1--..r8   c                 L    [         R                  " [        U5      U-
  U-  5      $ rO   )rQ   r	  r   r  s       r6   r   johnsonsu_gen._isf  r	  r8   c                    Su  pEpgUS-  n[         R                  " U5      n	X-  n
SU;   a  U	S-  * [         R                  " U
5      -  nSU;   a9  S[        R                  " U5      -  U	[         R
                  " SU
-  5      -  S-   -  nSU;   a  U	S-  [        R                  " U5      S-  -  nS	[         R                  " U
5      -  nXS-   -  [         R                  " S	U
-  5      -  n[         R                  " S5      SU	[         R
                  " SU
-  5      -  -   S
-  -  nU* X-   -  U-  nSU;   a  S	SU	-  -   nSU	S-  -  U	S-   -  [         R
                  " SU
-  5      -  nU	S-  [         R
                  " SU
-  5      -  nSS	U	S-  -  -   SU	S	-  -  -   U	S-  -   nSSU	[         R
                  " SU
-  5      -  -   S-  -  nX-   X-  -   U-  S	-
  nXEXg4$ )NNNNNr  r  r   r  rW   r   ro  r  rd  rq  r  rU  rp  )rQ   r   r	  r~   rk  rV  r&  )rE   r   r   rt  r}  r~  r  r  bn2expbn2a_br  r  r  r2	  r
  s                   r6   r   johnsonsu_gen._stats	  s    1fe'>#+,B'>bhhsm#VBGGAcEN%:Q%>?C'>bhhsmS00B2773<BA:&37BGGAJ!frwwqu~&="=!EEE5(B'>QvXB619
+bggaen<BRWWQsU^+Ba	k!AfaiK/&!);Bq6"''!C%.00144E'BE/U*Q.Br8   r   Nry  )r   r   r   r   r   rf   ro   rw   r{   r   r   r   r   r   r   r8   r6   r	  r	    s0    "F"
)0///r8   r	  	johnsonsuc                   b    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSS jrSS jrSrg)
landau_geni*  a  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                     / $ rO   r   rn   s    r6   ro   landau_gen._shape_infoV  r   r8   c                     g)NgX(@r   rn   s    r6   r  landau_gen._entropyY  s    "r8   c                 2    [         R                  " USS5      $ r   )rs   _landau_pdfr   s     r6   rw   landau_gen._pdf]  r#  r8   c                 2    [         R                  " USS5      $ r   )rs   _landau_cdfr   s     r6   r{   landau_gen._cdf`  r#  r8   c                 2    [         R                  " USS5      $ r   )rs   
_landau_sfr   s     r6   r   landau_gen._sfc  s    ~~aA&&r8   c                 2    [         R                  " USS5      $ r   )rs   _landau_ppfr  s     r6   r   landau_gen._ppff  r#  r8   c                 2    [         R                  " USS5      $ r   )rs   _landau_isfr  s     r6   r   landau_gen._isfi  r#  r8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   r*  rn   s    r6   r   landau_gen._statsl  r,  r8   c                 2    US:  a  [         R                  $ S$ r   r*  rd   s     r6   r+  landau_gen._munpo  s    Qrvv%A%r8   Nc                     [        U[        5      (       a  UR                  5       n[        R                  " U/ SQ5      u  p4nXEU-
  S-  4$ r1  r6  r8  s         r6   r  landau_gen._fitstartr  r=  r8   c                 z   [         R                  S-  nUR                  [         R                  * S-  [         R                  S-  US9nUR                  US9nS[         R                  -  X4-   [         R                  " U5      -  [         R
                  " X5-  [         R                  " U5      -  X4-   -  5      -
  -  nU$ )NrW   r  )rQ   r  r  r  r  r  rQ  )rE   r   r   pi_2UWSs          r6   r   landau_gen._rvsy  s    uuqy  "%%!RUUQYT B--4-8I$(bffQi/6648bffQi#7DH"EFG Hr8   r   rO   r-  )r   r   r   r   r   ro   r  rw   r{   r   r   r   r   r+  r  r   r   r   r8   r6   r	  r	  *  s?    *V#(('((.&"r8   r	  landauc                   v    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS r\\" \SS9S 5       5       rSrg)laplace_geni  zA 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                     / $ rO   r   rn   s    r6   ro   laplace_gen._shape_info  r   r8   Nc                 $    UR                  SSUS9$ )Nr   r   r  )laplacer   s      r6   r   laplace_gen._rvs  s    ##Aqt#44r8   c                 H    S[         R                  " [        U5      * 5      -  $ r  )rQ   r   r  r   s     r6   rw   laplace_gen._pdf  s    2663q6'?""r8   c           	          [         R                  " SS9   [         R                  " US:  SS[         R                  " U* 5      -  -
  S[         R                  " U5      -  5      sS S S 5        $ ! , (       d  f       g = f)Nrp  r  r   r   r   )rQ   rs  r  r   r   s     r6   r{   laplace_gen._cdf  sM    [[h'88AE3RVVQBZ#7RVVAYG (''s   AA,,
A:c                 &    U R                  U* 5      $ rO   r{   r   s     r6   r   laplace_gen._sf  s    yy!}r8   c                     [         R                  " US:  [         R                  " SSU-
  -  5      * [         R                  " SU-  5      5      $ r  rQ   r  r  r   s     r6   r   laplace_gen._ppf  s8    xxC"&&AaC/!1266!A#;??r8   c                 &    U R                  U5      * $ rO   r  r   s     r6   r   laplace_gen._isf  s    		!}r8   c                     g)N)r   rW   r   r  r   rn   s    r6   r   laplace_gen._stats  s    r8   c                 4    [         R                  " S5      S-   $ r  rg  rn   s    r6   r  laplace_gen._entropy  s    vvay{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                     [        XX#5      u  pnUc  [        R                  " U5      nUc8  [        R                  " [        R                  " X-
  5      5      [        U5      -  nXE4$ rO   )rj  rQ   medianr  r  r  )rE   rF   rG   r5   r  r  s         r6   rC   laplace_gen.fit  s\     99=EF <99T?D>ffRVVDK01SY>F|r8   r   r-  )r   r   r   r   r   ro   r   rw   r{   r   r   r   r   r  rL   r
   r   rC   r   r   r8   r6   r	  r	    sa    &5#H@  6F G	G 
r8   r	  r	  c                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)laplace_asymmetric_geni  u}  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                 @    [        SSS[        R                  4S5      /$ )NkappaFr   r3  rl   rn   s    r6   ro   "laplace_asymmetric_gen._shape_info  s    7EArvv;GHHr8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   r	
  s      r6   rw   laplace_asymmetric_gen._pdf   s    vvdll1,--r8   c                     SU-  nU[         R                  " US:  U* U5      -  nU[         R                  " X#-   5      -  nU$ r  r	  )rE   rv   r	
  kapinvr  s        r6   r   laplace_asymmetric_gen._logpdf  sB    5"((16E6622rvvel##
r8   c                     SU-  nX#-   n[         R                  " US:  S[         R                  " U* U-  5      X4-  -  -
  [         R                  " X-  5      X$-  -  5      $ r  rQ   r  r   rE   rv   r	
  r
  
kappkapinvs        r6   r{   laplace_asymmetric_gen._cdf	  s^    5\
xxQBFFA2e8,f.?@@qx(%*:;= 	=r8   c           	          SU-  nX#-   n[         R                  " US:  [         R                  " U* U-  5      X4-  -  S[         R                  " X-  5      X$-  -  -
  5      $ r  r
  r
  s        r6   r   laplace_asymmetric_gen._sf  s`    5\
xxQr%x(&*;<BFF18,e.>??A 	Ar8   c                     SU-  nX#-   n[         R                  " XU-  :  [         R                  " SU-
  U-  U-  5      * U-  [         R                  " X-  U-  5      U-  5      $ ra   r	  rE   r   r	
  r
  r
  s        r6   r   laplace_asymmetric_gen._ppf  sg    5\
xx:--Q
 25 899&@q|E1258: 	:r8   c                     SU-  nX#-   n[         R                  " XU-  :*  [         R                  " X-  U-  5      * U-  [         R                  " SU-
  U-  U-  5      U-  5      $ ra   r	  r
  s        r6   r   laplace_asymmetric_gen._isf  si    5\
xxJ..U 233F:Az1%78>@ 	@r8   c                 b   SU-  nX!-
  nX"-  X-  -   nSS[         R                  " US5      -
  -  [         R                  " S[         R                  " US5      -   S5      -  nSS[         R                  " US5      -   -  [         R                  " S[         R                  " US5      -   S5      -  nX4XV4$ )	Nr   r   r  rU  rd  r_  rb  rW   r  )rE   r	
  r
  mnr  r  r  s          r6   r   laplace_asymmetric_gen._stats%  s    5^mek)!BHHUA&&'288E13E1Es(KK!BHHUA&&'288E13E1Eq(IIr8   c                 @    S[         R                  " USU-  -   5      -   $ ra   rg  rE   r	
  s     r6   r  laplace_asymmetric_gen._entropy-  s    266%%-(((r8   r   Nr  r   r8   r6   r
  r
    s8    *VI.=A:@)r8   r
  laplace_asymmetricc                    [        U[        5      (       d  [        R                  " U5      nUR	                  SS 5      nUR	                  SS 5      nU R
                  (       a$  [        U R
                  R                  S5      5      OSn/ n/ nU R
                  (       a  U R
                  R                  SS5      R                  5       n	[        U	5       HT  u  pS[        U
5      -   nUSU-   SU-   /n[        X=5      nUR                  U5        UR                  U5        Uc  MP  XU'   MV     SS	S
SSS1Ukn[        U5      R                  U5      nU(       a  [        SU S35      e[        U5      U:  a  [        S5      eS XE1Uk;  a  [!        S5      e[        U[        5      (       a  UR#                  5       OUn[        R$                  " U5      R'                  5       (       d  [)        S5      eU/UQUPUP7$ )Nr  r  ,r    r  fix_r.   r/   r0   r1   zUnknown keyword arguments: r2   zToo many positional arguments.r  r   )r?   r*   rQ   r"  r=   shapesr  splitr  	enumeratestrr   rF	  set
differencer4   r  r  r#  r$  r!  )distrF   rG   r5   r  r  
num_shapesfshape_keysfshapesr(
  r  ro  keynamesr  
known_keysunknown_keys
uncensoreds                     r6   rj  rj  4  s   dL))zz$88FD!DXXh%F04T[[&&s+,JKG
 {{$$S#.446f%DAA,C#'6A:.E&t3Cs#NN3S	 & +x(2%02Jt9''
3L5l^1EFF
4y:899D+7++  ' ( 	( &0l%C%C!J;;z"&&((?@@)7)D)&))r8   c                   Z    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rS
rg)levy_genie  a  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                     / $ rO   r   rn   s    r6   ro   levy_gen._shape_info  r   r8   c                     S[         R                  " S[         R                  -  U-  5      -  U-  [         R                  " SSU-  -  5      -  $ Nr   rW   r  r8  r   s     r6   rw   levy_gen._pdf  s=    2771RUU719%%)BFF2qs8,<<<r8   c                 \    [         R                  " [        R                  " SU-  5      5      $ r  )r~   erfcrQ   r&  r   s     r6   r{   levy_gen._cdf  s    wwrwwsQw'((r8   c                 \    [         R                  " [        R                  " SU-  5      5      $ r  r>  r   s     r6   r   levy_gen._sf  s    vvbggcAg&''r8   c                 ,    [        US-  5      nSX"-  -  $ NrW   r   r  rE   r   r  s      r6   r   levy_gen._ppf  s    !nci  r8   c                 @    SS[         R                  " U5      S-  -  -  $ rf  )r~   erfinvr  s     r6   r   levy_gen._isf  s    !BIIaL!O#$$r8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   rE  rn   s    r6   r   levy_gen._stats  r,  r8   r   Nr   r   r   r   r   r   rI  rJ  ro   rw   r{   r   r   r   r   r   r   r8   r6   r8
  r8
  e  s9    GP "44M=)(!
%.r8   r8
  levyc                   Z    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rS
rg)
levy_l_geni  a  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                     / $ rO   r   rn   s    r6   ro   levy_l_gen._shape_info  r   r8   c                     [        U5      nS[        R                  " S[        R                  -  U-  5      -  U-  [        R                  " SSU-  -  5      -  $ r<
  )r  rQ   r&  r  r   rE   rv   r  s      r6   rw   levy_l_gen._pdf  sF    V255$$R'r1R4y(999r8   c                 h    [        U5      nS[        S[        R                  " U5      -  5      -  S-
  $ r  )r  r   rQ   r&  rS
  s      r6   r{   levy_l_gen._cdf  s,    V9Q_--11r8   c                 b    [        U5      nS[        S[        R                  " U5      -  5      -  $ r  )r  r   rQ   r&  rS
  s      r6   r   levy_l_gen._sf#  s'    V8AO,,,r8   c                 2    [        US-   S-  5      nSX"-  -  $ )Nr   rW   r  r   rE
  s      r6   r   levy_l_gen._ppf'  s!    SA&sy!!r8   c                 *    S[        US-  5      S-  -  $ )Nr  rW   r  r  s     r6   r   levy_l_gen._isf+  s    )AaC.!###r8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   rE  rn   s    r6   r   levy_l_gen._stats.  r,  r8   r   NrL
  r   r8   r6   rO
  rO
    s9    FN "44M:
2-"$.r8   rO
  levy_lc                      ^  \ rS rSrSrS rSS jrS rS rS r	S r
S	 rS
 rS rS rS rS r\\" \5      U 4S j5       5       rSrU =r$ )logistic_geni5  a  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                     / $ rO   r   rn   s    r6   ro   logistic_gen._shape_infoM  r   r8   c                      UR                  US9$ r  )logisticr   s      r6   r   logistic_gen._rvsP  s    $$$$//r8   c                 L    [         R                  " U R                  U5      5      $ rO   r.  r   s     r6   rw   logistic_gen._pdfS  r  r8   c                     [         R                  " U5      * nUS[        R                  " [         R                  " U5      5      -  -
  $ rv  )rQ   r  r~   r  r   )rE   rv   r  s      r6   r   logistic_gen._logpdfW  s2    VVAYJ2++++r8   c                 .    [         R                  " U5      $ rO   r  r   s     r6   r{   logistic_gen._cdf[      xx{r8   c                 .    [         R                  " U5      $ rO   r~   	log_expitr   s     r6   r  logistic_gen._logcdf^  s    ||Ar8   c                 .    [         R                  " U5      $ rO   r  r   s     r6   r   logistic_gen._ppfa  rm
  r8   c                 0    [         R                  " U* 5      $ rO   r  r   s     r6   r   logistic_gen._sfd  s    xx|r8   c                 0    [         R                  " U* 5      $ rO   ro
  r   s     r6   r	  logistic_gen._logsfg  s    ||QBr8   c                 0    [         R                  " U5      * $ rO   r  r   s     r6   r   logistic_gen._isfj  s    |r8   c                 R    S[         R                  [         R                  -  S-  SS4$ )Nr   r  g333333?rc  rn   s    r6   r   logistic_gen._statsm  s!    "%%+c/1g--r8   c                     grv  r   rn   s    r6   r  logistic_gen._entropyp  s    r8   c                   >^^
^^ UR                  SS5      (       a  [        TU ]  " T/UQ70 UD6$ [        U TX#5      u  mpE[	        T5      mU R                  T5      u  pgUR                  SU5      UR                  SU5      pvU4UU4S jjm
U4UU4S jjmU
U4S jnUb-  Uc*  [        R                  " T
U45      n	U	R                  S   nUnOVUb-  Uc*  [        R                  " TU45      n	U	R                  S   nUnO&[        R                  " XU45      n	U	R                  u  pg[        U5      nU	R                  (       a  Xg4$ [        TU ]  " T/UQ70 UD6$ )	Nr\  Fr.   r/   c                 t   > TU -
  U-  n[         R                  " [        R                  " U5      5      TS-  -
  $ rD  )rQ   r  r~   r  )r.   r/   ra  rF   re   s      r6   dl_dloc!logistic_gen.fit.<locals>.dl_dloc  s1    u$A66"((1+&1,,r8   c                 z   > TU-
  U -  n[         R                  " U[         R                  " US-  5      -  5      T-
  $ rD  )rQ   r  r  )r/   r.   ra  rF   re   s      r6   	dl_dscale#logistic_gen.fit.<locals>.dl_dscale  s5    u$A66!BGGAaCL.)A--r8   c                 ,   > U u  pT" X5      T" X!5      4$ rO   r   )paramsr.   r/   r
  r
  s      r6   r  logistic_gen.fit.<locals>.func  s    JC3&	%(===r8   r   )r3   rA   rC   rj  r  r  r=   r   rk  rv   r  success)rE   rF   rG   r5   r  r  r.   r/   r  r  r
  r
  re   r  s    `        @@@r6   rC   logistic_gen.fitt  sR    88J&&7;t3d3d338t9=EdI ^^D)
XXeS)488GU+CU  & 	- 	- "& 	. 	.	> $,--#0C%%(CE&.--	E84CEE!HEC--El3CJC E
 # 	7W[555	7r8   r   r-  )r   r   r   r   r   ro   r   rw   r   r{   r  r   r   r	  r   r   r  rL   r   r   rC   r   r  r   s   @r6   ra
  ra
  5  se    .0', . M*07 + 07r8   ra
  re
  c                   X    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)loggamma_geni  a  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   loggamma_gen._shape_info  r5  r8   Nc                     [         R                  " UR                  US-   US95      [         R                  " UR                  US95      U-  -   $ )Nr   r  )rQ   r  r(  r  r  s       r6   r   loggamma_gen._rvs  sM     |))!a%d);<&&--4-89!;< 	=r8   c                     [         R                  " X!-  [         R                  " U5      -
  [        R                  " U5      -
  5      $ rO   rQ   r   r~   r  re  s      r6   rw   loggamma_gen._pdf  s,    vvac"&&)mBJJqM122r8   c                 f    X!-  [         R                  " U5      -
  [        R                  " U5      -
  $ rO   r
  re  s      r6   r   loggamma_gen._logpdf  s#    sRVVAYA..r8   c                 .    [        U[        :  X4S S S9$ )Nc                 f    [         R                  " X-  [        R                  " US-   5      -
  5      $ ra   r
  r  s     r6   r:  #loggamma_gen._cdf.<locals>.<lambda>  s     rvvacBJJqsO.C'Dr8   c                 X    [         R                  " U[        R                  " U 5      5      $ rO   )r~   rS  rQ   r   r  s     r6   r:  r
    s    "++a*Cr8   r>  r   r#   re  s      r6   r{   loggamma_gen._cdf  s#     !h,DCE 	Er8   c                 \    [         R                  " X!5      n[        U[        :  X1U4S S S9$ )Nc                 h    [         R                  " U5      [        R                  " US-   5      -   U-  $ ra   r}  rc  r   ra  s      r6   r:  #loggamma_gen._ppf.<locals>.<lambda>  s"    266!9rzz!A#+F*Ir8   c                 .    [         R                  " U 5      $ rO   rg  r
  s      r6   r:  r
        RVVAYr8   r>  )r~   r\  r   r"   rE   r   ra  rc  s       r6   r   loggamma_gen._ppf  s1     NN1 !e)aAYI68 	8r8   c                 .    [        U[        :  X4S S S9$ )Nc                 h    [         R                  " X-  [        R                  " US-   5      -
  5      * $ ra   )rQ   rk  r~   r  r  s     r6   r:  "loggamma_gen._sf.<locals>.<lambda>  s#    rzz!A#1F(G'Gr8   c                 X    [         R                  " U[        R                  " U 5      5      $ rO   )r~   rW  rQ   r   r  s     r6   r:  r
    s    ",,q"&&)*Dr8   r>  r
  re  s      r6   r   loggamma_gen._sf  s!    !h,GDF 	Fr8   c                 \    [         R                  " X!5      n[        U[        :  X1U4S S S9$ )Nc                 j    [         R                  " U* 5      [        R                  " US-   5      -   U-  $ ra   )rQ   r  r~   r  r
  s      r6   r:  #loggamma_gen._isf.<locals>.<lambda>  s$    288QB<"**QqS/+I1*Lr8   c                 .    [         R                  " U 5      $ rO   rg  r
  s      r6   r:  r
    r
  r8   r>  )r~   ra  r   r"   r
  s       r6   r   loggamma_gen._isf  s1     OOA!!e)aAYL68 	8r8   c                     [         R                  " U5      n[         R                  " SU5      n[         R                  " SU5      [        R                  " US5      -  n[         R                  " SU5      X3-  -  nX#XE4$ )Nr   rW   rd  r  )r~   rk  	polygammarQ   rf  )rE   ra  r%  r  r^	  excess_kurtosiss         r6   r   loggamma_gen._stats  sc     zz!}ll1a <<1%c(::,,q!,8(33r8   c                 0    S nS n[        US:  U4X2S9nU$ )Nc                 l    [         R                  " U 5      U [         R                  " U 5      -  -
  U -   nU$ rO   )r~   r  rk  )ra  r  s     r6   r  &loggamma_gen._entropy.<locals>.regular  s+    

1BJJqM 11A5AHr8   c                     S[         R                  " U 5      -  U S-  S-  -   U S-  S-  -
  U S-  S-  -   n[        R                  5       U-   nU$ )Nr:  r  r  r  r  r     )rQ   r  r.  r  )ra  termr  s      r6   r	  )loggamma_gen._entropy.<locals>.asymptotic  sO    q	>AsF1H,q#vby81c6#:ED$&AHr8   -   r  r@  )rE   ra  r  r	  r  s        r6   r  loggamma_gen._entropy  s'    		 qBw@r8   r   r-  r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r   r  r   r   r8   r6   r
  r
    s<    0E=3/E&8F84r8   r
  loggammac                   |   ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 r\\" \5      U 4S j5       5       rSrU =r$ )loglaplace_geni!  a  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   loglaplace_gen._shape_infoB  r5  r8   c                 V    US-  n[         R                  " US:  X"* 5      nX1US-
  -  -  $ r  rQ   r  )rE   rv   ra  cd2s       r6   rw   loglaplace_gen._pdfE  s3     eHHQUAr"qs8|r8   c                 T    [         R                  " US:  SX-  -  SSX* -  -  -
  5      $ Nr   r   r
  re  s      r6   r{   loglaplace_gen._cdfL  s+    xxAs14x3q2w;77r8   c                 T    [         R                  " US:  SSX-  -  -
  SX* -  -  5      $ r
  r
  re  s      r6   r   loglaplace_gen._sfO  s+    xxAq3qt8|SR[99r8   c                 b    [         R                  " US:  SU-  SU-  -  SSU-
  -  SU-  -  5      $ Nr   r   r   rW   r  r
  rl  s      r6   r   loglaplace_gen._ppfR  s7    xxC#a%3q5!1As1uIa3HIIr8   c                 b    [         R                  " US:  SSU-
  -  SU-  -  SU-  SU-  -  5      $ r
  r
  rl  s      r6   r   loglaplace_gen._isfU  s6    xxC#sQw-3q5!9AaC46?KKr8   c                     [         R                  " SS9   US-  US-  pC[         R                  " XC:  X3U-
  -  [         R                  5      sS S S 5        $ ! , (       d  f       g = f)Nrp  rq  rW   )rQ   rs  r  rm   )rE   re   ra  r  n2s        r6   r+  loglaplace_gen._munpX  sE    [[)T1a488BGR7^RVV< *))s   6A
A#c                 :    [         R                  " SU-  5      S-   $ r(  rg  r  s     r6   r  loglaplace_gen._entropy]  s    vvc!e}s""r8   c                   > [        XX#5      u  ppVUc  [        [        U 5      U ]  " U/UQ70 UD6$ [        R
                  " X:*  5      (       a  [        SU[        R                  S9eUS:w  a  X-
  n[        R                  [        R                  " U5      Ub  [        R                  " U5      OS Ub  SU-  OS SS9u  pxUn	Uc  [        R                  " U5      OUn
Uc  SU-  OUnXU
4$ )N
loglaplacer  r   r   r;   )r  r  r1   )rj  rA   rB   rC   rQ   r  r  rm   r	  r  r   )rE   rF   rG   r5   rl  r  r  r   r   r.   r/   ra  r  s               r6   rC   loglaplace_gen.fit`  s     "=T=A"I$ <dT.tCdCdCC 66$,|4rvvFF 19;D {{266$<282Dv$*,.!B$d"'  ) #^q	ZAERu}r8   r   )r   r   r   r   r   ro   rw   r{   r   r   r   r+  r  rL   r   r   rC   r   r  r   s   @r6   r
  r
  !  sU    @E8:JL=
# M* + r8   r
  r
  c                 F    [        U S:g  X4S [        R                  * 5      $ )Nr   c                     [         R                  " U 5      S-  * SUS-  -  -  [         R                  " X-  [         R                  " S[         R                  -  5      -  5      -
  $ rD  )rQ   r  r&  r  rv   ro  s     r6   r:  !_lognorm_logpdf.<locals>.<lambda>  sI    RVVAY\MQAX$>&(ffQURWWQY5G-G&H%Ir8   rZ  r
  s     r6   _lognorm_logpdfr
    s(    a1fqfJvvg r8   c                      ^  \ rS rSrSr\R                  rS rSS jr	S r
S rS rS rS	 rS
 rS rS rS rS r\\" \SS9U 4S j5       5       rSrU =r$ )lognorm_geni  a9  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                 @    [        SSS[        R                  4S5      /$ )Nro  Fr   r3  rl   rn   s    r6   ro   lognorm_gen._shape_info  r5  r8   c                 P    [         R                  " XR                  U5      -  5      $ rO   rQ   r   r   )rE   ro  r   r   s       r6   r   lognorm_gen._rvs  s    vva66t<<==r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   ro  s      r6   rw   lognorm_gen._pdf  r  r8   c                     [        X5      $ rO   r
  r
  s      r6   r   lognorm_gen._logpdf  s    q$$r8   c                 F    [        [        R                  " U5      U-  5      $ rO   r   rQ   r  r
  s      r6   r{   lognorm_gen._cdf  s    Q''r8   c                 F    [        [        R                  " U5      U-  5      $ rO   rx  r
  s      r6   r  lognorm_gen._logcdf  s    BFF1IM**r8   c                 F    [         R                  " U[        U5      -  5      $ rO   rQ   r   r   rE   r   ro  s      r6   r   lognorm_gen._ppf      vva)A,&''r8   c                 F    [        [        R                  " U5      U-  5      $ rO   r   rQ   r  r
  s      r6   r   lognorm_gen._sf  s    q	A&&r8   c                 F    [        [        R                  " U5      U-  5      $ rO   )r   rQ   r  r
  s      r6   r	  lognorm_gen._logsf  s    266!9q=))r8   c                 F    [         R                  " U[        U5      -  5      $ rO   rQ   r   r   r
  s      r6   r   lognorm_gen._isf  r
  r8   c                     [         R                  " X-  5      n[         R                  " U5      nX"S-
  -  n[         R                  " US-
  5      SU-   -  n[         R                  " / SQU5      nX4XV4$ Nr   rW   )r   rW   r  r   r  )rQ   r   r&  polyval)rE   ro  rK  r}  r~  r  r  s          r6   r   lognorm_gen._stats  s^    FF13KWWQZ1gWWQqS\1Q3ZZ*A.r8   c                     SS[         R                  " S[         R                  -  5      -   S[         R                  " U5      -  -   -  $ Nr   r   rW   r  )rE   ro  s     r6   r  lognorm_gen._entropy  s3    a"&&255/)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                 t  >^ ^^^^ UR                  SS5      (       a  [        TT ]  " T/UQ70 UD6$ [        T TX#5      nUu  mmnm[        R
                  " T5      nUUU4S jmUU4S jnUUU 4S jnUGcc  [        R                  " U5      n	Xi-
  n
U" U
5      nU" U
5      nSU	-  nUS:  a  Xm-
  n
U" U
5      nUS-  nUS:  a  M  [        R                  " U
5      (       a  [        R                  " U5      (       d  [        TT ]  " T/UQ70 UD6$ [        R                  " [        R                  " U
[        R                  * 5      U
S-
  5      nU" U5      nSX-
  -  n[        R                  " U5      (       a  [        R                  " U5      (       a  [        R                  " U5      [        R                  " U5      :X  aw  X-
  nU" U5      nUS-  n[        R                  " U5      (       aK  [        R                  " U5      (       a0  [        R                  " U5      [        R                  " U5      :X  a  Mw  [        R                  " U5      (       a  [        R                  " U5      (       d  [        TT ]  " T/UQ70 UD6$ [        X~U
4S	9nUR                  (       d  [        TT ]  " T/UQ70 UD6$ U" UR                  5      nUU:  a  UR                  OXi-
  nO XV:  a  [        S
S[        R                  S9eUnT" U5      u  nnT R!                  U5      (       a  US:  d  [        TT ]  " T/UQ70 UD6$ UUU4$ )Nr\  Fc                 <  > Tb  Tc  [         R                  " TU -
  5      nT=(       d$    [         R                  " WR                  5       5      nT=(       dD    [         R                  " [         R                  " W[         R                  " U5      -
  S-  5      5      nX24$ rD  )rQ   r  r   r%  r&  )r.   lndatar/   re  rF   r  fshapes       r6   get_shape_scale(lognorm_gen.fit.<locals>.get_shape_scale  so     ~s
+3bffV[[]3EKbggbggvu/E.I&JKE<r8   c                    > T" U 5      u  pTU -
  n[         R                  " S[         R                  " X2-  5      US-  -  -   U-  5      $ rf  rQ   r  r  )r.   re  r/   shiftedrF   r  s       r6   dL_dLoc lognorm_gen.fit.<locals>.dL_dLoc  sE    *3/LESjG661rvvgm4UAX==wFGGr8   c                 B   > T" U 5      u  pTR                  XU4T5      * $ rO   )nnlf)r.   re  r/   rF   r  rE   s      r6   lllognorm_gen.fit.<locals>.ll  s(    *3/LEIIu514888r8   rW   gưr   r  lognormr   r  r   )r3   rA   rC   rj  rQ   rg  spacingr#  r9  	nextafterrm   rR   r+   	convergedrk  r  rf   )rE   rF   rG   r5   
parametersr  rh  r
  r  r  rT   dL_dLoc_rbrack	ll_rbrackrR	  rS   dL_dLoc_lbrackr  ll_rootr.   re  r/   r  r  r  r  s   ``                   @@@r6   rC   lognorm_gen.fit  s   $ 88J&&7;t3d3d330tTH
%/"fdF66$<	 	H	9
 < jj*G'F %V_N6
IKE E)!)!(
 !E)
 ;;v&&bkk..I.I w{47$7$77
 ZZVbffW =vaxHF$V_N)E;;v&&2;;~+F+Fww~."''.2II!(
	 ;;v&&2;;~+F+Fww~."''.2II ;;v&&bkk..I.Iw{47$7$77 g/?@C==w{47$7$77
 lG%	1#((x7GC "9BbffEEC&s+uu%%%!)7;t3d3d33c5  r8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r   r{   r  r   r   r	  r   r   r  rL   r	   rC   r   r  r   s   @r6   r
  r
    s}    *V "44ME>*%(+('*(; } 5  Z!! "Z!r8   r
  r  c                   p    \ rS rSrSr\R                  rS rSS jr	S r
S rS rS	 rS
 rS rS rS rSrg)
gibrat_geniT  a/  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                     / $ rO   r   rn   s    r6   ro   gibrat_gen._shape_infol  r   r8   Nc                 L    [         R                  " UR                  U5      5      $ rO   r
  r   s      r6   r   gibrat_gen._rvso  s    vvl224899r8   c                 L    [         R                  " U R                  U5      5      $ rO   r.  r   s     r6   rw   gibrat_gen._pdfr  r  r8   c                     [        US5      $ r>  r
  r   s     r6   r   gibrat_gen._logpdfv  s    q#&&r8   c                 @    [        [        R                  " U5      5      $ rO   r
  r   s     r6   r{   gibrat_gen._cdfy  s    ##r8   c                 @    [         R                  " [        U5      5      $ rO   r
  r   s     r6   r   gibrat_gen._ppf|      vvil##r8   c                 @    [        [        R                  " U5      5      $ rO   r
  r   s     r6   r   gibrat_gen._sf  s    q	""r8   c                 @    [         R                  " [        U5      5      $ rO   r
  r  s     r6   r   gibrat_gen._isf  r(  r8   c                     [         R                  n[         R                  " U5      nXS-
  -  n[         R                  " US-
  5      SU-   -  n[         R                  " / SQU5      nX#XE4$ r
  )rQ   er&  r
  )rE   rK  r}  r~  r  r  s         r6   r   gibrat_gen._stats  sX    DDWWQZq5kWWQU^q1u%ZZ*A.r8   c                 \    S[         R                  " S[         R                  -  5      -  S-   $ rQ  r  rn   s    r6   r  gibrat_gen._entropy  s#    RVVAI&&,,r8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r   r{   r   r   r   r   r  r   r   r8   r6   r  r  T  sF    * "44M:''$$#$-r8   r  gibratc                   X    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)maxwell_geni  a  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                     / $ rO   r   rn   s    r6   ro   maxwell_gen._shape_info  r   r8   Nc                 *    [         R                  SXS9$ )Nr  r'  rw  r)  r   s      r6   r   maxwell_gen._rvs  s    wwswAAr8   c                 V    [         U-  U-  [        R                  " U* U-  S-  5      -  $ rv  )r'   rQ   r   r   s     r6   rw   maxwell_gen._pdf  s*    q "2661"Q$s(#333r8   c                     [         R                  " SS9   [        S[         R                  " U5      -  -   SU-  U-  -
  sS S S 5        $ ! , (       d  f       g = f)Nrp  rq  rW   r   )rQ   rs  r)   r  r   s     r6   r   maxwell_gen._logpdf  s;    [[)&266!94s1uQw> *))s   )A
Ac                 :    [         R                  " SX-  S-  5      $ Nrd  r   rR  r   s     r6   r{   maxwell_gen._cdf  s    {{3C((r8   c                 ^    [         R                  " S[        R                  " SU5      -  5      $ rp  r[  r   s     r6   r   maxwell_gen._ppf  s!    wwqQ//00r8   c                 :    [         R                  " SX-  S-  5      $ r?  rV  r   s     r6   r   maxwell_gen._sf  s    ||CS))r8   c                 ^    [         R                  " S[        R                  " SU5      -  5      $ rp  r`  r   s     r6   r   maxwell_gen._isf  s!    wwqa0011r8   c                    S[         R                  -  S-
  nS[         R                  " S[         R                  -  5      -  SS[         R                  -  -
  [         R                  " S5      SS[         R                  -  -
  -  US-  -  S[         R                  -  [         R                  -  S	[         R                  -  -   S
-
  US-  -  4$ )Nr  rb  rW   r       r  rd  r     i  rQ   r  r&  rE   r  s     r6   r   maxwell_gen._stats  s    gai"''#bee)$$!BEE'	
Br"%%xK(c1RUU2553ruu9,s2c3h>@ 	@r8   c                 j    [         S[        R                  " S[        R                  -  5      -  -   S-
  $ rQ  )r$   rQ   r  r  rn   s    r6   r  maxwell_gen._entropy  s'    BFF1RUU7O++C//r8   r   r-  r
  r   r8   r6   r4  r4    s;    4B4?
)1*2@0r8   r4  maxwellc                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)
mielke_geni  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )Nrq  Fr   r3  ro  rl   )rE   iki_ss      r6   ro   mielke_gen._shape_info  :    UQK@ea[.Ayr8   c                 >    X!US-
  -  -  SX-  -   SUS-  U-  -   -  -  $ r>  r   rE   rv   rq  ro  s       r6   rw   mielke_gen._pdf  s.    QsU|s14x3quQw;777r8   c                    [         R                  " SS9   [         R                  " U5      [         R                  " U5      US-
  -  -   [         R                  " X-  5      SX#-  -   -  -
  sS S S 5        $ ! , (       d  f       g = f)Nrp  rq  r   )rQ   rs  r  r  rX  s       r6   r   mielke_gen._logpdf  sU    [[)66!9rvvay!a%00288AD>1qs73KK *))s   AA33
Bc                 ,    X-  SX-  -   US-  U-  -  -  $ r>  r   rX  s       r6   r{   mielke_gen._cdf  s"    ts14x1S57+++r8   c                 N    [        XS-  U-  5      n[        USU-
  -  SU-  5      $ r>  rQ  )rE   r   rq  ro  qsks        r6   r   mielke_gen._ppf
  s,    !sU1Wo3C=#a%((r8   c                 H    S n[        X:  XU4U[        R                  5      $ )Nc                     [         R                  " X-   U-  5      [         R                  " SX-  -
  5      -  [         R                  " X-  5      -  $ ra   r<  )re   rq  ro  s      r6   r	  $mielke_gen._munp.<locals>.nth_moment  s9    88QS!G$RXXae_4RXXac]BBr8   rZ  )rE   re   rq  ro  r	  s        r6   r+  mielke_gen._munp  s%    	C !%!J??r8   r   N)r   r   r   r   r   ro   rw   r   r{   r   r+  r   r   r8   r6   rQ  rQ    s(     B
8L
,)@r8   rQ  mielkec                   Z    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rSrg)
kappa4_geni  ap  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                 r    [         R                  " X5      S   R                  n[         R                  " USS9$ )Nr   T
fill_value)rQ   rH  re  full)rE   r  rq  re  s       r6   rf   kappa4_gen._argcheckr  s.    ##A)!,22wwu..r8   c                     [        SS[        R                  * [        R                  4S5      n[        SS[        R                  * [        R                  4S5      nX/$ )Nr  Fr3  rq  rl   )rE   ihrS  s      r6   ro   kappa4_gen._shape_infov  sG    UbffWbff$5~FUbffWbff$5~Fxr8   c           
         [         R                  " US:  US:  5      [         R                  " US:  US:H  5      [         R                  " US:  US:  5      [         R                  " US:*  US:  5      [         R                  " US:*  US:H  5      [         R                  " US:*  US:  5      /nS nS nS nS n[        UXEXFXg/X/[         R                  S9nS nS n[        UXEXTXU/X/[         R                  S9n	X4$ )	Nr   c                 <    S[         R                  " X* 5      -
  U-  $ r>  )rQ   rY  r  rq  s     r6   r  #kappa4_gen._get_support.<locals>.f0  s    "..B//22r8   c                 .    [         R                  " U 5      $ rO   rg  rr  s     r6   r  #kappa4_gen._get_support.<locals>.f1  s    66!9r8   c                     [         R                  " [         R                  " U 5      5      n[         R                  * US S & U$ rO   rQ   r  re  rm   r  rq  r   s      r6   f3#kappa4_gen._get_support.<locals>.f3  s,    !%AFF7AaDHr8   c                     SU-  $ r>  r   rr  s     r6   f5#kappa4_gen._get_support.<locals>.f5      q5Lr8   defaultc                     SU-  $ r>  r   rr  s     r6   r  rs    r~  r8   c                     [         R                  " [         R                  " U 5      5      n[         R                  US S & U$ rO   rw  rx  s      r6   r  ru    s*    !%A66AaDHr8   rQ   r$  r   rF  )
rE   r  rq  condlistr  r  ry  r|  r;  r:  s
             r6   r   kappa4_gen._get_support{  s    NN1q5!a%0NN1q5!q&1NN1q5!a%0NN161q51NN16162NN161q513	3		
	 ""1!#)
		
 ""1!#) vr8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  rE   rv   r  rq  s       r6   rw   kappa4_gen._pdf  r  r8   c                 :   [         R                  " US:g  US:g  5      [         R                  " US:H  US:g  5      [         R                  " US:g  US:H  5      [         R                  " US:H  US:H  5      /nS nS nS nS n[        UXVXx/XU/[         R                  S9$ )Nr   c                     [         R                  " SU-  S-
  U* U -  5      [         R                  " SU-  S-
  U* SX -  -
  SU-  -  -  5      -   $ )zbpdf = (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   r  rv   r  rq  s      r6   r  kappa4_gen._logpdf.<locals>.f0  sX    
 JJs1us{QBqD1JJs1us{QBac	SU/C,CDE Fr8   c                 `    [         R                  " SU-  S-
  U* U -  5      SX -  -
  SU-  -  -
  $ )zTpdf = (1.0 - k*x)**(1.0/k - 1.0)*np.exp(-(
       1.0 - k*x)**(1.0/k))
logpdf = ...
r   r  r  s      r6   r  kappa4_gen._logpdf.<locals>.f1  s7    
 ::c!eckA2a40C!#IQ3GGGr8   c                 v    U * [         R                  " SU-  S-
  U* [        R                  " U * 5      -  5      -   $ )zBpdf = np.exp(-x)*(1.0 - h*np.exp(-x))**(1.0/h - 1.0)
logpdf = ...
r   )r~   r  rQ   r   r  s      r6   r?  kappa4_gen._logpdf.<locals>.f2  s4     2

3q53;2661":>>>r8   c                 8    U * [         R                  " U * 5      -
  $ )z)pdf = np.exp(-x-np.exp(-x))
logpdf = ...
rL  r  s      r6   ry  kappa4_gen._logpdf.<locals>.f3  s     2r
?"r8   r  r  	rE   rv   r  rq  r  r  r  r?  ry  s	            r6   r   kappa4_gen._logpdf  s    NN16162NN16162NN16162NN161624
	F	H	?	# 8B+!9#%66+ 	+r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r  r  s       r6   r{   kappa4_gen._cdf  r  r8   c                 :   [         R                  " US:g  US:g  5      [         R                  " US:H  US:g  5      [         R                  " US:g  US:H  5      [         R                  " US:H  US:H  5      /nS nS nS nS n[        UXVXx/XU/[         R                  S9$ )Nr   c                 X    SU-  [         R                  " U* SX -  -
  SU-  -  -  5      -  $ )z;cdf = (1.0 - h*(1.0 - k*x)**(1.0/k))**(1.0/h)
logcdf = ...
r   rd  r  s      r6   r  kappa4_gen._logcdf.<locals>.f0  s2     E288QBac	SU';$;<<<r8   c                     SX -  -
  SU-  -  * $ )z1cdf = np.exp(-(1.0 - k*x)**(1.0/k))
logcdf = ...
r   r   r  s      r6   r  kappa4_gen._logcdf.<locals>.f1  s     13Y#a%(((r8   c                 l    SU-  [         R                  " U* [        R                  " U * 5      -  5      -  $ )z1cdf = (1.0 - h*np.exp(-x))**(1.0/h)
logcdf = ...
r   )r~   r  rQ   r   r  s      r6   r?  kappa4_gen._logcdf.<locals>.f2  s,     E288QBrvvqbzM222r8   c                 2    [         R                  " U * 5      * $ )z'cdf = np.exp(-np.exp(-x))
logcdf = ...
rL  r  s      r6   ry  kappa4_gen._logcdf.<locals>.f3  s     FFA2J;r8   r  r  r  s	            r6   r  kappa4_gen._logcdf  s    NN16162NN16162NN16162NN161624
	=	)	3	 8B+!9#%66+ 	+r8   c                 :   [         R                  " US:g  US:g  5      [         R                  " US:H  US:g  5      [         R                  " US:g  US:H  5      [         R                  " US:H  US:H  5      /nS nS nS nS n[        UXVXx/XU/[         R                  S9$ )Nr   c                 .    SU-  SSX-  -
  U-  U-  -
  -  $ r>  r   r   r  rq  s      r6   r  kappa4_gen._ppf.<locals>.f0  s&    q5##,!1A 5566r8   c                 H    SU-  S[         R                  " U 5      * U-  -
  -  $ r>  rg  r  s      r6   r  kappa4_gen._ppf.<locals>.f1  s$    q5#"&&)a/00r8   c                 d    [         R                  " X-  * 5      * [        R                  " U5      -   $ )z,ppf = -np.log((1.0 - (q**h))/h)
            r  r  s      r6   r?  kappa4_gen._ppf.<locals>.f2  s'     HHqtW%%q	11r8   c                 Z    [         R                  " [         R                  " U 5      * 5      * $ rO   rg  r  s      r6   ry  kappa4_gen._ppf.<locals>.f3  s    FFBFF1I:&&&r8   r  r  )	rE   r   r  rq  r  r  r  r?  ry  s	            r6   r   kappa4_gen._ppf  s    NN16162NN16162NN16162NN161624
	7	1	2
	' 8B+!9#%66+ 	+r8   c                 n    [         R                  " US:  US:  5      US:  /nS nS n[        X4U/X/SS9$ )Nr   c                 8    SU -  U-  R                  [        5      $ r  astyper*  rr  s     r6   r  &kappa4_gen._get_stats_info.<locals>.f0  s    F1H$$S))r8   c                 2    SU-  R                  [        5      $ r  r  rr  s     r6   r  &kappa4_gen._get_stats_info.<locals>.f1  s    F??3''r8   r  r  )rQ   r$  r   )rE   r  rq  r  r  r  s         r6   _get_stats_infokappa4_gen._get_stats_info  sG    NN1q5!q&)E

	*	( 8"XvqAAr8   c                     U R                  X5      n[        SS5       Vs/ s H2  n[        R                  " XC:  5      (       a  S O[        R                  PM4     nnUS S  $ s  snf Nr   r  )r  rU  rQ   r  rF  )rE   r  rq  maxrrL  outputss         r6   r   kappa4_gen._stats  sU    ##A)AFq!MA266!(++47Mqz Ns   9A c                     U R                  US   US   5      nX:  a  [        R                  $ [        R                  " U R
                  SSU4U-   S9S   $ Nr   r   r  )r  rQ   rF  r   rJ  _mom_integ1)rE   r  rG   r  s       r6   _mom1_sckappa4_gen._mom1_sc!  sP    ##DGT!W5966M~~d..1A49EaHHr8   r   N)r   r   r   r   r   rf   ro   r   rw   r   r{   r  r   r  r   r  r   r   r8   r6   rg  rg    sE    Wp/
'R-
$+L-!+F+2B
Ir8   rg  kappa4c                   V   ^  \ rS rSrSrS rS rS rU 4S jrS r	S r
S	 rS
 rSrU =r$ )
kappa3_geni+  a  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                 @    [        SSS[        R                  4S5      /$ r2  rl   rn   s    r6   ro   kappa3_gen._shape_infoL  r5  r8   c                 &    X"X-  -   SU-  S-
  -  -  $ r  r   r8  s      r6   rw   kappa3_gen._pdfO  s    ad(d1fQh'''r8   c                      XX-  -   SU-  -  -  $ r  r   r8  s      r6   r{   kappa3_gen._cdfS  s    ad(d1f%%%r8   c           	         > [         R                  " X5      u  p[        TU ]  X5      nSnX4:  n[        R
                  " [        R                  " SX%   -  X%   X   X%   * -  -  5      5      * nXd:  nX5   U   Xg'   XcU'   U$ )Ng{Gz?r  )rQ   rH  rA   r   r~   rk  r  )	rE   rv   r   sfcutoffrV  sf2i2r  s	           r6   r   kappa3_gen._sfV  s    ""1(W[
 Kxx

4!$;qtadU{0BCDD\%)1	r8   c                 $    X!U* -  S-
  -  SU-  -  $ r>  r   rA  s      r6   r   kappa3_gen._ppff  s    qb53;3q5))r8   c                 t    [         R                  " U* U* 5      n[         R                  " U5      nX$-  SU-  -  $ r>  r  )rE   r   r   lgr2	  s        r6   r   kappa3_gen._isfi  s4    ZZQB	S1W%%r8   c                     [        SS5       Vs/ s H2  n[        R                  " X!:  5      (       a  S O[        R                  PM4     nnUS S  $ s  snf r  )rU  rQ   r  rF  )rE   r   rV  r  s       r6   r   kappa3_gen._statsn  sC    >CAqkJk266!%==4bff4kJqz Ks   9Ac                     [         R                  " XS   :  5      (       a  [         R                  $ [        R                  " U R
                  SSU4U-   S9S   $ r  )rQ   r  rF  r   rJ  r  )rE   r  rG   s      r6   r  kappa3_gen._mom1_scr  sF    66!Aw,66M~~d..1A49EaHHr8   r   )r   r   r   r   r   ro   rw   r{   r   r   r   r   r  r   r  r   s   @r6   r  r  +  s9    @E(& *&
I Ir8   r  kappa3c                   L    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rSrg)	moyal_geni{  aL  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                     / $ rO   r   rn   s    r6   ro   moyal_gen._shape_info  r   r8   Nc                 \    [         R                  SSUUS9n[        R                  " U5      * $ )Nr   rW   )r   r/   r   r   )r(  r)  rQ   r  )rE   r   r   r*  s       r6   r   moyal_gen._rvs  s.    YYAD$0  2r
{r8   c                     [         R                  " SU[         R                  " U* 5      -   -  5      [         R                  " S[         R                  -  5      -  $ Nr:  rW   )rQ   r   r&  r  r   s     r6   rw   moyal_gen._pdf  s:    vvda"&&!*n-.2551AAAr8   c                     [         R                  " [        R                  " SU-  5      [        R                  " S5      -  5      $ r  )r~   r?
  rQ   r   r&  r   s     r6   r{   moyal_gen._cdf  s+    wwrvvdQh'"''!*455r8   c                     [         R                  " [        R                  " SU-  5      [        R                  " S5      -  5      $ r  )r~   r4  rQ   r   r&  r   s     r6   r   moyal_gen._sf  s+    vvbffTAX&344r8   c                 d    [         R                  " S[        R                  " U5      S-  -  5      * $ rD  )rQ   r  r~   erfcinvr   s     r6   r   moyal_gen._ppf  s&    q2::a=!++,,,r8   c                    [         R                  " S5      [         R                  -   n[         R                  S-  S-  nS[         R                  " S5      -  [
        R                  " S5      -  [         R                  S-  -  nSnXX44$ )NrW      r  r  )rQ   r  euler_gammar  r&  r~   r  r|  s        r6   r   moyal_gen._stats  sc    VVAY'eeQhl"''!*_rwwqz)BEE1H4r8   c                    US:X  a'  [         R                  " S5      [         R                  -   $ US:X  aA  [         R                  S-  S-  [         R                  " S5      [         R                  -   S-  -   $ US:X  a  S[         R                  S-  -  [         R                  " S5      [         R                  -   -  n[         R                  " S5      [         R                  -   S-  nS[        R
                  " S5      -  nX#-   U-   $ US:X  a  S	[        R
                  " S5      -  [         R                  " S5      [         R                  -   -  nS[         R                  S-  -  [         R                  " S5      [         R                  -   S-  -  n[         R                  " S5      [         R                  -   S
-  nS[         R                  S
-  -  S
-  nX#-   U-   U-   $ U R                  U5      $ )Nr   rW   r   r  rd  r  rs  r  8   rU  r  )rQ   r  r  r  r~   r  r  )rE   re   tmp1r  tmp3tmp4s         r6   r+  moyal_gen._munp  sj   866!9r~~--#X55!8a<266!9r~~#="AAA#X>RVVAYr~~%=>DFF1Ibnn,q0D
?D;%%#XBGGAJ&"&&)bnn*DEDruuax<266!9r~~#="AADFF1I.2Druuax<!#D;%,, ==##r8   r   r-  )r   r   r   r   r   ro   r   rw   r{   r   r   r   r+  r   r   r8   r6   r  r  {  s1    )T
B65-$r8   r  moyalc                   h    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSS jrSS jrSrg)nakagami_geni  a  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                     US:  $ r  r   )rE   nus     r6   rf   nakagami_gen._argcheck  r  r8   c                 @    [        SSS[        R                  4S5      /$ )Nr  Fr   r3  rl   rn   s    r6   ro   nakagami_gen._shape_info  rE  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   r  s      r6   rw   nakagami_gen._pdf   r  r8   c                     [         R                  " S5      [        R                  " X"5      -   [        R                  " U5      -
  [        R                  " SU-  S-
  U5      -   X!S-  -  -
  $ r  )rQ   r  r~   r  r  r  s      r6   r   nakagami_gen._logpdf  sX     q	BHHR,,rzz"~=21%&(*a40 	1r8   c                 :    [         R                  " X"U-  U-  5      $ rO   rR  r  s      r6   r{   nakagami_gen._cdf	  s    {{2!tAv&&r8   c                 b    [         R                  " SU-  [        R                  " X!5      -  5      $ r>  r[  )rE   r   r  s      r6   r   nakagami_gen._ppf  s#    wws2vbnnR3344r8   c                 :    [         R                  " X"U-  U-  5      $ rO   rV  r  s      r6   r   nakagami_gen._sf  s    ||B1Q''r8   c                 b    [         R                  " SU-  [        R                  " X!5      -  5      $ ra   r`  )rE   rK  r  s      r6   r   nakagami_gen._isf  s#    wwqtboob4455r8   c                 &   [         R                  " US5      [        R                  " U5      -  nSX"-  -
  nUSSU-  U-  -
  -  S-  U-  [        R                  " US5      -  nSUS-  -  U-  SU-  S	-
  US	-  -  -   S	U-  -
  S-   nXQUS-  -  -  nX#XE4$ )
Nr   r   r   rU  r   rd  rb  rW   )r~   re  rQ   r&  rf  )rE   r  r}  r~  r  r  s         r6   r   nakagami_gen._stats  s    WWRbggbk)"%i1qtCx< 3&+bhhsC.@@AXb[AbDFBE>)!B$.2
ckr8   c                    [         R                  " U5      n[         R                  " U5      n[        R                  " U5      nXS-
  [        R
                  " U5      -  -
  nS[         R                  " U5      -  [         R                  " S5      -
  nX4-   U-   n[        R                  R                  5       nUS:  nXX   U-   SSX   -  -  -
  Xh'   UR                  U5      S   $ )Nr   r:  rW   g     j@r   r  r   )rQ   re  r	  r~   r  rk  r  rI  r.  r  r  )	rE   r  re  r  r  r)  r  norm_entropyrV  s	            r6   r  nakagami_gen._entropy  s    ]]2JJrNs(bjjn,,266":q	)EAIzz**, Htl"Q25\1yy##r8   Nc                 N    [         R                  " UR                  XS9U-  5      $ r  )rQ   r&  r  )rE   r  r   r   s       r6   r   nakagami_gen._rvs.  s$    ww|2222ABFGGr8   c                    [        U[        5      (       a  UR                  5       nUc  SU R                  -  n[        R
                  " U5      n[        R                  " [        R                  " X-
  S-  5      [        U5      -  5      nX#U4-   $ )N)r   rW   )	r?   r*   r  numargsrQ   rg  r&  r  r  )rE   rF   rG   r.   r/   s        r6   r  nakagami_gen._fitstart2  sp    dL))>>#D<DLL(D ffTl
Q/#d);<El""r8   r   r-  rO   )r   r   r   r   r   rf   ro   rw   r   r{   r   r   r   r   r  r   r  r   r   r8   r6   r  r    sE    >F+1'5(6$"H	#r8   r  nakagamic                 .   US-  S-
  n[         R                  " U 5      [         R                  " U5      pT[        R                  " US-  X-  5      SXE-
  S-  -  -
  n[        R                  " X4U-  5      S-  n[        US:  Xg4S [         R                  * S9$ )Nr   r   r   rW   r   c                 4    U [         R                  " U5      -   $ rO   rg  )rL  ra  s     r6   r:  _ncx2_log_pdf.<locals>.<lambda>N  s    q266!9}r8   ri  )rQ   r&  r~   r  iver   rm   )rv   rC  r  df2r 	  nsr  corrs           r6   _ncx2_log_pdfr  B  s     S&3,CWWQZ
((3s7AD
!C1$4
4C66#"u#Dq	
$66'	 r8   c                   X    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rS rS rS rSrg)ncx2_geniR  a  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    US:  [         R                  " U5      -  US:  -  $ r  r  rE   rC  r  s      r6   rf   ncx2_gen._argcheckv  s"    Q"++b/)R1W55r8   c                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )NrC  Fr   r3  r  rk   rl   rE   idfincs      r6   ro   ncx2_gen._shape_infoy  s:    uq"&&k>Buq"&&k=Azr8   Nc                 &    UR                  XU5      $ rO   )noncentral_chisquare)rE   rC  r  r   r   s        r6   r   ncx2_gen._rvs~  s    00>>r8   c                 d    [         R                  " U[        S9US:g  -  n[        XAX#4[        S S9$ )Nr.	  r   c                 ,    [         R                  X5      $ rO   )rG  r   rv   rC  _s      r6   r:  "ncx2_gen._logpdf.<locals>.<lambda>  s    dll1.Ar8   r  )rQ   	ones_likeboolr   r  rE   rv   rC  r  conds        r6   r   ncx2_gen._logpdf  s5    ||AT*bAg6$B}AC 	Cr8   c                     [         R                  " U[        S9US:g  -  n[         R                  " SS9   [	        XAX#4[
        R                  S S9sS S S 5        $ ! , (       d  f       g = f)Nr.	  r   rp  r  c                 ,    [         R                  X5      $ rO   )rG  rw   r*  s      r6   r:  ncx2_gen._pdf.<locals>.<lambda>      $))A2Br8   r  )rQ   r-  r.  rs  r   rs   	_ncx2_pdfr/  s        r6   rw   ncx2_gen._pdf  K    ||AT*bAg6[[h'dK3==!BD (''   A
A(c                     [         R                  " U[        S9US:g  -  n[         R                  " SS9   [	        XAX#4[
        R                  S S9sS S S 5        $ ! , (       d  f       g = f)Nr.	  r   rp  r  c                 ,    [         R                  X5      $ rO   )rG  r{   r*  s      r6   r:  ncx2_gen._cdf.<locals>.<lambda>  r5  r8   r  )rQ   r-  r.  rs  r   rs   	_ncx2_cdfr/  s        r6   r{   ncx2_gen._cdf  r8  r9  c                     [         R                  " U[        S9US:g  -  n[         R                  " SS9   [	        XAX#4[
        R                  S S9sS S S 5        $ ! , (       d  f       g = f)Nr.	  r   rp  r  c                 ,    [         R                  X5      $ rO   )rG  r   r*  s      r6   r:  ncx2_gen._ppf.<locals>.<lambda>  r5  r8   r  )rQ   r-  r.  rs  r   rs   	_ncx2_ppf)rE   r   rC  r  r0  s        r6   r   ncx2_gen._ppf  r8  r9  c                     [         R                  " U[        S9US:g  -  n[         R                  " SS9   [	        XAX#4[
        R                  S S9sS S S 5        $ ! , (       d  f       g = f)Nr.	  r   rp  r  c                 ,    [         R                  X5      $ rO   )rG  r   r*  s      r6   r:  ncx2_gen._sf.<locals>.<lambda>  s    $((1/r8   r  )rQ   r-  r.  rs  r   rs   _ncx2_sfr/  s        r6   r   ncx2_gen._sf  sK    ||AT*bAg6[[h'dK3<<!AC (''r9  c                     [         R                  " U[        S9US:g  -  n[         R                  " SS9   [	        XAX#4[
        R                  S S9sS S S 5        $ ! , (       d  f       g = f)Nr.	  r   rp  r  c                 ,    [         R                  X5      $ rO   )rG  r   r*  s      r6   r:  ncx2_gen._isf.<locals>.<lambda>  r5  r8   r  )rQ   r-  r.  rs  r   rs   	_ncx2_isfr/  s        r6   r   ncx2_gen._isf  r8  r9  c                     X-   nS nSU" XS5      -  n[         R                  " S5      U" XS5      -  [         R                  " U" XS5      S-  5      -  nSU" XS5      -  U" XS5      S-  -  nUUUU4$ )Nc                     XU-  -   $ rO   r   )rq  rN  ra  s      r6   	k_plus_cl"ncx2_gen._stats.<locals>.k_plus_cl  s    s7Nr8   r   r  r  r  r  rW   r  )rE   rC  r  
_ncx2_meanrP  _ncx2_variance_ncx2_skewness_ncx2_kurtosis_excesss           r6   r   ncx2_gen._stats  s    W
		"# 66''#,21)=='')BC"8!";<=!%	"#(>!>!*23!7!:"; !	
 	
r8   r   r-  )r   r   r   r   r   rf   ro   r   r   rw   r{   r   r   r   r   r   r   r8   r6   r  r  R  s@    "F6
?C
DDDCD
r8   r  ncx2c                   V    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rS rSS jrSrg)ncf_geni  a  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                 $    US:  US:  -  US:  -  $ r  r   )rE   r  r  r  s       r6   rf   ncf_gen._argcheck  s    aC!G$a00r8   c                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      n[        SSS[        R                  4S5      nXU/$ )Nr  Fr   r3  r  r  rk   rl   )rE   idf1idf2r#  s       r6   ro   ncf_gen._shape_info  sU    %BFF^D%BFF^Duq"&&k=AC  r8   Nc                 &    UR                  XX45      $ rO   )noncentral_f)rE   r  r  r  r   r   s         r6   r   ncf_gen._rvs  s    ((2<<r8   c                 0    [         R                  " XX45      $ rO   )rs   _ncf_pdfrE   rv   r  r  r  s        r6   rw   ncf_gen._pdf  s    ||AC,,r8   c                 0    [         R                  " X#XA5      $ rO   )r~   ncfdtrre  s        r6   r{   ncf_gen._cdf  s    yy2))r8   c                     [         R                  " SS9   [        R                  " X#XA5      sS S S 5        $ ! , (       d  f       g = fr  )rQ   rs  r~   ncfdtri)rE   r   r  r  r  s        r6   r   ncf_gen._ppf  s(    [[h'::c. (''r  c                 0    [         R                  " XX45      $ rO   )rs   _ncf_sfre  s        r6   r   ncf_gen._sf  s    {{13++r8   c                     [         R                  " SS9   [        R                  " XX45      sS S S 5        $ ! , (       d  f       g = fr  )rQ   rs  rs   _ncf_isfre  s        r6   r   ncf_gen._isf  s(    [[h'<<0 (''r  c                     [         R                  " XU5      n[         R                  " XU5      nSU;   a  [         R                  " XU5      OS nSU;   a  [         R                  " XU5      S-
  OS nXVXx4$ )Nro  rq  r  )rs   	_ncf_mean_ncf_variance_ncf_skewness_ncf_kurtosis_excess)	rE   r  r  r  rt  r}  r~  r  r  s	            r6   r   ncf_gen._stats  sv    ]]3R("-03wSs,D!$ %%b59 	 r8   r   r-  ry  r   r   r   r   r   rf   ro   r   rw   r{   r   r   r   r   r   r   r8   r6   rY  rY    s5    /`1!=-*/,1r8   rY  ncfc                   X    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 rS rS rS rSrg)t_geni  a?  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                 @    [        SSS[        R                  4S5      /$ rB  rl   rn   s    r6   ro   t_gen._shape_info:  rE  r8   Nc                      UR                  XS9$ r  )
standard_trH  s       r6   r   
t_gen._rvs=  s    &&r&55r8   c                 J   ^  [        U[        R                  :H  X4S U 4S jS9$ )Nc                 ,    [         R                  U 5      $ rO   )r.  rw   rv   rC  s     r6   r:  t_gen._pdf.<locals>.<lambda>C  s    DIIaLr8   c                 N   > [         R                  " TR                  X5      5      $ rO   r.  )rv   rC  rE   s     r6   r:  r  D  s    t||A*+r8   r  rZ  rK  s   `  r6   rw   
t_gen._pdf@  s'    "&&L1'(
 	
r8   c                 H    S nS n[        U[        R                  :H  X4XCS9$ )Nc                 &   [         R                  " [        R                  " SU-  S5      5      S[         R                  " U5      [         R                  " [         R                  5      -   -  -
  US-   S-  [         R
                  " X -  U-  5      -  -
  $ r
  )rQ   r  r~   re  r  r  r  s     r6   t_logpdft_gen._logpdf.<locals>.t_logpdfK  sl    FF27738S12RVVBZ"&&-789Avqj!%(!334 5r8   c                 ,    [         R                  U 5      $ rO   )r.  r   r  s     r6   norm_logpdf"t_gen._logpdf.<locals>.norm_logpdfP  s    <<?"r8   r  rZ  )rE   rv   rC  r  r  s        r6   r   t_gen._logpdfI  s'    	5
	# ",	[NNr8   c                 .    [         R                  " X!5      $ rO   r~   stdtrrK  s      r6   r{   
t_gen._cdfU  r  r8   c                 0    [         R                  " X!* 5      $ rO   r  rK  s      r6   r   	t_gen._sfX  s    xxBr8   c                 .    [         R                  " X!5      $ rO   r~   stdtritr]  s      r6   r   
t_gen._ppf[  s    zz"  r8   c                 0    [         R                  " X!5      * $ rO   r  r]  s      r6   r   
t_gen._isf^  s    

2!!!r8   c                 
   [         R                  " U5      n[         R                  " US:  S[         R                  5      nUS:  US:*  -  US:  [         R                  " U5      -  U4nS S S 4n[        XEU4[         R                  5      n[         R                  " US:  S[         R                  5      nUS:  US:*  -  US:  [         R                  " U5      -  U4nS	 S
 S 4n[        XEU4[         R                  5      nX6Xx4$ )Nr   r   rW   c                 `    [         R                  " [         R                  U R                  5      $ rO   rQ   broadcast_torm   re  rl  s    r6   r:  t_gen._stats.<locals>.<lambda>j      !Br8   c                     X S-
  -  $ rv  r   rl  s    r6   r:  r  k  s
    #vr8   c                 D    [         R                  " SU R                  5      $ ra   rQ   r  re  rl  s    r6   r:  r  l      BHH!=r8   r  rU  c                 `    [         R                  " [         R                  U R                  5      $ rO   r  rl  s    r6   r:  r  t  r  r8   c                     SU S-
  -  $ )Nr_  r  r   rl  s    r6   r:  r  u  s    3r8   c                 D    [         R                  " SU R                  5      $ r  r  rl  s    r6   r:  r  v  r  r8   )rQ   isposinfr  rm   r#  r   rF  )	rE   rC  infinite_dfr}  r  
choicelistr~  r  r  s	            r6   r   t_gen._statsa  s    kk"oXXb1fc266*!Va(!Vr{{2.! C.=?
 (rvv>XXb1fc266*!Va(!Vr{{2.! C/=?
 ubff=r8   c                     U[         R                  :X  a  [        R                  5       $ S nS n[	        US:  U4X2S9nU$ )Nc                    U S-  nU S-   S-  nU[         R                  " U5      [         R                  " U5      -
  -  [        R                  " [        R                  " U 5      [         R
                  " US5      -  5      -   $ r	  )r~   rk  rQ   r  r&  r  )rC  halfhalf1s      r6   r  t_gen._entropy.<locals>.regular  se    a4D!VQJE2::e,rzz$/??@ffRWWR[s);;<= >r8   c                     [         R                  5       SU -  -   U S-  S-  -   U S-  S-  -
  U S-  S-  -
  SU S	-  -  -   U S
-  S-  -   nU$ )Nr   r  rU  r  r  r   rb  g333333?r  r  )r.  r  )rC  r  s     r6   r	  "t_gen._entropy.<locals>.asymptotic  sg     1R4'2s7A+5S!CGQ;!%r3w035s7A+>AHr8   d   r  )rQ   rm   r.  r  r   )rE   rC  r  r	  r  s        r6   r  t_gen._entropy{  s>    <==?"	>	 rSy2&JCr8   r   r-  rv  r   r8   r6   r|  r|    s;    <F6

O !"4r8   r|  r  c                   V    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rS rSS jrSrg)nct_geni  aE  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                     US:  X":H  -  $ r  r   r  s      r6   rf   nct_gen._argcheck  s    Q28$$r8   c                     [        SSS[        R                  4S5      n[        SS[        R                  * [        R                  4S5      nX/$ )NrC  Fr   r3  r  rl   r!  s      r6   ro   nct_gen._shape_info  sA    uq"&&k>Buw&7Hzr8   Nc                     [         R                  X#US9n[        R                  XUS9nU[        R                  " U5      -  [        R                  " U5      -  $ )Nr  r'  )r.  r)  rG  rQ   r&  )rE   rC  r  r   r   re   r  s          r6   r   nct_gen._rvs  sE    HH\HBXXb,X?2772;,,r8   c                 0    [         R                  " XU5      $ rO   )rs   _nct_pdfrE   rv   rC  r  s       r6   rw   nct_gen._pdf  s    ||A2&&r8   c                 0    [         R                  " X#U5      $ rO   )r~   nctdtrr  s       r6   r{   nct_gen._cdf  s    yy##r8   c                     [         R                  " SS9   [        R                  " XU5      sS S S 5        $ ! , (       d  f       g = fr  )rQ   rs  rs   _nct_ppf)rE   r   rC  r  s       r6   r   nct_gen._ppf  (    [[h'<<r* (''r  c                     [         R                  " SS9   [         R                  " [        R                  " XU5      SS5      sS S S 5        $ ! , (       d  f       g = f)Nrp  r  r   r   )rQ   rs  cliprs   _nct_sfr  s       r6   r   nct_gen._sf  s5    [[h'773;;qb11a8 (''s   -A
Ac                     [         R                  " SS9   [        R                  " XU5      sS S S 5        $ ! , (       d  f       g = fr  )rQ   rs  rs   _nct_isfr  s       r6   r   nct_gen._isf  r  r  c                     [         R                  " X5      n[         R                  " X5      nSU;   a  [         R                  " X5      OS nSU;   a  [         R                  " X5      OS nXEXg4$ )Nro  rq  )rs   	_nct_mean_nct_variance_nct_skewness_nct_kurtosis_excess)rE   rC  r  rt  r}  r~  r  r  s           r6   r   nct_gen._stats  sZ    ]]2"'*-.Sr&d14S%%b-Tr8   r   r-  ry  ry  r   r8   r6   r  r    s5    @%
-
'$+9+r8   r  nctc                      ^  \ rS rSrSrS rS rS rS rS r	S r
SS	 jrS
 r\\" \5      U 4S j5       5       rSrU =r$ )
pareto_geni  a   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                 @    [        SSS[        R                  4S5      /$ r  rl   rn   s    r6   ro   pareto_gen._shape_info  r5  r8   c                     X!U* S-
  -  -  $ ra   r   r  s      r6   rw   pareto_gen._pdf  s    r!t9}r8   c                     SX* -  -
  $ ra   r   r  s      r6   r{   pareto_gen._cdf  s    1r7{r8   c                 &    [        SU-
  SU-  5      $ )Nr   r  rQ  r  s      r6   r   pareto_gen._ppf  s    1Q3Qr8   c                     X* -  $ rO   r   r  s      r6   r   pareto_gen._sf   s    2wr8   c                 6    [         R                  " USU-  5      $ r  r  r  s      r6   r   pareto_gen._isf   s    xx4!8$$r8   c                    Su  p4pVSU;   an  US:  n[         R                  " Xq5      n[         R                  " [         R                  " U5      [         R                  S9n[         R
                  " X7XS-
  -  5        SU;   aw  US:  n[         R                  " Xq5      n[         R                  " [         R                  " U5      [         R                  S9n[         R
                  " XGXS-
  -  US-
  S-  -  5        S	U;   a  US
:  n[         R                  " Xq5      n[         R                  " [         R                  " U5      [         R                  S9nSUS-   -  [         R                  " US-
  5      -  US-
  [         R                  " U5      -  -  n	[         R
                  " XWU	5        SU;   a  US:  n[         R                  " Xq5      n[         R                  " [         R                  " U5      [         R                  S9nS[         R                  " / SQU5      -  [         R                  " / SQU5      -  n	[         R
                  " XgU	5        X4XV4$ )Nr	  r  r   ri  r   r  rW   r   ro  r  r  rq  rU  r_  )r   r   r  r;  )r   g      r  r   )	rQ   extractrk  re  rm   placerF  r&  r
  )
rE   r   rt  r}  r~  r  r  maskbtr  s
             r6   r   pareto_gen._stats   s   0'>q5DD$B!8BHHRrV}-'>q5DD$B''"((1+"&&9CHHSfC! ;<'>q5DD$B!8BS>BGGBH$55"s(bggbk9QRDHHRt$'>q5DD$B!8B

#5r::JJ5r:;DHHRt$r8   c                 @    SSU-  -   [         R                  " U5      -
  $ r  rg  rE   r   s     r6   r  pareto_gen._entropy#       3q5y266!9$$r8   c                 L  >^^^^^^^ [        U TX#5      nUu  mmpVUb?  [        R                  " T5      U-
  U=(       d    S:  a  [        SS[        R                  S9eTR
                  S   mUU4S jmXVs=L a  GcS  O  GOOU4S jmU4S jmUUUUU4S jmU4S	 jn[        UR                  S
S5      5      nUS-  US-  pU" X5      (       dO  U	S:  d  U
[        R                  :  a5  U	S-  n	U
S-  n
U" X5      (       d  U	S:  a  M  U
[        R                  :  a  M5  [        TX/S9nUR                  (       a  UR                  n[        R                  " T5      U-
  nT=(       d    T" X5      nX-   [        R                  " T5      :  d0  [        R                  " T5      U-
  n[        R                  " US5      nXU4$ [        TU ]4  " T40 UD6$ Uc  [        R                  " T5      U-
  nOUnU=(       d    [        R                  " T5      U-
  nT=(       d    T" X5      nXU4$ )Nr   paretor   r  c                 j   > T[         R                  " [         R                  " TU-
  U -  5      5      -  $ rO   r  )r/   locationrF   ndatas     r6   	get_shape!pareto_gen.fit.<locals>.get_shape3   s+     266"&&$/U)B"CDDDr8   c                    > TU -  U-  $ rO   r   )re  r/   r  s     r6   	dL_dScale!pareto_gen.fit.<locals>.dL_dScale>   s     u}u,,r8   c                 H   > U S-   [         R                  " STU-
  -  5      -  $ ra   r  )re  r  rF   s     r6   dL_dLocation$pareto_gen.fit.<locals>.dL_dLocationC   s&     	RVVA,A%BBBr8   c                 z   > [         R                  " T5      U -
  nT=(       d    T" X5      nT" X!5      T" X 5      -
  $ rO   )rQ   rg  )r/   r  re  r  r  rF   r  r  s      r6   r  $pareto_gen.fit.<locals>.fun_to_solveH   s;     66$<%/<)E"<#E4y7NNNr8   c                 v   > [         R                  " T" U 5      5      [         R                  " T" U5      5      :g  $ rO   rP   rS   rT   r  s     r6   rU   .pareto_gen.fit.<locals>.interval_contains_rootO   s/    V 45V 456 7r8   r/   rW   r  )rj  rQ   rg  r  rm   re  r  r=   r+   r  rk  r  rA   rC   )rE   rF   rG   r5   r  r  r  rU   r  rS   rT   r  r/   r.   re  r  r  r  r  r  r  r  s    `             @@@@@@r6   rC   pareto_gen.fit&   s    1tTH
%/"fd tt 3v{ Cxq??

1	E
 !!-
C
O O7  ! 45K(1_kAoF .f==
frvvo!! .f==
frvvo lV4DEC}}ffTlU*7)E"7 rvvd|3FF4L3.ELL2E5((w{40400\&&,'CC ,"&&,,/)E/5  r8   r   ry  )r   r   r   r   r   ro   rw   r{   r   r   r   r   r  rL   r   r   rC   r   r  r   s   @r6   r  r    sT    *E %6% M*R! + R!r8   r  r  c                   T    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rSrg)	lomax_geni   aw  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   lomax_gen._shape_info   r5  r8   c                 $    US-  SU-   US-   -  -  $ r>  r   re  s      r6   rw   lomax_gen._pdf   s    uc!equ%%%r8   c                 h    [         R                  " U5      US-   [        R                  " U5      -  -
  $ ra   r  re  s      r6   r   lomax_gen._logpdf   s&    vvayAaC!,,,r8   c                 `    [         R                  " U* [         R                  " U5      -  5      * $ rO   rj  re  s      r6   r{   lomax_gen._cdf   s"    !BHHQK(((r8   c                 ^    [         R                  " U* [        R                  " U5      -  5      $ rO   )rQ   r   r~   r  re  s      r6   r   lomax_gen._sf   s    vvqb!n%%r8   c                 6    U* [         R                  " U5      -  $ rO   rd  re  s      r6   r	  lomax_gen._logsf   s    r"((1+~r8   c                 `    [         R                  " [         R                  " U* 5      * U-  5      $ rO   rj  rl  s      r6   r   lomax_gen._ppf   s!    xx1"a((r8   c                     USU-  -  S-
  $ r  r   rl  s      r6   r   lomax_gen._isf   s    4!8}q  r8   c                 :    [         R                  USSS9u  p#pEX#XE4$ )Nr  r  )r.   rt  )r  rI  r  s         r6   r   lomax_gen._stats   s$     ,,qdF,Cr8   c                 @    SSU-  -   [         R                  " U5      -
  $ r  rg  r  s     r6   r  lomax_gen._entropy   s    Qwrvvay  r8   r   N)r   r   r   r   r   ro   rw   r   r{   r   r	  r   r   r   r  r   r   r8   r6   r  r     s:    .E&-)&)!!r8   r  lomaxc                      ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSS jrS r\\" \SS9U 4S j5       5       rSrU =r$ )pearson3_geni   a  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                     SnSnSn[         R                  " SX5      u  panUR                  5       n[         R                  " U5      U:  nU) nSX(   U-  -  n	XI-  S-  n
X:U	-  -
  nXU   U-
  -  nXaXXX4$ )Nr   r   g>r   rW   )rQ   rH  copyr8	  )rE   rv   rb  r.   r/   norm2pearson_transitionansr  invmaskr  rK  r  transxs                r6   _preprocesspearson3_gen._preprocess   s    
  #+**38hhj {{4 #::%dme+,!T\!7d*+vWE??r8   c                 .    [         R                  " U5      $ rO   r  )rE   rb  s     r6   rf   pearson3_gen._argcheck!  s    
 {{4  r8   c                 ^    [        SS[        R                  * [        R                  4S5      /$ )Nrb  Fr3  rl   rn   s    r6   ro   pearson3_gen._shape_info!  s%    65BFF7BFF*;^LMMr8   c                 &    SnSnUnSUS-  -  nX#XE4$ )Nr   r   rd  rW   r   )rE   rb  r  r  ro  rq  s         r6   r   pearson3_gen._stats!  s(    aKQzr8   c                     [         R                  " U R                  X5      5      nUR                  S:X  a  [         R                  " U5      (       a  gU$ SU[         R                  " U5      '   U$ )Nr   r   )rQ   r   r   r  rK  )rE   rv   rb  r  s       r6   rw   pearson3_gen._pdf!  sR    
 ffT\\!*+88q=xx}}J BHHSM
r8   c                     U R                  X5      u  p1pEpgp[        R                  " [        X   5      5      X5'   [        R                  " [	        U5      5      [
        R                  XH5      -   X6'   U$ rO   )r!  rQ   r  r   r  r(  rO  )
rE   rv   rb  r  r   r  r  r  rK  r+  s
             r6   r   pearson3_gen._logpdf$!  sa     Q% 	6gU FF9QW-.	 vvc$i(5<<+FF
r8   c                    U R                  X5      u  p1pEpgp[        X   5      X5'   [        R                  " X&R                  5      n[        R
                  " XbS:  5      n	X&   S:  n
[        R                  XJ   X   5      X9'   [        R
                  " XbS:  5      nX&   S:  n[        R                  XL   X   5      X;'   U$ r  )	r!  r   rQ   r  re  r$  r(  r   r  rE   rv   rb  r  r   r  r  r+  rK  	invmask1a	invmask1b	invmask2a	invmask2bs                r6   r{   pearson3_gen._cdf3!  s    Q% 	3g% ag&	t]]3NN71H5	MA%	 6#4e6FG NN71H5	MA%	&"3U5EF
r8   c                    U R                  X5      u  p1pEpgp[        X   5      X5'   [        R                  " X&R                  5      n[        R
                  " XbS:  5      n	X&   S:  n
[        R                  XJ   X   5      X9'   [        R
                  " XbS:  5      nX&   S:  n[        R                  XL   X   5      X;'   U$ r  )	r!  r   rQ   r  re  r$  r(  r  r   r.  s                r6   r   pearson3_gen._sfK!  s    Q% 	3g% QW%	t]]3NN71H5	MA%	&"3U5EFNN71H5	MA%	6#4e6FG
r8   c                    [         R                  " X5      nU R                  S/U5      u  n  pVpxpUR                  5       nUR                  U-
  nUR                  U5      XF'   UR                  X5      U-  U
-   XG'   US:X  a  US   nU$ )Nr   r   )rQ   r  r!  r  r   r   r  )rE   rb  r   r   r  r+  r  r  r  rK  r  nsmallnbigs                r6   r   pearson3_gen._rvs\!  s    t*aS$' 	4Q yy6! 008	#225?DtK2:a&C
r8   c                     U R                  X5      u  p1pEpgp[        X   5      X5'   X   nSXS:     -
  XS:  '   [        R                  " X5      U-  U	-   X6'   U$ r  )r!  r   r~   r\  )
rE   r   rb  r  r+  r  r  r  rK  r  s
             r6   r   pearson3_gen._ppfj!  sf    Q% 	4ag&	J!1H+o(~~e/4t;
r8   ze        Note that method of moments (`method='MM'`) is not
        available for this distribution.

r  c                    > UR                  SS 5      S:X  a  [        S5      e[        [        U 5      U ]  " U/UQ70 UD6$ )Nr1   MMzhFit `method='MM'` is not available for the Pearson3 distribution. Please try the default `method='MLE'`.)r=   NotImplementedErrorrA   rB   rC   r  s       r6   rC   pearson3_gen.fits!  sO    
 88Hd#t+% 'D E E dT.tCdCdCCr8   r   r-  )r   r   r   r   r   r!  rf   ro   r   rw   r   r{   r   r   r   rL   r	   r   rC   r   r  r   s   @r6   r  r     sg    ,Z@8!N0" } 50 1D1 Dr8   r  pearson3c                      ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rU 4S jr\\" \SS9U 4S j5       5       rSrU =r$ )powerlaw_geni!  a\  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                 @    [        SSS[        R                  4S5      /$ r2  rl   rn   s    r6   ro   powerlaw_gen._shape_info!  r5  r8   c                     X!US-
  -  -  $ r>  r   r8  s      r6   rw   powerlaw_gen._pdf!  s    QsU|r8   c                 d    [         R                  " U5      [        R                  " US-
  U5      -   $ ra   )rQ   r  r~   r  r8  s      r6   r   powerlaw_gen._logpdf!  s$    vvay288AE1---r8   c                     XS-  -  $ r>  r   r8  s      r6   r{   powerlaw_gen._cdf!  s    S5zr8   c                 4    U[         R                  " U5      -  $ rO   rg  r8  s      r6   r  powerlaw_gen._logcdf!  ri  r8   c                      [        USU-  5      $ r>  rQ  rA  s      r6   r   powerlaw_gen._ppf!  s    1c!e}r8   c                 0    [         R                  " X5      * $ rO   )r~   r  )rE   rK  r   s      r6   r   powerlaw_gen._sf!  s    r8   c                     X"U-   -  $ rO   r   r  s      r6   r+  powerlaw_gen._munp!  s    E{r8   c                     XS-   -  XS-   -  US-   S-  -  SUS-
  US-   -  -  [         R                  " US-   U-  5      -  S[         R                  " / SQU5      -  XS-   -  US-   -  -  4$ )	Nr   r   rW   r  r  r  )r   r  r  rW   rU  )rQ   r&  r
  rG  s     r6   r   powerlaw_gen._stats!  s    WWSQ.SQW-.!c'Q1GGBJJ~q11Qc']a!e5LMO 	Or8   c                 @    SSU-  -
  [         R                  " U5      -
  $ r  rg  rG  s     r6   r  powerlaw_gen._entropy!  r  r8   c                 :   > [         TU ]  X5      US:g  US:  -  -  $ r   )rA   rJ  )rE   rv   r   r  s      r6   rJ  powerlaw_gen._support_mask!  s*    %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                   >^^^^^^^^ UR                  SS5      (       a  [        TU ]  " T/UQ70 UD6$ [        [        R
                  " T5      5      S:X  a  [        TU ]  " T/UQ70 UD6$ [        U TX#5      u  mmpETU R                  T5      4/nU R                  U0 5      S   nUbG  TR                  5       U:  d  [        SSS5      eUb#  TR                  5       XE-   ::  d  [        SSS5      eUb8  US::  a  [        S5      eU[        R                  " T5      ::  a  Sn[        U5      eS mS	 mUb  Ub  T" TXE5      XE4$ Ub  [        R                  " TR                  5       [        R                  * 5      n	T=(       d	    T" TX5      n
U" XU4T5      n[        R                  " TR                  5       U-
  [        R                  5      nT=(       d	    T" TX5      nU" XU4T5      nX:  a  XU4$ XU4$ Ub  T" TU5      nT=(       d	    T" TXO5      nUXO4$ UUUU4S
 jnS mS mUUUUU4S jmUUUUUU4S jmUUUUUU4S jnTb  TS::  a  U" 5       $ Tb  TS:  a  U" 5       $ U" 5       nU R!                  UT5      nU" 5       nU R!                  UT5      nX::  a  US   S::  a  U$ X:  a  US   S:  a  U$ [        TU ]  " T/UQ70 UD6$ )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                     [        U 5      nU* [        R                  " [        R                  " X-
  5      5      U[        R                  " U5      -  -
  -  $ rO   )r  rQ   r  r  )rF   r.   r/   r	  s       r6   r  #powerlaw_gen.fit.<locals>.get_shape"  s?     D	A3"&&
!34qFGGr8   c                 (    U R                  5       U-
  $ rO   )rL  )rF   r.   s     r6   	get_scale#powerlaw_gen.fit.<locals>.get_scale"  s     88:##r8   c                    > [         R                  " TR                  5       [         R                  * 5      n [         R                  " U 5      [         R
                  " U R                  5      R                  :  aA  [         R                  " U 5      [         R
                  " U R                  5      R                  -  n [         R                  " T" TU 5      [         R                  5      nT=(       d	    T" TX5      nX U4$ rO   )	rQ   r  rg  rm   r  r  r/	  r  rR   )r.   r/   re  rF   r  r^  r  s      r6   fit_loc_scale_w_shape_lt_14powerlaw_gen.fit.<locals>.fit_loc_scale_w_shape_lt_1="  s    ,,txxzBFF73Cvvc{RXXcii0555ggclRXXcii%8%=%==LL4!5rvv>E9ic9Eu$$r8   c                 .    U R                   S   * U-  U-  $ r  )re  )rF   re  r/   s      r6   r  #powerlaw_gen.fit.<locals>.dL_dScaleL"  s     JJqM>E)E11r8   c                 D    US-
  [         R                  " SX -
  -  5      -  $ ra   r  )rF   re  r.   s      r6   r  &powerlaw_gen.fit.<locals>.dL_dLocationQ"  s#     AISZ(8!999r8   c                    > [         R                  " T" TU 5      [         R                  * 5      nT=(       d	    T" TX5      nT" TX 5      $ rO   rQ   r  rm   )r.   r/   re  r  rF   r  r^  r  s      r6   dL_dLocation_star+powerlaw_gen.fit.<locals>.dL_dLocation_starV"  s@     LL4!5w?E9ic9Ee11r8   c                    > [         R                  " T" TU 5      [         R                  * 5      nT=(       d	    T" TX5      nT" TX!5      T" TX 5      -
  $ rO   rh  )	r.   r/   re  r  r  rF   r  r^  r  s	      r6   r  &powerlaw_gen.fit.<locals>.fun_to_solve]"  sQ     LL4!5w?E9ic9EdE1"445 6r8   c                    > [         R                  " T
R                  5       [         R                  * 5      n T
R                  5       U -
  nT	" U 5      S:  a&  T
R                  5       U-
  n US-  nT	" U 5      S:  a  M&  U4S jnU S-
  nSnU" X05      (       dQ  U[         R                  * :w  a<  T
R                  5       U-
  nUS-  nU" X05      (       d  U[         R                  * :w  a  M<  [        R
                  " TX04S9n[         R                  " UR                  [         R                  * 5      n[         R                  " T" T
U5      [         R                  5      nT=(       d	    T" T
Xg5      nXU4$ )Nr   rW   c                 v   > [         R                  " T" U 5      5      [         R                  " T" U5      5      :g  $ rO   rP   r  s     r6   rU   Tpowerlaw_gen.fit.<locals>.fit_loc_scale_w_shape_gt_1.<locals>.interval_contains_rootq"  s/    V 4577<#789 :r8   r   r   r  )rQ   r  rg  rm   r   r+   rk  )rT   rR	  rU   rS   rV  rk  r.   r/   re  ri  rF   r  r  r^  r  s            r6   fit_loc_scale_w_shape_gt_14powerlaw_gen.fit.<locals>.fit_loc_scale_w_shape_gt_1e"  s3    \\$((*rvvg6F XXZ&(E#F+a/e+
 $F+a/:
 aZF
 A-f=="&&(((*q.Q .f=="&&( ''v>NOD,,tyy266'2CLL4!5rvv>E9ic9Eu$$r8   )r3   rA   rC   r  rQ   uniquerj  r  _reduce_funcrg  r  rL  r!  ptpr  rm   r  )rE   rF   rG   r5   r  r  penalized_nllf_argspenalized_nllfr[   loc_lt1	shape_lt1ll_lt1loc_gt1	shape_gt1ll_gt1r/   re  ra  rp  fit_shape_lt1fit_shape_gt1r  ri  r  r  r  r^  r  r  s    `                   @@@@@@@r6   rC   powerlaw_gen.fit!  s   P 88J&&7;t3d3d33ryy1$7;t3d3d33%@tAE&M"fd#dnnT&:%<=**+>CAF
 88:$":q!44!$((**E":q!44{  "F G G%H o%	H	$ $"2T40$>> ll488:w7GB)D'"BI#Y$@$GF ll488:#6?GB)D'"BI#Y$@$GF 611 611 dD)E:id:E$%%
	% 	%	2
	:
	2 	2	6 	6!	% !	%H &A+-//FQJ-// 34=$/24=$/a 0A 5  _q!1A!5  7;t3d3d33r8   r   )r   r   r   r   r   ro   rw   r   r{   r  r   r   r+  r   r  rJ  rL   r	   r   rC   r   r  r   s   @r6   rB  rB  !  sl    @E.O%) } 5 H4 H4r8   rB  rZ  c                   `    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rS
 rSrg)powerlognorm_geni"  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )Nra  Fr   r3  ro  rl   )rE   r  rT  s      r6   ro   powerlognorm_gen._shape_info"  rV  r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  rE   rv   ra  ro  s       r6   rw   powerlognorm_gen._pdf"  r  r8   c                 $   [         R                  " U5      [         R                  " U5      -
  [         R                  " U5      -
  [        [         R                  " U5      U-  5      -   [        [         R                  " U5      * U-  5      US-
  -  -   $ r>  rQ   r  r   r   r  s       r6   r   powerlognorm_gen._logpdf"  si    q	BFF1I%q	1RVVAY]+,bffQiZ!^,B78 	9r8   c                 P    [         R                  " U R                  XU5      5      * $ rO   r  r  s       r6   r{   powerlognorm_gen._cdf"  r  r8   c                 ,    U R                  SU-
  X#5      $ ra   )r   rE   r   ra  ro  s       r6   r   powerlognorm_gen._ppf"  s    yyQ%%r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r  r  s       r6   r   powerlognorm_gen._sf"  r  r8   c                 N    [        [        R                  " U5      * U-  5      U-  $ rO   rx  r  s       r6   r	  powerlognorm_gen._logsf"  s     RVVAYJN+a//r8   c                 T    [         R                  " [        USU-  -  5      * U-  5      $ ra   r
  r  s       r6   r   powerlognorm_gen._isf"  s&    vvyQqS**Q.//r8   r   N)r   r   r   r   r   r   rI  rJ  ro   rw   r   r{   r   r   r	  r   r   r   r8   r6   r  r  "  s<    . "44M
-9
/&,00r8   r  powerlognormc                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)powernorm_geni"  a(  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   powernorm_gen._shape_info"  r5  r8   c                 D    U[        U5      -  [        U* 5      US-
  -  -  $ r>  r   r   re  s      r6   rw   powernorm_gen._pdf"  s$    1~A23!788r8   c                 l    [         R                  " U5      [        U5      -   US-
  [        U* 5      -  -   $ ra   r  re  s      r6   r   powernorm_gen._logpdf"  s.    vvay<?*ac<3C-CCCr8   c                 N    [         R                  " U R                  X5      5      * $ rO   r  re  s      r6   r{   powernorm_gen._cdf #  s    Q*+++r8   c                 :    [        [        SU-
  SU-  5      5      * $ r>  )r   r  rl  s      r6   r   powernorm_gen._ppf#  s    #cAgsQw/000r8   c                 L    [         R                  " U R                  X5      5      $ rO   r  re  s      r6   r   powernorm_gen._sf#  rO  r8   c                      U[        U* 5      -  $ rO   r   re  s      r6   r	  powernorm_gen._logsf	#  s    <###r8   c                 p    [        [        R                  " [        R                  " U5      U-  5      5      * $ rO   )r   rQ   r   r  rl  s      r6   r   powernorm_gen._isf#  s%    "&&Q/000r8   r   N)r   r   r   r   r   ro   rw   r   r{   r   r   r	  r   r   r   r8   r6   r  r  "  s1    6E9D,1)$1r8   r  	powernormc                   L    \ rS rSrSrS rS rS rS rS r	S r
SS
 jrS rSrg	)	rdist_geni#  a  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                 @    [        SSS[        R                  4S5      /$ r`  rl   rn   s    r6   ro   rdist_gen._shape_info5#  r5  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  re  s      r6   rw   rdist_gen._pdf9#  ru  r8   c                 x    [         R                  " S5      * [        R                  US-   S-  US-  US-  5      -   $ r  )rQ   r  r  r   re  s      r6   r   rdist_gen._logpdf<#  s4    q	zDLL!a%AaC1===r8   c                 H    [         R                  US-   S-  US-  US-  5      $ rf  r=  re  s      r6   r{   rdist_gen._cdf?#  s%    yy!a%AaC1--r8   c                 H    [         R                  US-   S-  US-  US-  5      $ rf  r5  re  s      r6   r   rdist_gen._sfB#  s%    xxQ	1Q3!,,r8   c                 F    S[         R                  XS-  US-  5      -  S-
  $ r  )r  r   rl  s      r6   r   rdist_gen._ppfE#  s%    1c1Q3''!++r8   Nc                 @    SUR                  US-  US-  U5      -  S-
  $ r  r  r  s       r6   r   rdist_gen._rvsH#  s)    <$$QqS!A#t44q88r8   c                     SUS-  -
  [         R                  " US-   S-  US-  5      -  nU[         R                  " SUS-  5      -  $ )Nr   rW   r   r   r   r  )rE   re   ra  	numerators       r6   r+  rdist_gen._munpK#  sE    !a%[BGGQWM1s7$CC	27761r6222r8   r   r-  )r   r   r   r   r   ro   rw   r   r{   r   r   r   r+  r   r   r8   r6   r  r  #  s1     BE*>.-,93r8   r  r  rdistc                      ^  \ rS rSrSr\R                  rS rSS jr	S r
S rS rS rS	 rS
 rS rS rS r\\" \SS9U 4S j5       5       rSrU =r$ )rayleigh_geniS#  a  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                     / $ rO   r   rn   s    r6   ro   rayleigh_gen._shape_infok#  r   r8   c                 *    [         R                  SXS9$ )NrW   r'  r8  r   s      r6   r   rayleigh_gen._rvsn#  s    wwqtw??r8   c                 L    [         R                  " U R                  U5      5      $ rO   r.  rE   rL  s     r6   rw   rayleigh_gen._pdfq#  r  r8   c                 @    [         R                  " U5      SU-  U-  -
  $ r  rg  r  s     r6   r   rayleigh_gen._logpdfu#  s    vvay37Q;&&r8   c                 <    [         R                  " SUS-  -  5      * $ r  rR  r  s     r6   r{   rayleigh_gen._cdfx#  s    1%%%r8   c                 ^    [         R                  " S[        R                  " U* 5      -  5      $ Nr;  )rQ   r&  r~   r  r   s     r6   r   rayleigh_gen._ppf{#  s     wwrBHHaRL())r8   c                 L    [         R                  " U R                  U5      5      $ rO   r  r  s     r6   r   rayleigh_gen._sf~#  s    vvdkk!n%%r8   c                     SU-  U-  $ )Nr:  r   r  s     r6   r	  rayleigh_gen._logsf#  s    ax!|r8   c                 \    [         R                  " S[         R                  " U5      -  5      $ r  )rQ   r&  r  r   s     r6   r   rayleigh_gen._isf#  s    wwrBFF1I~&&r8   c                 <   S[         R                  -
  n[         R                  " [         R                  S-  5      US-  S[         R                  S-
  -  [         R                  " [         R                  5      -  US-  -  S[         R                  -  U-  SUS-  -  -
  4$ )NrU  rW   r  rd  r  r`  rJ  rK  s     r6   r   rayleigh_gen._stats#  sy    "%%ia A2557BGGBEEN*383"%%BsAvI%' 	'r8   c                 N    [         S-  S-   S[        R                  " S5      -  -
  $ )Nr   r   r   rW   rX  rn   s    r6   r  rayleigh_gen._entropy#  s!    czA~BFF1I--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                   >^ UR                  SS5      (       a  [        TU ]  " T/UQ70 UD6$ [        U TX#5      u  mpEU4S jnU4S jnU4U4S jjnUbC  [        R
                  " TU-
  S:*  5      (       a  [        SS[        R                  S	9eXF" U5      4$ UR                  S
5      n	U	c  U R                  T5      S   n	Uc  UOUn
[        R                  " [        R                  " T5      [        R                  * 5      n[        X5      n[        R                  " XU4S9nUR                  (       d  [!        UR"                  5      eUR$                  nU=(       d    U" U5      nX4$ )Nr\  Fc                 `   > [         R                  " TU -
  S-  5      S[        T5      -  -  S-  $ rZ  )rQ   r  r  )r.   rF   s    r6   	scale_mle#rayleigh_gen.fit.<locals>.scale_mle#  s/     FFD3J1,-SY?BFFr8   c                    > TU -
  nUR                  5       nUS-  R                  5       nSU-  R                  5       nX#S[        T5      -  -  U-  -
  $ r  )r  r  )r.   rP	  r  r  s3rF   s        r6   loc_mle!rayleigh_gen.fit.<locals>.loc_mle#  sR     BBa%BB$BAc$iK(+++r8   c                 b   > TU -
  nUR                  5       US-  SU-  R                  5       -  -
  $ r  )r  )r.   r/   rP	  rF   s      r6   loc_mle_scale_fixed-rayleigh_gen.fit.<locals>.loc_mle_scale_fixed#  s2     B668eQh!B$555r8   r   rayleighr   r  r.   r  )r3   rA   rC   rj  rQ   r  r  rm   r=   r  r  rg  r\   r   r+   r  rY   flagrk  )rE   rF   rG   r5   r  r  r  r  r  loc0rI   rT   rS   r  r.   r/   r  s    `              r6   rC   rayleigh_gen.fit#  sB    88J&&7;t3d3d338t9=Ed	G
	, ,2 	6 vvdTkQ&''":QbffEEYt_,, xx<>>$'*Dg-@bffTlRVVG4"3/""30@A}} **hh()C.zr8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r   r{   r   r   r	  r   r   r  rL   r	   rC   r   r  r   s   @r6   r  r  S#  su    * "44M@''&*&''. } 5. /// /r8   r  r  c                      ^  \ rS rSrSrS rS rU 4S jrS rS r	S r
S	 rS
 rS rS rSr\" \\S9U 4S j5       rSrU =r$ )reciprocal_geni#  a  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                     US:  X!:  -  $ r  r   r9	  s      r6   rf   reciprocal_gen._argcheck$  s    A!%  r8   c                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ r  rl   r  s      r6   ro   reciprocal_gen._shape_info$  r  r8   c                    > [        U[        5      (       a  UR                  5       n[        TU ]  U[
        R                  " U5      [
        R                  " U5      4S9$ Nr  r?   r*   r  rA   r  rQ   rg  rL  rz  s     r6   r  reciprocal_gen._fitstart$  sF    dL))>>#Dw RVVD\266$<,H IIr8   c                     X4$ rO   r   r9	  s      r6   r   reciprocal_gen._get_support$  r~  r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  r  s       r6   rw   reciprocal_gen._pdf$  r0  r8   c                     [         R                  " U5      * [         R                  " [         R                  " U5      [         R                  " U5      -
  5      -
  $ rO   rg  r  s       r6   r   reciprocal_gen._logpdf$  s5    q	zBFF266!9rvvay#8999r8   c                     [         R                  " U5      [         R                  " U5      -
  [         R                  " U5      [         R                  " U5      -
  -  $ rO   rg  r  s       r6   r{   reciprocal_gen._cdf$  s7    q	"&&)#q	BFF1I(=>>r8   c                     [         R                  " [         R                  " U5      U[         R                  " U5      [         R                  " U5      -
  -  -   5      $ rO   rQ   r   r  r  s       r6   r   reciprocal_gen._ppf$  s8    vvbffQi!RVVAY%:";;<<r8   c                 B   US:X  a  gS[         R                  " U5      [         R                  " U5      -
  -  U-  n[         R                  " [         R                  " [	        U[         R                  " U5      -  U[         R                  " U5      -  5      5      5      nXE-  $ )Nr   r   r   )rQ   r  r(  r   	_log_diff)rE   re   r   r   r  r  s         r6   r+  reciprocal_gen._munp!$  sm    6"&&)bffQi'(1,WWRVVIa"&&)mQrvvay[ABCwr8   c                     S[         R                  " U5      [         R                  " U5      -   -  [         R                  " [         R                  " U5      [         R                  " U5      -
  5      -   $ r  rg  r9	  s      r6   r  reciprocal_gen._entropy($  sE    BFF1Iq	)*RVVBFF1Iq	4I-JJJr8   z        `loguniform`/`reciprocal` is over-parameterized. `fit` automatically
         fixes `scale` to 1 unless `fscale` is provided by the user.

r  c                 T   > UR                  SS5      n[        TU ]  " U/UQ7SU0UD6$ )Nr  r   )r3   rA   rC   )rE   rF   rG   r5   r  r  s        r6   rC   reciprocal_gen.fit/$  s1    (A&w{4>$>v>>>r8   r   )r   r   r   r   r   rf   ro   r  r   rw   r   r{   r   r+  r  fit_noter	   r   rC   r   r  r   s   @r6   r  r  #  s`    2f!
J-:?=KLH }H=? >?r8   r  
loguniform
reciprocalc                   F    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rSrg)rice_geni?$  a  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                     US:  $ r  r   r  s     r6   rf   rice_gen._argcheck\$  r  r8   c                 @    [        SSS[        R                  4S5      /$ )Nr   Fr   rk   rl   rn   s    r6   ro   rice_gen._shape_info_$  r  r8   Nc                     U[         R                  " S5      -  UR                  SU-   S9-   n[         R                  " XD-  R                  SS95      $ )NrW   )rW   r  r   rR  )rQ   r&  r   r  )rE   r   r   r   r  s        r6   r   rice_gen._rvsb$  sF    bggajL<77TD[7IIwwyyay())r8   c                     [         R                  " [        R                  " U5      S[        R                  " U5      5      $ rD  )r~   chndtrrQ   r  r  s      r6   r{   rice_gen._cdfg$  s%    yy1q"))A,77r8   c           	          [         R                  " [        R                  " US[         R                  " U5      5      5      $ rD  )rQ   r&  r~   chndtrixr  r  s      r6   r   rice_gen._ppfj$  s&    wwr{{1a1677r8   c                 |    U[         R                  " X-
  * X-
  -  S-  5      -  [        R                  " X-  5      -  $ rv  )rQ   r   r~   i0er  s      r6   rw   rice_gen._pdfm$  s6     266AC&!#,s*++bffQSk99r8   c                     US-  nSU-   nX"-  S-  nSU-  [         R                  " U* 5      -  [        R                  " U5      -  [        R                  " USU5      -  $ r  )rQ   r   r~   r(  hyp1f1)rE   re   r   nd2n1rh  s         r6   r+  rice_gen._munpv$  s\    eWSWc
RVVRC[(288B<7		"a$% 	&r8   r   r-  )r   r   r   r   r   rf   ro   r   r{   r   rw   r+  r   r   r8   r6   r  r  ?$  s+    8D*
88:&r8   r  ricec                   |    \ rS rSrSr\" \SS9S 5       rS rS r	S r
S	 r\S
 5       rS rS rS rSS jrS rSrg)irwinhall_geni$  a	  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                     Sn[        U5      e)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   irwinhall_gen.fit$  s    
9	 "),,r8   c                 R    US:  [        U5      -  [        R                  " U5      -  $ r  )r   rQ   	isrealobjrd   s     r6   rf   irwinhall_gen._argcheck$  s"    AQ'",,q/99r8   c                 
    SU4$ r  r   rd   s     r6   r   irwinhall_gen._get_support$  s    !tr8   c                 @    [        SSS[        R                  4S5      /$ rj   rl   rn   s    r6   ro   irwinhall_gen._shape_info$  rq   r8   c                 \    S n[         R                  " U[         R                  /S9" X5      $ )Nc                     [         R                  " U[         R                  S9n[        R                  " X-   USS9[        R
                  " X-   USS9-  $ )Nr.	  T)exact)rQ   r"  int64r~   	stirling2r  )rM  re   s     r6   vmunp"irwinhall_gen._munp.<locals>.vmunp$  sD    

1BHH-ALL!48ggagq56 7r8   r;  r=  )rE   rM  re   r.  s       r6   r+  irwinhall_gen._munp$  s%    	7 ||E2::,7AAr8   c                 `    [         R                  " U S-   5      n[        R                  " U5      $ ra   )rQ   r  r   basis_element)re   r  s     r6   	_cardbsplirwinhall_gen._cardbspl$  s$    IIacN$$Q''r8   c                 d   ^  U 4S jn[         R                  " U[         R                  /S9" X5      $ )Nc                 2   > TR                  U5      " U 5      $ rO   )r3  rv   re   rE   s     r6   vpdf irwinhall_gen._pdf.<locals>.vpdf$  s    >>!$Q''r8   r;  r=  )rE   rv   re   r8  s   `   r6   rw   irwinhall_gen._pdf$  s$    	(||D"**6q<<r8   c                 d   ^  U 4S jn[         R                  " U[         R                  /S9" X5      $ )Nc                 N   > TR                  U5      R                  5       " U 5      $ rO   r3  antiderivativer7  s     r6   vcdf irwinhall_gen._cdf.<locals>.vcdf$  s     >>!$335a88r8   r;  r=  )rE   rv   re   r?  s   `   r6   r{   irwinhall_gen._cdf$  s$    	9||D"**6q<<r8   c                 d   ^  U 4S jn[         R                  " U[         R                  /S9" X5      $ )Nc                 R   > TR                  U5      R                  5       " X-
  5      $ rO   r=  r7  s     r6   vsfirwinhall_gen._sf.<locals>.vsf$  s"    >>!$335ac::r8   r;  r=  )rE   rv   re   rD  s   `   r6   r   irwinhall_gen._sf$  s$    	;||C5a;;r8   Nc                 ,    [         SS j5       nU" XUS9$ )Nc                     [         R                  " U 5      R                  [        5      n Uc  U 4OU /UQ7nUR	                  US9R                  SS9$ )Nr  r   rR  )rQ   r  r  r*  r  r  )re   r   r   usizes       r6   _rvs1!irwinhall_gen._rvs.<locals>._rvs1$  sO    ""3'A LQDqj4jE''U'377Q7??r8   r'  r-  )r   )rE   re   r   r   rG   rJ  s         r6   r   irwinhall_gen._rvs$  s%    	#	@ 
$	@ Q==r8   c                 &    US-  US-  SSSU-  -  4$ )NrW   r  r   r  r  r   rd   s     r6   r   irwinhall_gen._stats$  s#     sAbD!R1X%%r8   r   r-  )r   r   r   r   r   r
   r   rC   rf   r   ro   r+  rr  r3  rw   r{   r   r   r   r   r   r8   r6   r  r  $  sm    5n   6? @-	@-:C	B ( (=
=
<
>&r8   r  	irwinhall)r   re   c                   @    \ rS rSrSrS rS rS rS rS r	SS	 jr
S
rg)recipinvgauss_geni%  a}  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                 @    [        SSS[        R                  4S5      /$ r  rl   rn   s    r6   ro   recipinvgauss_gen._shape_info%  rE  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  r  s      r6   rw   recipinvgauss_gen._pdf%  s     vvdll1)**r8   c                 B    [        US:  X4S [        R                  * S9$ )Nr   c                     SX-  -
  S-  * SU -  US-  -  -  S[         R                  " S[         R                  -  U -  5      -  -
  $ )Nr   r   rW   r   r  )rv   r}  s     r6   r:  +recipinvgauss_gen._logpdf.<locals>.<lambda>%%  sE    1rt8c/)9QqSS[)I+.rvvagai/@+@*Ar8   rX  rZ  r  s      r6   r   recipinvgauss_gen._logpdf#%  s(    !a%!B%'VVG- 	-r8   c                     SU-  U-
  nSU-  U-   nS[         R                  " U5      -  n[        U* U-  5      [         R                  " SU-  5      [        U* U-  5      -  -
  $ Nr   r   rQ   r&  r   r   rE   rv   r}  trm1trm2isqxs         r6   r{   recipinvgauss_gen._cdf)%  s_    2vz2vz2771:~$t$rvvc"f~id
6K'KKKr8   c                     SU-  U-
  nSU-  U-   nS[         R                  " U5      -  n[        XS-  5      [         R                  " SU-  5      [        U* U-  5      -  -   $ r[  r\  r]  s         r6   r   recipinvgauss_gen._sf/%  s[    2vz2vz2771:~#bffSVnYuTz5J&JJJr8   Nc                 *    SUR                  USUS9-  $ r  r  r  s       r6   r   recipinvgauss_gen._rvs5%  s    <$$R4$888r8   r   r-  )r   r   r   r   r   ro   rw   r   r{   r   r   r   r   r8   r6   rQ  rQ  %  s(    ,F+
-LK9r8   rQ  recipinvgaussc                   L    \ rS rSrSrS rS rS rS rS r	SS	 jr
S
 rS rSrg)semicircular_geni<%  a  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                     / $ rO   r   rn   s    r6   ro   semicircular_gen._shape_info[%  r   r8   c                 `    S[         R                  -  [         R                  " SX-  -
  5      -  $ r  rJ  r   s     r6   rw   semicircular_gen._pdf^%  s#    255y13''r8   c                     [         R                  " S[         R                  -  5      S[        R                  " U* U-  5      -  -   $ rZ  r  r   s     r6   r   semicircular_gen._logpdfa%  s0    vvagRXXqbd^!333r8   c                     SS[         R                  -  U[         R                  " SX-  -
  5      -  [         R                  " U5      -   -  -   $ )Nr   r   r   )rQ   r  r&  r]  r   s     r6   r{   semicircular_gen._cdfd%  s:    3ruu9a!#.1=>>>r8   c                 .    [         R                  US5      $ Nr  )r  r   r   s     r6   r   semicircular_gen._ppfg%  s    zz!Qr8   Nc                     [         R                  " UR                  US95      n[         R                  " [         R                  UR                  US9-  5      nX4-  $ r  )rQ   r&  r  rQ  r  )rE   r   r   rL  r   s        r6   r   semicircular_gen._rvsj%  sL     GGL((d(34FF255<//T/::;ur8   c                     g)N)r   r  r   r  r   rn   s    r6   r   semicircular_gen._statsq%  rA  r8   c                     g)NgzCϑ?r   rn   s    r6   r  semicircular_gen._entropyt%  s    %r8   r   r-  )r   r   r   r   r   ro   rw   r   r{   r   r   r   r  r   r   r8   r6   rh  rh  <%  s/    <(4?  &r8   rh  semicircularc                   F    \ rS rSrSrS rS rS rS rS r	SS jr
S	 rS
rg)skewcauchy_geni{%  a  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                 4    [         R                  " U5      S:  $ ra   )rQ   r  rG  s     r6   rf   skewcauchy_gen._argcheck%  s    vvay1}r8   c                      [        SSSS5      /$ )Nr   F)r  r   r3  r   rn   s    r6   ro   skewcauchy_gen._shape_info%  s    3{NCDDr8   c                 z    S[         R                  US-  U[         R                  " U5      -  S-   S-  -  S-   -  -  $ rf  )rQ   r  rR   r8  s      r6   rw   skewcauchy_gen._pdf%  s:    BEEQTQ^a%7!$;;a?@AAr8   c                     [         R                  " US:*  SU-
  S-  SU-
  [         R                  -  [         R                  " USU-
  -  5      -  -   SU-
  S-  SU-   [         R                  -  [         R                  " USU-   -  5      -  -   5      $ Nr   r   rW   )rQ   r  r  r  r8  s      r6   r{   skewcauchy_gen._cdf%  s    xxQQ!q1uo		!q1u+8N&NNQ!q1uo		!q1u+8N&NNP 	Pr8   c           
      B   XR                  SU5      :  n[        R                  " U[        R                  " [        R                  SU-
  -  USU-
  S-  -
  -  5      SU-
  -  [        R                  " [        R                  SU-   -  USU-
  S-  -
  -  5      SU-   -  5      $ r  )r{   rQ   r  r  r  )rE   rv   r   rV  s       r6   r   skewcauchy_gen._ppf%  s    		!QxxruuA!q1uk/BCq1uMruuA!q1uk/BCq1uMO 	Or8   c                 ~    [         R                  [         R                  [         R                  [         R                  4$ rO   r*  )rE   r   rt  s      r6   r   skewcauchy_gen._stats%  r,  r8   c                     [        U[        5      (       a  UR                  5       n[        R                  " U/ SQ5      u  p#nSX4U-
  S-  4$ )Nr2  r   rW   r6  )rE   rF   r9  r:  r;  s        r6   r  skewcauchy_gen._fitstart%  sD     dL))>>#DdL9#C)Q&&r8   r   Nr  )r   r   r   r   r   rf   ro   rw   r{   r   r   r  r   r   r8   r6   r|  r|  {%  s/     BEBP
O.'r8   r|  
skewcauchyc                      ^  \ rS rSrSrS rS rS rS rU 4S jr	S r
S	 rS
 rSS jrSS jr\S 5       rS r\" \SS9U 4S j5       rSrU =r$ )skewnorm_geni%  a  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                 .    [         R                  " U5      $ rO   r  rG  s     r6   rf   skewnorm_gen._argcheck%  r  r8   c                 ^    [        SS[        R                  * [        R                  4S5      /$ )Nr   Fr3  rl   rn   s    r6   ro   skewnorm_gen._shape_info%  r  r8   c                 &    [        US:H  X4S S S9$ )Nr   c                     [        U 5      $ rO   r   rv   r   s     r6   r:  #skewnorm_gen._pdf.<locals>.<lambda>%  s    1r8   c                 :    S[        U 5      -  [        X-  5      -  $ rv  r  r  s     r6   r:  r  %  s    By|OIacN:r8   r>  r@  r8  s      r6   rw   skewnorm_gen._pdf%  s     FQF5:
 	
r8   c                 &    [        US:H  X4S S S9$ )Nr   c                     [        U 5      $ rO   r   r  s     r6   r:  &skewnorm_gen._logpdf.<locals>.<lambda>%  s    ar8   c                 b    [         R                  " S5      [        U 5      -   [        X-  5      -   $ rD  r  r  s     r6   r:  r  %  s!    BFF1Il1o5l136GGr8   r>  r@  r8  s      r6   r   skewnorm_gen._logpdf%  s     FQF8G
 	
r8   c                   > [         R                  " U5      n[        R                  " USSU5      n[         R                  " X#R
                  5      nUS:  US:  -  n[        TU ]  X   X$   5      X4'   [         R                  " USS5      $ )Nr   r   gư>r   r   )	rQ   r	  rs   _skewnorm_cdfr  re  rA   r{   r  )rE   rv   r   r   i_small_cdfr  s        r6   r{   skewnorm_gen._cdf%  su    MM!3Q/OOAyy)Tza!e, 7<GwwsAq!!r8   c                 4    [         R                  " USSU5      $ Nr   r   )rs   _skewnorm_ppfr8  s      r6   r   skewnorm_gen._ppf%        Ca00r8   c                 *    U R                  U* U* 5      $ rO   r	  r8  s      r6   r   skewnorm_gen._sf%  s     yy!aR  r8   c                 4    [         R                  " USSU5      $ r  )rs   _skewnorm_isfr8  s      r6   r   skewnorm_gen._isf&  r  r8   c                     UR                  US9nUR                  US9nU[        R                  " SUS-  -   5      -  nXd-  U[        R                  " SUS-  -
  5      -  -   n[        R                  " US:  Xw* 5      $ )Nr  r   rW   r   )r  rQ   r&  r  )rE   r   r   r   u0r  r  r*  s           r6   r   skewnorm_gen._rvs&  s|      d +T*bgga!Q$hTAbgga!Q$h'''xxaS))r8   c                    / SQn[         R                  " S[         R                  -  5      U-  [         R                  " SUS-  -   5      -  nSU;   a  XCS'   SU;   a  SUS-  -
  US'   SU;   a<  S[         R                  -
  S-  U[         R                  " SUS-  -
  5      -  S	-  -  US'   S
U;   a+  S[         R                  S	-
  -  US-  SUS-  -
  S-  -  -  US	'   U$ )Nr	  rW   r   r  r   r  ro  rU  r  rq  rG  )rE   r   rt  r  consts        r6   r   skewnorm_gen._stats&  s    )"%% 1$RWWQAX%66'>1I'>E1HF1I'>bee)Q5UAX1F+F*JJF1I'>BEEAI5!8Q\A4E+EFF1Ir8   c                     [        S/5      [        SS/5      [        / SQ5      [        / SQ5      [        / SQ5      [        / SQ5      [        / SQ5      [        / S	Q5      [        / S
Q5      [        / SQ5      S.
nU$ )Nr   r  r  )rr  ir  )i   i?   i)i  iin  ir  )(  iSi6Q  ir	  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  r  r  rp  r     rr        r   )rE   skewnorm_odd_momentss     r6   _skewnorm_odd_moments"skewnorm_gen._skewnorm_odd_moments"&  s     1#1b'",'./78EF # $ 8 9 % &  2 3 
$ $#r8   c                    US-  (       aQ  US:  a  [        S5      eU[        R                  " SUS-  -   5      -  nX0R                  U   " US-  5      -  [        -  $ [
        R                  " US-   S-  5      SUS-  -  -  [        -  $ )NrW   r  zKskewnorm noncentral moments not implemented for odd orders greater than 19.r   )r>  rQ   r&  r  r'   r~   r(  r&   )rE   rM  r   rR	  s       r6   r+  skewnorm_gen._munp8&  s    19rz) +5 6 6
 bgga!Q$h''E66u=eQhGG%& ' 88UQY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           	      z  > UR                  SS5      (       a  [        TU ]  " U/UQ70 UD6$ [        U[        5      (       a9  UR                  5       S:X  a  UR                  5       nO[        TU ]  " U/UQ70 UD6$ [        XX#5      u  ppVUR                  SS5      R                  5       nS nS n	US:X  a  S	u  pnO;[        U5      (       a  US   OS n
UR                  S
S 5      nUR                  SS 5      nUc  U
c  [        R                  " U5      nUS:X  a  [        R                  " USS5      nO U" S5      n[        R                  " X* U5      nU	" U5      n[        R                  " SS9   [        R                   " [        R"                  " US-  SUS-  -
  5      5      [        R$                  " U5      -  n
S S S 5        O&Ub  UOU
n
U
[        R                   " SU
S-  -   5      -  nUcM  UcJ  [        R&                  " U5      n[        R                   " USSUS-  -  [        R(                  -  -
  -  5      nOUb  UnUcI  UcF  [        R*                  " U5      nUX-  [        R                   " S[        R(                  -  5      -  -
  nOUb  UnUS:X  a  XU4$ [        TU ]  " X4XS.UD6$ ! , (       d  f       N= f)Nr\  Fr   r1   r;   c                     S[         R                  -
  S-  U [         R                  " S[         R                  -  5      -  S-  SSU S-  -  [         R                  -  -
  S-  -  -  $ )NrU  rW   r  r   rd  rJ  r  s    r6   skew_d skewnorm_gen.fit.<locals>.skew_di&  s]    beeGQ;1rwwq255y'9#9A"=%&1a4"%%%73$?#@ A Ar8   c                     [         R                  " U 5      S-  n[         R                  " U 5      [         R                  " [         R                  S-  U-  US[         R                  -
  S-  S-  -   -  5      -  $ )Nr  rW   rU  )rQ   r  rR   r&  r  )rb  s_23s     r6   d_skew skewnorm_gen.fit.<locals>.d_skewm&  s^    66$<#&D774=277a$$1ruu9a-3)?"?@$  r8   r<   rd  r.   r/   gGzgGz?r   rp  rq  rW   ri  )r3   rA   rC   r?   r*   r@   r  rj  r=   r>   r  rI  rb  rQ   r  rs  r&  rr  rR   r  r  r%  )rE   rF   rG   r5   r  r  r  r1   r  r  r   r.   r/   ro  s_maxr  r  r  r  s                     r6   rC   skewnorm_gen.fitL&  sy    88J&&7;t3d3d33dL))  "a'~~'w{47$7$77 "=T=A"I$(E*002	A	 T>,MAEt99Q$A((5$'CHHWd+E:!) 

4 A GGAud+q	GGAvu-q	AH-GGBIIadQq!tV56rwwqzA .- n!ABGGA1H%%A>emtAGGAQq!tVBEE\!123EE<CKAegbggag...CCT>5=  7;tECEEE/ .-s   .AJ,,
J:r   r-  r  )r   r   r   r   r   rf   ro   rw   r   r{   r   r   r   r   r   r   r  r+  r	   r   rC   r   r  r   s   @r6   r  r  %  sy    :K

"1!
1** $ $*E( } 5 GFGFr8   r  skewnormc                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)trapezoid_geni&  a?  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                 :    US:  US:*  -  US:  -  US:*  -  X!:  -  $ r   r   rE   ra  r  s      r6   rf   trapezoid_gen._argcheck&  s.    Q16"a1f-a8AFCCr8   c                 @    [        SSSS5      n[        SSSS5      nX/$ )Nra  Fr   r   TTr  r  r  s      r6   ro   trapezoid_gen._shape_info&  s)    UHl;UHl;xr8   c                 \    SX2-
  S-   -  n[        X:  X!:*  X:*  -  X:  /S S S /XX445      $ )NrW   r   c                     X0-  U-  $ rO   r   rv   ra  r  r  s       r6   r:  $trapezoid_gen._pdf.<locals>.<lambda>&  s
    quqyr8   c                     U$ rO   r   r  s       r6   r:  r  &  s    qr8   c                     USU -
  -  SU-
  -  $ ra   r   r  s       r6   r:  r  &  s    qAaCyAaC/@r8   r   )rE   rv   ra  r  r  s        r6   rw   trapezoid_gen._pdf&  sR    QKAEV/E# 90@B !<) 	)r8   c                 H    [        X:  X!:*  X:*  -  X:  /S S S /XU45      $ )Nc                 "    U S-  U-  X!-
  S-   -  $ r  r   rv   ra  r  s      r6   r:  $trapezoid_gen._cdf.<locals>.<lambda>&  s    AqD1HA,>r8   c                 &    USX-
  -  -   X!-
  S-   -  $ r  r   r  s      r6   r:  r  &  s    Qac]qs1u,Er8   c                 4    SSU -
  S-  X!-
  S-   -  SU-
  -  -
  $ rf  r   r  s      r6   r:  r  &  s/    A!z23#a%09<=aC0A -Br8   r  r  s       r6   r{   trapezoid_gen._cdf&  sF    AEV/E# ?EBC !9& 	&r8   c                 F   U R                  X"U5      U R                  X2U5      pTX:  X:*  X:  /n[        R                  " X-  SU-   U-
  -  5      SU-  SU-   U-
  -  SU-  -   S[        R                  " SU-
  X2-
  S-   -  SU-
  -  5      -
  /n[        R                  " Xg5      $ r
  )r{   rQ   r&  select)rE   r   ra  r  qcqdr  r  s           r6   r   trapezoid_gen._ppf&  s    1#TYYqQ%7BFAGQV,ggaeq1uqy12AgQ+cAg5"''1q5QUQY"71q5"ABBD
 yy..r8   c                    ^ UTS-   -  n[        US:H  SU:  US:  -  US:H  /S U4S jU4S j/U/5      nSSU-   U-
  -  XT-
  -  TS-   TS-   -  -  nU$ )	Nr   r   r   c                     gr>  r   r  s    r6   r:  %trapezoid_gen._munp.<locals>.<lambda>&  s    sr8   c                 p   > [         R                  " TS-   [         R                  " U 5      -  5      U S-
  -  $ rD
  )rQ   rk  r  r  re   s    r6   r:  r  &  s(    rxx1q	 12ae<r8   c                    > TS-   $ rD  r   r  s    r6   r:  r   '  s	    qsr8   r   rW   r  )rE   re   ra  r  ab_termdc_termr  s    `     r6   r+  trapezoid_gen._munp&  s     ac(#XaAG,a3h7< C SU1Wo!23!!}E
r8   c                 j    SSU-
  U-   -  SU-   U-
  -  [         R                  " SSU-   U-
  -  5      -   $ r   rg  r  s      r6   r  trapezoid_gen._entropy'  s=     c!eAg#a%'*RVVC3q57O-DDDr8   r   N)r   r   r   r   r   rf   ro   rw   r{   r   r+  r  r   r   r8   r6   r  r  &  s-     BD
	)&/2Er8   r  zS`trapz` is deprecated in favour of `trapezoid` and will be removed in SciPy 1.16.0.c                       \ rS rSrSrS rSrg)	trapz_geni'  zy

.. deprecated:: 1.14.0
    `trapz` is deprecated and will be removed in SciPy 1.16.
    Plese use `trapezoid` instead!
c                 b    [         R                  " [        [        SS9  U R                  " U0 UD6$ NrW   r  )r  r  deprmsgDeprecationWarningfreeze)rE   rG   r5   s      r6   __call__trapz_gen.__call__'  s'    g1a@{{D)D))r8   r   N)r   r   r   r   r   r  r   r   r8   r6   r  r  '  s    *r8   r  	trapezoidtrapz)r   entropyexpectrC   intervalr  logcdfrO  logsfr%  r
  rO  pdfr  r)  r  rI  stdr  c                        \ rS rSrS rS rSrg)_DeprecationWrapperi.'  c                 J    SU SU S3U l         [        [        U5      U l        g )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.)r[   getattrr  r1   )rE   r1   s     r6   r  _DeprecationWrapper.__init__/'  s1    fX%LVH UX X i0r8   c                 n    [         R                  " U R                  [        SS9  U R                  " U0 UD6$ r  )r  r  r[   r  r1   )rE   rG   kwargss      r6   r  _DeprecationWrapper.__call__5'  s+    dhh 2qA{{D+F++r8   )r1   r[   N)r   r   r   r   r  r  r   r   r8   r6   r  r  .'  s    1,r8   r  c                   L    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
 rS rSrg)
triang_geni>'  a  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                 *    UR                  SUSU5      $ r   )
triangularr  s       r6   r   triang_gen._rvsT'  s    &&q!Q55r8   c                     US:  US:*  -  $ r   r   r  s     r6   rf   triang_gen._argcheckW'  s    Q16""r8   c                      [        SSSS5      /$ )Nra  Fr  r  r  rn   s    r6   ro   triang_gen._shape_infoZ'  s    3x>??r8   c                 Z    [        US:H  X:  X:  US:g  -  US:H  /S S S S /X45      nU$ )Nr   r   c                     SSU -  -
  $ rD  r   r  s     r6   r:  !triang_gen._pdf.<locals>.<lambda>g'  s    a!a%ir8   c                     SU -  U-  $ rD  r   r  s     r6   r:  r  h'  s    a!eair8   c                     SSU -
  -  SU-
  -  $ r  r   r  s     r6   r:  r  i'  s    a1q5kQU&;r8   c                     SU -  $ rD  r   r  s     r6   r:  r  j'  s    a!er8   r  rE   rv   ra  rL  s       r6   rw   triang_gen._pdf]'  sT     a&Q!V,a! 0/;+-   r8   c                 Z    [        US:H  X:  X:  US:g  -  US:H  /S S S S /X45      nU$ )Nr   r   c                     SU -  X -  -
  $ rD  r   r  s     r6   r:  !triang_gen._cdf.<locals>.<lambda>s'  s    acACir8   c                     X -  U-  $ rO   r   r  s     r6   r:  r!  t'  s
    aeair8   c                 (    X -  SU -  -
  U-   US-
  -  $ r  r   r  s     r6   r:  r!  u'  s    qsQqSy1}1&=r8   c                 
    X -  $ rO   r   r  s     r6   r:  r!  v'  s    aer8   r  r  s       r6   r{   triang_gen._cdfn'  sR    a&Q!V,a! 0/=+-   r8   c           
          [         R                  " X:  [         R                  " X!-  5      S[         R                  " SU-
  SU-
  -  5      -
  5      $ ra   )rQ   r  r&  rl  s      r6   r   triang_gen._ppfz'  s;    xxrwwqu~q!A#!A#1G/GHHr8   c           	          US-   S-  SU-
  X-  -   S-  [         R                  " S5      SU-  S-
  -  US-   -  US-
  -  S[         R                  " SU-
  X-  -   S5      -  -  S4$ )	Nr   r     rW   r   r  rd  g333333)rQ   r&  rf  r  s     r6   r   triang_gen._stats}'  st    3QqsB
AaCE"AaC(!A#.!BHHc!eACi#4N2NO 	r8   c                 4    S[         R                  " S5      -
  $ rQ  rg  r  s     r6   r  triang_gen._entropy'  s    266!9}r8   r   r-  )r   r   r   r   r   r   rf   ro   rw   r{   r   r   r  r   r   r8   r6   r  r  >'  s1    *6#@"
Ir8   r  triangc                   b   ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rU 4S jrS rSrU =r$ )truncexpon_geni'  a8  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                 @    [        SSS[        R                  4S5      /$ r  rl   rn   s    r6   ro   truncexpon_gen._shape_info'  r5  r8   c                     U R                   U4$ rO   r  r  s     r6   r   truncexpon_gen._get_support'      vvqyr8   c                 b    [         R                  " U* 5      [        R                  " U* 5      * -  $ rO   r  r  s      r6   rw   truncexpon_gen._pdf'  s#    vvqbzBHHaRL=))r8   c                 b    U* [         R                  " [        R                  " U* 5      * 5      -
  $ rO   r"  r  s      r6   r   truncexpon_gen._logpdf'  s$    rBFFBHHaRL=)))r8   c                 `    [         R                  " U* 5      [         R                  " U* 5      -  $ rO   rR  r  s      r6   r{   truncexpon_gen._cdf'  s!    xx|BHHaRL((r8   c                 `    [         R                  " U[         R                  " U* 5      -  5      * $ rO   )r~   r  rk  r  s      r6   r   truncexpon_gen._ppf'  s"    288QB<(((r8   c                     [         R                  " U* 5      [         R                  " U* 5      -
  [        R                  " U* 5      -  $ rO   r  r  s      r6   r   truncexpon_gen._sf'  s0    r
RVVQBZ'1"55r8   c                     [         R                  " [         R                  " U* 5      U[        R                  " U* 5      -  -
  5      * $ rO   )rQ   r  r   r~   rk  r  s      r6   r   truncexpon_gen._isf'  s2    rvvqbzA!$44555r8   c                 :  > US:X  a9  SUS-   [         R                  " U* 5      -  -
  [        R                  " U* 5      * -  $ US:X  aG  SSSX"-  SU-  -   S-   -  [         R                  " U* 5      -  -
  -  [        R                  " U* 5      * -  $ [        TU ]  X5      $ r	  )rQ   r   r~   rk  rA   r+  )rE   re   r   r  s      r6   r+  truncexpon_gen._munp'  s     6qsBFFA2J&&"((A2,77!VaQS1WQYr
223bhhrl]CC 7=&&r8   c                     [         R                  " U5      n[         R                  " US-
  5      SX!S-
  -  -   SU-
  -  -   $ r  r  )rE   r   eBs      r6   r  truncexpon_gen._entropy'  s9    VVAYvvbd|QrS5z\CF333r8   r   )r   r   r   r   r   ro   r   rw   r   r{   r   r   r   r+  r  r   r  r   s   @r6   r/  r/  '  s@    *E**))66	'4 4r8   r/  
truncexpon)r   r   c                 .    [         R                  " X/SS9$ )Nr   rR  )r~   r	  log_plog_qs     r6   _log_sumrK  '  s    <<Q//r8   c                 V    [         R                  " X[        R                  S-  -   /SS9$ )N              ?r   rR  )r~   r	  rQ   r  rH  s     r6   r  r  '  s"    <<beeBh/a88r8   c                   ^ [         R                  " X5      u  pUS:*  nU S:  nX#-  ) nS mU4S jnS n[         R                  " U [         R                  [         R                  S9nX   R
                  (       a  T" X   X   5      Xr'   X   R
                  (       a  U" X   X   5      Xs'   X   R
                  (       a  U" X   X   5      Xt'   [         R                  " U5      $ )z3Log of Gaussian probability mass within an intervalr   c                 >    [        [        U5      [        U 5      5      $ rO   )r  r   r  s     r6   mass_case_left'_log_gauss_mass.<locals>.mass_case_left'  s    a,q/::r8   c                    > T" U* U * 5      $ rO   r   )r   r   rP  s     r6   mass_case_right(_log_gauss_mass.<locals>.mass_case_right'  s    qb1"%%r8   c                 \    [         R                  " [        U 5      * [        U* 5      -
  5      $ rO   )r~   r  r   r  s     r6   mass_case_central*_log_gauss_mass.<locals>.mass_case_central'  s$     xx1	1"566r8   )rj  r/	  )rQ   rH  r1	  rF  
complex128r   r(  )	r   r   	case_left
case_rightcase_centralrS  rV  rM  rP  s	           @r6   _log_gauss_massr\  '  s    q$DA QIQJ+,L;&7 ,,qRVV2==
AC|'alC})!-G-aoqO773<r8   c                      ^  \ rS rSrSrS rS rU 4S jrS rS r	S r
S	 rS
 rS rS rS rS rS rS rSS jrSrU =r$ )truncnorm_geni'  a	  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                 
    X:  $ rO   r   r9	  s      r6   rf   truncnorm_gen._argcheck@(  s	    ur8   c                     [        SS[        R                  * [        R                  4S5      n[        SS[        R                  * [        R                  4S5      nX/$ )Nr   Frk   r   )FTrl   r  s      r6   ro   truncnorm_gen._shape_infoC(  sG    UbffWbff$5}EUbffWbff$5}Exr8   c                    > [        U[        5      (       a  UR                  5       n[        TU ]  U[
        R                  " U5      [
        R                  " U5      4S9$ r  r  rz  s     r6   r  truncnorm_gen._fitstartH(  sF    dL))>>#Dw RVVD\266$<,H IIr8   c                     X4$ rO   r   r9	  s      r6   r   truncnorm_gen._get_supportN(  r~  r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r.  r  s       r6   rw   truncnorm_gen._pdfQ(  r  r8   c                 0    [        U5      [        X#5      -
  $ rO   )r   r\  r  s       r6   r   truncnorm_gen._logpdfT(  s    A!666r8   c                 N    [         R                  " U R                  XU5      5      $ rO   r  r  s       r6   r{   truncnorm_gen._cdfW(  r  r8   c           
      X   [         R                  " XU5      u  pn[         R                  " [        X!5      [        X#5      -
  5      nUS:  n[         R                  " U5      (       aD  [         R
                  " [         R                  " U R                  X   X%   X5   5      5      * 5      XE'   U$ Ng)rQ   rH  r"  r\  r  r  r   r	  )rE   rv   r   r   r  rV  s         r6   r  truncnorm_gen._logcdfZ(  s    %%aA.aOA1OA4IIJTM66!99"&&QT14)F"G!GHFIr8   c                 N    [         R                  " U R                  XU5      5      $ rO   r  r  s       r6   r   truncnorm_gen._sfb(  r  r8   c           
      X   [         R                  " XU5      u  pn[         R                  " [        X5      [        X#5      -
  5      nUS:  n[         R                  " U5      (       aD  [         R
                  " [         R                  " U R                  X   X%   X5   5      5      * 5      XE'   U$ rn  )rQ   rH  r"  r\  r  r  r   r  )rE   rv   r   r   r  rV  s         r6   r	  truncnorm_gen._logsfe(  s    %%aA.a

?10?13HHIDL66!99xxQT14(F!G GHEHr8   c                 &   [        U5      n[        U5      nXC-
  n[        R                  " [        R                  " S[        R                  -  [        R
                  -  5      U-  5      nU[        U5      -  U[        U5      -  -
  SU-  -  nXg-   nU$ rD  )r   rQ   r  r&  r  r.  r   )	rE   r   r   r  r  r  r)  Dr  s	            r6   r  truncnorm_gen._entropym(  sy    aLaLEFF2771ruu9rtt+,q011IaL 00QU;Er8   c                    [         R                  " XU5      u  pnUS:  nU) nS nS n[         R                  " U5      nX   n	X   n
U	R                  (       a  U" XU   X4   5      X'   U
R                  (       a  U" XU   X5   5      X'   U$ )Nr   c                     [        [        U5      [        R                  " U 5      [	        X5      -   5      n[
        R                  " U5      $ rO   )rK  r   rQ   r  r\  r~   	ndtri_expr   r   r   	log_Phi_xs       r6   ppf_left$truncnorm_gen._ppf.<locals>.ppf_left|(  s7     a!#_Q-B!BDI<<	**r8   c                     [        [        U* 5      [        R                  " U * 5      [	        X5      -   5      n[
        R                  " U5      * $ rO   )rK  r   rQ   r  r\  r~   ry  rz  s       r6   	ppf_right%truncnorm_gen._ppf.<locals>.ppf_right(  s?     qb!1!#1"0E!EGILL+++r8   rQ   rH  
empty_liker   )rE   r   r   r   rY  rZ  r|  r  rM  q_leftq_rights              r6   r   truncnorm_gen._ppfv(  s    %%aA.aE	Z
	+
	,
 mmA-;;%f	lALICN<<':NCO
r8   c                    [         R                  " XU5      u  pnUS:  nU) nS nS n[         R                  " U5      nX   n	X   n
U	R                  (       a  U" XU   X4   5      X'   U
R                  (       a  U" XU   X5   5      X'   U$ )Nr   c                     [        [        U5      [        R                  " U 5      [	        X5      -   5      n[
        R                  " [        R                  " U5      5      $ rO   )r  r   rQ   r  r\  r~   ry  r(  rz  s       r6   isf_left$truncnorm_gen._isf.<locals>.isf_left(  s@    !,q/"$&&)oa.C"CEI<<	 233r8   c                     [        [        U* 5      [        R                  " U * 5      [	        X5      -   5      n[
        R                  " [        R                  " U5      5      * $ rO   )r  r   rQ   r  r\  r~   ry  r(  rz  s       r6   	isf_right%truncnorm_gen._isf.<locals>.isf_right(  sH    !,r"2"$((A2,1F"FHILL!3444r8   r  )rE   r   r   r   rY  rZ  r  r  rM  r  r  s              r6   r   truncnorm_gen._isf(  s    %%aA.aE	Z
	4
	5
 mmA-;;%f	lALICN<<':NCO
r8   c           	         ^  U 4S jn[        US:  X":H  -  X3:H  -  XU4[        R                  " U[        R                  /S9[        R                  5      $ )Nc                 (  >^	 T
R                  [        R                  " X/5      X5      u  p4X4* /nSS/n[        SU S-   5       HH  m	[	        XUX//U	4S jSS9n[        R
                  " U5      T	S-
  US   -  -   nUR                  U5        MJ     US   $ )z_
Returns n-th moment. Defined only if n >= 0.
Function cannot broadcast due to the loop over n
r   r   c                    > XTS-
  -  -  $ ra   r   )rv   r  rq  s     r6   r:  :truncnorm_gen._munp.<locals>.n_th_moment.<locals>.<lambda>(  s    qqs8|r8   rX  r;  r  )rw   rQ   r"  rU  r   r  rF	  )re   r   r   pApBprobsrt  r  mkrq  rE   s            @r6   n_th_moment(truncnorm_gen._munp.<locals>.n_th_moment(  s    
 YYrzz1&118FBIE!fG1ac]
 "%!";qJVVD\QqSGBK$77r" # 2;r8   r   r;  r	  )rE   re   r   r   r  s   `    r6   r+  truncnorm_gen._munp(  sL    	& 16af-81),,{BJJ<H&&" 	"r8   c                     U R                  [        R                  " X/5      X5      u  pES n[        R                  " USS9nU" XXEU5      $ )Nc                    X#-
  nUnX#* /n[        XwX//S SS9nS[        R                  " U5      -   n	[        XwX-
  X-
  //S SS9nS[        R                  " U5      -   n
[        XwX//S SS9nSU-  [        R                  " U5      -   n[        XwX//S SS9nS	U	-  [        R                  " U5      -   nXS
U	-  SUS-  -  -   -  -   nU[        R                  " U
S5      -  nXSU-  S	U-  SU	-  US-  -
  -  -   -  -   nXS-  -  S	-
  nXjUU4$ )Nc                 
    X-  $ rO   r   r  s     r6   r:  Gtruncnorm_gen._stats.<locals>._truncnorm_stats_scalar.<locals>.<lambda>(  s    13r8   r   rX  r   c                 
    X-  $ rO   r   r  s     r6   r:  r  (  s    r8   c                     XS-  -  $ rD  r   r  s     r6   r:  r  (  
    1T6r8   rW   c                     XS-  -  $ rr  r   r  s     r6   r:  r  (  r  r8   r  rp  rd  rq  )r   rQ   r  rf  )r   r   r  r  rt  r  r}  r  r  r  r~  r  m4mu3r  mu4r  s                    r6   _truncnorm_stats_scalar5truncnorm_gen._stats.<locals>._truncnorm_stats_scalar(  sI   BBIEeaV_6F()+DRVVD\!BeadAD\%:<L()+D bffTl"CeaV_6I()+D2t$BeaV_6I()+D2t$BRUQr1uW_--CrxxS))B2b51R42A#6677CAv!BB?"r8   )rt  )excluded)r  rQ   rD  r2  )rE   r   r   rt  r  r  r  _truncnorm_statss           r6   r   truncnorm_gen._stats(  sJ    "((A6*A1	#4 <<(?1=?bg66r8   r   ry  )r   r   r   r   r   rf   ro   r  r   rw   r   r{   r  r   r	  r  r   r   r+  r   r   r  r   s   @r6   r^  r^  '  sZ    >@
J-7-,8:"07 7r8   r^  	truncnorm)r   r   c                      ^  \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS r\\" \5      U 4S j5       5       rSrU =r$ )truncpareto_geni(  a  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                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )Nr   Fr   r3  ra  r   rl   )rE   r  r  s      r6   ro   truncpareto_gen._shape_info)  s9    US"&&M>BUS"&&M>Bxr8   c                     US:  US:  -  $ r  r   rE   r   ra  s      r6   rf   truncpareto_gen._argcheck)  s    B1r6""r8   c                     U R                   U4$ rO   r  r  s      r6   r   truncpareto_gen._get_support)  r4  r8   c                 .    X!US-   * -  -  SSX2-  -  -
  -  $ ra   r   rE   rv   r   ra  s       r6   rw   truncpareto_gen._pdf")  s#    !f9}AadF
++r8   c           	          [         R                  " U5      [         R                  " [         R                  " U* [         R                  " U5      -  5      * 5      -
  US-   [         R                  " U5      -  -
  $ ra   )rQ   r  rk  r  s       r6   r   truncpareto_gen._logpdf%)  sM    vvay266288QBrvvayL#9"9::ac266!9_LLr8   c                 (    SX* -  -
  SSX2-  -  -
  -  $ ra   r   r  s       r6   r{   truncpareto_gen._cdf()  s    ArE	a!AD&j))r8   c                 n    [         R                  " X* -  * 5      [         R                  " SX2-  -  5      -
  $ rr	  r  r  s       r6   r  truncpareto_gen._logcdf+)  s+    xxB"((2ad7"333r8   c                 <    [        SSSX2-  -  -
  U-  -
  SU-  5      $ Nr   r  rQ  rE   r   r   ra  s       r6   r   truncpareto_gen._ppf.)  s&    1AadF
A~%r!t,,r8   c                 2    X* -  SX2-  -  -
  SSX2-  -  -
  -  $ ra   r   r  s       r6   r   truncpareto_gen._sf1)  s%    2!$1qv:..r8   c                 |    [         R                  " X* -  SX2-  -  -
  5      [         R                  " SX2-  -  5      -
  $ r  r  r  s       r6   r	  truncpareto_gen._logsf4)  s3    vvaeafn%AD(999r8   c                 F    [        SX2-  -  SSX2-  -  -
  U-  -   SU-  5      $ r  rQ  r  s       r6   r   truncpareto_gen._isf7)  s,    1QT6Q14ZN*BqD11r8   c                     [         R                  " USSX!-  -  -
  -  5      US-   [         R                  " U5      X!-  S-
  -  SU-  -
  -  -   * $ ra   rg  r  s      r6   r  truncpareto_gen._entropy:)  sS    1qv:'aC"&&)QTAX.1456 7 	7r8   c                     X:H  R                  5       (       a$  U[        R                  " U5      -  SSX2-  -  -
  -  $ X"U-
  -  X2-  X1-  -
  -  X2-  S-
  -  $ ra   )r$  rQ   r  )rE   re   r   ra  s       r6   r+  truncpareto_gen._munp>)  sT    F<<>>RVVAY;!af*--!9qt,q99r8   c                     [        U[        5      (       a  UR                  5       n[        R	                  U5      u  p#n[        U5      U-
  U-  nX%X44$ rO   )r?   r*   r  r  rC   rL  )rE   rF   r   r.   r/   ra  s         r6   r  truncpareto_gen._fitstartD)  sJ    dL))>>#D

4(Y_e#Sr8   c                   >^ ^^^ ^!^"^#^$^% UR                  SS5      (       a  [        T&T ]  " T/UQ70 UD6$ S m#S m"UU"U#4S jmU%4S jm U$U%4S jnU$4S jm!SUUU U!U"4S	 jjnS
 nU&U 4S jn[        T TX#5      nUu  mppTR	                  5       TR                  5       sm$m%[        R                  " T$[        R                  * 5      nU	b  U
b  Ub  Ub  [        S5      eU
Gc  UGc  UGc  U	Gc0  UU U!U"4S jn[        R                  " T$[        R                  * 5      nUnSnUS-
  nU[        R                  * :  a`  U" U5      U" U5      -  S:  aK  US-  nU[        R                  " SU5      -
  nU[        R                  * :  a  U" U5      U" U5      -  S:  a  MK  U[        R                  * :  d  U" T/UQ70 UD6$ [        UUU4S9nUR                  (       d  U" T/UQ70 UD6$ UR                  S-
  nUS-
  nSnU[        R                  * :  a`  U" U5      U" U5      -  S:  aK  US-  nU[        R                  " SU5      -
  nU[        R                  * :  a  U" U5      U" U5      -  S:  a  MK  U[        R                  * :  d  U" T/UQ70 UD6$ [        UUU4S9nUR                  (       d  U" T/UQ70 UD6$ UR                  nT!" U5      nT " UU5      nT" UUU5      nTU-
  U-  n[	        ST#" U5      -  ST"" U5      S-
  -  5      nUU:  d  U" T/UQ70 UD6$ GOUnUS-
  nSnU[        R                  * :  aP  U" UU	5      U" X5      -  S:  a:  US-  nUSU-  -
  nU[        R                  * :  a  U" UU	5      U" X5      -  S:  a  M:  U[        R                  * :  d  U" T/UQ70 UD6$ [        XY4UU4S9nUR                  (       d  U" T/UQ70 UD6$ UR                  nT!" U5      nT " UU5      nU	nGO3Ub  UOU" X5      nU=(       d    T!" U5      nU
=(       d	    T " UU5      nUb"  TR	                  5       U-
  S:  a  [        SSUS9eU
(       a5  Ub2  U(       a+  TR                  5       X-  U-   :  a  [        SST " UU5      S9eU	c  TU-
  U-  nT#" U5      n[        R                  " U5      nSU-  U:  d  U" T/UQ70 UD6$ SU-  SUU-
  -  -   n[        R                  " SU-  S5      n [        UUU4UU4S9nUR                  (       d  U" T/UQ70 UD6$ UR                  nOU	nUU-   T$:  dM  U(       a'  [        R                  " U[        R                  * 5      nOT!" U5      n[        R                  " US5      nUU-  U-   T%:  d.  T " UU5      n[        R                  " U[        R                  5      n[        R                   " T R#                  UU5      5      (       a  US:  d  U" T/UQ70 UD6$ UUUU4nUc;  Uc8  U" T/UQ70 UD6nT R%                  UT5      nT R%                  UT5      nUU:  a  U$ U$ ! [         a    Un GN"f = f)Nr\  Fc                 V    [         R                  " [         R                  " U 5      5      $ rO   )rQ   r%  r  r   s    r6   log_mean%truncpareto_gen.fit.<locals>.log_meanQ)  s    77266!9%%r8   c                 :    S[         R                  " SU -  5      -  $ ra   )rQ   r%  r   s    r6   	harm_mean&truncpareto_gen.fit.<locals>.harm_meanT)  s    RWWQqS\>!r8   c                    > TU-
  U-  nT" U5      nT	" U5      nUS-
  U-  nSUS-
  USSU -  -
  U-  [         R                  " U 5      -  -
  -  -
  U-  $ ra   rg  )
ra  r.   r/   r  harm_mlog_mquotrF   r  r  s
          r6   get_b"truncpareto_gen.fit.<locals>.get_bW)  si    c5 Aq\FQKE1He#DaDA!GV+;BFF1I+E$EFFMMr8   c                    > TU -
  U-  $ rO   r   )r.   r/   mxs     r6   get_c"truncpareto_gen.fit.<locals>.get_c^)  s    He##r8   c                 P   > U(       a  TU-
  nU$ U (       a  U T-  T-
  U S-
  -  nU$ g ra   r   )rl  r  r.   r
  r  s      r6   get_loc$truncpareto_gen.fit.<locals>.get_loca)  s7    6k
"urzBF+
 r8   c                    > TU -
  $ rO   r   )r.   r
  s    r6   r^  &truncpareto_gen.fit.<locals>.get_scalei)  s    8Or8   c                    > T	" U 5      nT" X5      nUc	  T" X0U5      OUnT
" TU -
  U-  5      nSSUS-
  X4S-   -  U-
  -  -   SSUS-   -  -
  -  U-  -
  $ ra   r   )r.   r9  r/   ra  r   r  rF   r  r  r^  r  s         r6   r
  $truncpareto_gen.fit.<locals>.dL_dLoco)  sv     cNEc!A(*
ae$As
E12FQUQ1X\22q1ac7{CfLLLr8   c                 N    U [         R                  " X-  SX-  -
  -  5      U-  -
  $ ra   r  )r   logclogms      r6   dL_dB"truncpareto_gen.fit.<locals>.dL_dBx)  s*     rxx!af* 56===r8   c                 4   > [         [        T]
  " U /UQ70 UD6$ rO   )rA   r  rC   )rF   rG   r  r  rE   s      r6   fallback%truncpareto_gen.fit.<locals>.fallback~)  s    $3DJ4J6JJr8   z2All parameters fixed.There is nothing to optimize.c                    > T" U 5      nT" X5      nT" TU -
  U-  5      nSSUS-
  -  -   [         R                  " U5      -  U-  S-
  $ ra   rg  )r.   r/   ra  r  rF   r  r^  r  s       r6   cond_b#truncpareto_gen.fit.<locals>.cond_b)  sR    %cNEc)A&s
E'9:F1Q3K266!94v=AAr8   r   r   r   r  gMbP?rW   truncparetor  rO   )r3   rA   rC   rj  rg  rL  rQ   r  rm   r!  rf  r+   r  rk  r  r  r$  rf   r  )'rE   rF   rG   r5   r  r
  r  r  r  r  rl  r  r  mn_infr  rT   rV  rS   r  r.   r/   ra  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   truncpareto_gen.fitK)  s    88J&&7;t3d3d33	&	"	N	$			M 	M	>	K 1tTH
%/"bdTXXZBb266'*NN$& = > >ZDLV^zB B b266'2!"&&("6N6&>9Q>FA#bhhr1o5F "&&("6N6&>9Q> '#D848488!&662BC}}#D848488 D!"&&(#FOGFO;q@FA#bhhr1o5F "&&(#FOGFO;q@ '#D848488!'FF3CD}}#D848488hh!##u%!S%( 3J- 8H#5!5!"Ih$7$9!:<
J#D848488 '
  !'#FB/%f12567FA#ad]F	 '#FB/%f12567 '#D848488!'5+16*:<}}#D848488hh!##u% *$0CC,inE'eC'A DHHJ$5$9"=CC t'V88:	D 00&}A-23->@ @ z 3J-)vvay$#D8484884!TD[/1afa0%edD\/5v.>@C =='<t<t<<A  c	Rll30!#UA.%r!c5!AQ'At~~a+,,%!)D040400QU*<FN
 $D84848L IIot<M<6JM)##E " As   0+X> X> >YYr   )r   r   r   r   r   ro   rf   r   rw   r   r{   r  r   r   r	  r   r  r+  r  rL   r   r   rC   r   r  r   s   @r6   r  r  (  ss    'R
#,M*4-/:27:  M*Z + Zr8   r  r  )r   ra  c                   `    \ rS rSrSr\R                  rS rS r	S r
S rS rS rS	 rS
 rSrg)tukeylambda_geni.*  a  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                 .    [         R                  " U5      $ rO   r  rE   lams     r6   rf   tukeylambda_gen._argcheckG*  s    {{3r8   c                 ^    [        SS[        R                  * [        R                  4S5      /$ )Nr  Fr3  rl   rn   s    r6   ro   tukeylambda_gen._shape_infoJ*  s%    5%266'266):NKLLr8   c                 J    [        US:  U4S [        R                  S9nU* U4$ )Nr   c                     SU -  $ ra   r   )r  s    r6   r:  .tukeylambda_gen._get_support.<locals>.<lambda>O*  s    QsUr8   ri  rZ  )rE   r  r   s      r6   r   tukeylambda_gen._get_supportM*  s-    sQw*!#) r1ur8   c           	         [         R                  " [        R                  " X5      5      nX2S-
  -  [         R                  " SU-
  5      US-
  -  -   n[         R                  " SS9   S[         R                  " U5      -  n[         R
                  " US:*  [        U5      S[         R                  " U5      -  :  -  US5      sS S S 5        $ ! , (       d  f       g = f)Nr   r   rp  rq  r   r   )rQ   r"  r~   tklmbdars  r  r  )rE   rv   r  Fxr)  s        r6   rw   tukeylambda_gen._pdfS*  s    ZZ

1*+c']bjj2.#c'::[[)RZZ^#B88SAX#a&3rzz#3F*FGSQ *))s   &AC


Cc                 .    [         R                  " X5      $ rO   )r~   r  )rE   rv   r  s      r6   r{   tukeylambda_gen._cdfZ*  s    zz!!!r8   c                 `    [         R                  " X5      [         R                  " U* U5      -
  $ rO   )r~   r  r  )rE   r   r  s      r6   r   tukeylambda_gen._ppf]*  s#    yy 2;;r3#777r8   c                 2    S[        U5      S[        U5      4$ r  )_tlvar_tlkurtr  s     r6   r   tukeylambda_gen._stats`*  s    &+q'#,..r8   c                 F   ^ U4S jn[         R                  " USS5      S   $ )Nc                 p   > [         R                  " [        U TS-
  5      [        SU -
  TS-
  5      -   5      $ ra   )rQ   r  r  )rK  r  s    r6   integ'tukeylambda_gen._entropy.<locals>.integd*  s/    66#aQ-AaCQ788r8   r   r   )r   rJ  )rE   r  r  s    ` r6   r  tukeylambda_gen._entropyc*  s     	9~~eQ*1--r8   r   N)r   r   r   r   r   r   rI  rJ  rf   ro   r   rw   r{   r   r   r  r   r   r8   r6   r  r  .*  s>    , "44M MR"8/.r8   r  tukeylambdac                       \ rS rSrS rSrg)FitUniformFixedScaleDataErroril*  c                      SU SU S3U l         g )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   r  )rE   rt  r  s      r6   r  &FitUniformFixedScaleDataError.__init__m*  s$    ::= ?xq" 		r8   r  N)r   r   r   r   r  r   r   r8   r6   r  r  l*  s    
r8   r  c                   V    \ rS rSrSrS rSS jrS rS rS r	S	 r
S
 r\S 5       rSrg)uniform_geniv*  zA 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                     / $ rO   r   rn   s    r6   ro   uniform_gen._shape_info*  r   r8   Nc                 (    UR                  SSU5      $ r  )r  r   s      r6   r   uniform_gen._rvs*  s    ##Cd33r8   c                     SX:H  -  $ r>  r   r   s     r6   rw   uniform_gen._pdf*  s    AF|r8   c                     U$ rO   r   r   s     r6   r{   uniform_gen._cdf*      r8   c                     U$ rO   r   r   s     r6   r   uniform_gen._ppf*  r$  r8   c                     g)N)r   gUUUUUU?r   g333333r   rn   s    r6   r   uniform_gen._stats*  s    #r8   c                     grs  r   rn   s    r6   r  uniform_gen._entropy*  rc  r8   c                    [        U5      S:  a  [        S5      eUR                  SS5      nUR                  SS5      n[        U5        Ub  Ub  [	        S5      e[
        R                  " U5      n[
        R                  " U5      R                  5       (       d  [	        S5      eUca  Uc'  UR                  5       n[
        R                  " U5      nOuUnUR                  5       U-
  nUR                  5       U:  a  [        SXfU-   S	9eO>[
        R                  " U5      nX:  a	  [        XS
9eUR                  5       SXX-
  -  -
  nUn[        U5      [        U5      4$ )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   re  r  Nr  r  r   r  r  )rt  r  r   )r  r4   r3   r7   r!  rQ   r"  r#  r$  rg  rt  rL  r  r  r  )	rE   rF   rG   r5   r  r  r.   r/   rt  s	            r6   rC   uniform_gen.fit*  sF   V t9q=122xx%(D)$T* 2 ) * * zz${{4 $$&&CDD> >|hhjt 
S(88:#&y;OO $ &&,C|3KK ((*sFL11CE Sz5<''r8   r   r-  )r   r   r   r   r   ro   r   rw   r{   r   r   r  rL   rC   r   r   r8   r6   r  r  v*  s@    
4$ R( R(r8   r  r  c                      ^  \ rS rSrSrS rS rSS jr\" \	5      U 4S j5       r
S rS rS	 rS
 rS r\" \	SS9  SU 4S jj5       r\\" \	SS9U 4S j5       5       rSrU =r$ )vonmises_geni0+  aE  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                 @    [        SSS[        R                  4S5      /$ )Nr	
  Fr   rk   rl   rn   s    r6   ro   vonmises_gen._shape_info+  s    7EArvv;FGGr8   c                     US:  $ r  r   r!
  s     r6   rf   vonmises_gen._argcheck+  s    zr8   c                 "    UR                  SXS9$ )Nr   r  )vonmises)rE   r	
  r   r   s       r6   r   vonmises_gen._rvs+  s    $$S%$;;r8   c                    > [         TU ]  " U0 UD6n[        R                  " U[        R                  -   S[        R                  -  5      [        R                  -
  $ rD  )rA   r)  rQ   modr  )rE   rG   r5   r)  r  s       r6   r)  vonmises_gen.rvs+  s@    gk4(4(vvcBEEk1RUU7+bee33r8   c                     [         R                  " U[        R                  " U5      -  5      S[         R                  -  [        R
                  " U5      -  -  $ rD  )rQ   r   r~   cosm1r  r  r
  s      r6   rw   vonmises_gen._pdf+  s:    
 vveBHHQK'(AbeeGBFF5M,ABBr8   c                     U[         R                  " U5      -  [        R                  " S[        R                  -  5      -
  [        R                  " [         R
                  " U5      5      -
  $ rD  )r~   r:  rQ   r  r  r  r
  s      r6   r   vonmises_gen._logpdf+  s@    rxx{"RVVAbeeG_4rvvbffUm7LLLr8   c                 .    [         R                  " X!5      $ rO   )r   von_mises_cdfr
  s      r6   r{   vonmises_gen._cdf+  s    ##E--r8   c                     gr?  r   r!
  s     r6   _stats_skipvonmises_gen._stats_skip+  rA  r8   c                     U* [         R                  " U5      -  [         R                  " U5      -  [        R                  " S[        R
                  -  [         R                  " U5      -  5      -   U-   $ rD  )r~   i1er  rQ   r  r  r!
  s     r6   r  vonmises_gen._entropy+  sV     &6q255y266%=0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   c           	         > [         R                  * [         R                  pUc  X9-   nUc  X:-   n[        TU ]  " XUXEXg40 UD6$ rO   )rQ   r  rA   r   )rE   r  rG   r.   r/   lbubconditionalr5   r;  r:  r  s              r6   r   vonmises_gen.expect+  sS     %%B:B:Bw~d##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                 
  > UR                  SS5      (       a  [        TU ]  " U/UQ70 UD6$ [        XX#5      u  ppVU R                  [
        R                  * :X  a  [        TU ]  " U/UQ70 UD6$ [
        R                  " US[
        R                  -  5      nS nS nUb  UOU" U5      n	Ub  UOU" X5      n
[
        R                  " U	[
        R                  -   S[
        R                  -  5      [
        R                  -
  n	XS4$ )Nr\  FrW   c                 .    [         R                  " U 5      $ rO   )rI  circmean)rF   s    r6   find_mu!vonmises_gen.fit.<locals>.find_mu+  s    >>$''r8   c                 p  ^ [         R                  " [         R                  " X-
  5      5      [        U 5      -  mTS:X  a  gTS:  aM  U4S jnTST-
  -  ST-   -  nSU-  nU" U5      S:  a  U$ U" U5      S::  a  U$ [	        USX44S9nUR
                  $ [         R                  " [        5      R                  $ )Nr   g 7yACr   c                 d   > [         R                  " U 5      [         R                  " U 5      -  T-
  $ rO   )r~   rE  r  )r	
  rL  s    r6   solve_for_kappa=vonmises_gen.fit.<locals>.find_kappa.<locals>.solve_for_kappa+  s#    66%=6::r8   rW   r  )r1   rh  )	rQ   r  rQ  r  r+   rk  r  r  r  )rF   r.   rS  lower_boundupper_boundroot_resrL  s         @r6   
find_kappa$vonmises_gen.fit.<locals>.find_kappa+  s     rvvcj)*3t94A Av Q;  1gqsmm #;/14&&$[1Q6&&*?84?3M OH#==( xx+++r8   r   )r3   rA   rC   rj  r   rQ   r  r7  )rE   rF   rG   r5   r  r  r  rO  rX  r.   re  r  s              r6   rC   vonmises_gen.fit+  s     88J&&7;t3d3d33%@AE&M"d66beeV7;t3d3d33 vvdAI&	(6	,r &dGDM ,*T2GffS255[!bee),ruu41}r8   r-  )Nr   r   r   NNF)r   r   r   r   r   ro   rf   r   r   r   r)  rw   r   r{   rB  r  r	   r   rL   rC   r   r  r   s   @r6   r.  r.  0+  s    ^~H< M*4 +4CM. 
; } 5  FJ 
B	
B } 5/ 0
N0 Nr8   r.  r4  vonmises_linec                   |    \ rS rSrSr\R                  rS rSS jr	S r
S rS rS	 rS
 rS rS rS rS rS rSrg)r  i&,  a,  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                     / $ rO   r   rn   s    r6   ro   wald_gen._shape_info=,  r   r8   Nc                 $    UR                  SSUS9$ r  r  r   s      r6   r   wald_gen._rvs@,  s      c 55r8   c                 .    [         R                  US5      $ r>  )r  rw   r   s     r6   rw   wald_gen._pdfC,  s    }}Q$$r8   c                 .    [         R                  US5      $ r>  )r  r{   r   s     r6   r{   wald_gen._cdfG,      }}Q$$r8   c                 .    [         R                  US5      $ r>  )r  r   r   s     r6   r   wald_gen._sfJ,  s    ||As##r8   c                 .    [         R                  US5      $ r>  )r  r   r   s     r6   r   wald_gen._ppfM,  re  r8   c                 .    [         R                  US5      $ r>  )r  r   r   s     r6   r   wald_gen._isfP,  re  r8   c                 .    [         R                  US5      $ r>  )r  r   r   s     r6   r   wald_gen._logpdfS,      3''r8   c                 .    [         R                  US5      $ r>  )r  r  r   s     r6   r  wald_gen._logcdfV,  rn  r8   c                 .    [         R                  US5      $ r>  )r  r	  r   s     r6   r	  wald_gen._logsfY,  s    q#&&r8   c                     g)N)r   r   r  r  r   rn   s    r6   r   wald_gen._stats\,  s    "r8   c                 ,    [         R                  S5      $ r>  )r  r  rn   s    r6   r  wald_gen._entropy_,  s      %%r8   r   r-  )r   r   r   r   r   r   rI  rJ  ro   r   rw   r{   r   r   r   r   r  r	  r   r  r   r   r8   r6   r  r  &,  sP    ( "44M6%%$%%(('#&r8   r  r  c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)wrapcauchy_genif,  aS  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                     US:  US:  -  $ r   r   r  s     r6   rf   wrapcauchy_gen._argcheck|,  s    A!a%  r8   c                      [        SSSS5      /$ )Nra  F)r   r   r3  r  rn   s    r6   ro   wrapcauchy_gen._shape_info,  s    3v~>??r8   c                     SX"-  -
  S[         R                  -  SX"-  -   SU-  [         R                  " U5      -  -
  -  -  $ r	  r  re  s      r6   rw   wrapcauchy_gen._pdf,  s;    AC!BEE'1QS51RVVAY#6788r8   c                 ^    S nS nSU-   SU-
  -  n[        U[        R                  :  X4X4S9$ )Nc                     S[         R                  -  [         R                  " U[         R                  " U S-  5      -  5      -  $ rf  rQ   r  r  r  rv   crs     r6   r  wrapcauchy_gen._cdf.<locals>.f1,  s.    RUU7RYYr"&&1+~666r8   c           	          SS[         R                  -  [         R                  " U[         R                  " S[         R                  -  U -
  S-  5      -  5      -  -
  $ rf  r  r  s     r6   r?  wrapcauchy_gen._cdf.<locals>.f2,  sA    qw2bffagk1_.E+E!FFFFr8   r   r  )r   rQ   r  )rE   rv   ra  r  r?  r  s         r6   r{   wrapcauchy_gen._cdf,  s9    	7	G !ea!e_!bee)aW::r8   c           
      ~   SU-
  SU-   -  nS[         R                  " U[         R                  " [         R                  U-  5      -  5      -  nS[         R                  -  S[         R                  " U[         R                  " [         R                  SU-
  -  5      -  5      -  -
  n[         R                  " US:  XE5      $ )Nr   rW   r   r   )rQ   r  r  r  r  )rE   r   ra  r  rcqrcmqs         r6   r   wrapcauchy_gen._ppf,  s    1us1uo		#bffRUU1Wo-..wq3rvvbeeQqSk':#:;;;xxE	3--r8   c                 `    [         R                  " S[         R                  -  SX-  -
  -  5      $ r  r  r  s     r6   r  wrapcauchy_gen._entropy,  s#    vvagquo&&r8   c                     [        U[        5      (       a  UR                  5       nS[        R                  " U5      [        R
                  " U5      S[        R                  -  -  4$ rQ  )r?   r*   r  rQ   rg  rt  r  )rE   rF   s     r6   r  wrapcauchy_gen._fitstart,  sG     dL))>>#DBFF4L"&&,"%%"888r8   r   N)r   r   r   r   r   rf   ro   rw   r{   r   r  r  r   r   r8   r6   rx  rx  f,  s+    *!@9;.'9r8   rx  
wrapcauchyc                   X    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSS jrSrg)gennorm_geni,  a  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                 @    [        SSS[        R                  4S5      /$ Nr  Fr   r3  rl   rn   s    r6   ro   gennorm_gen._shape_info,      651bff+~FGGr8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   r  s      r6   rw   gennorm_gen._pdf,  s    vvdll1+,,r8   c                     [         R                  " SU-  5      [        R                  " SU-  5      -
  [	        U5      U-  -
  $ r   )rQ   r  r~   r  r  r  s      r6   r   gennorm_gen._logpdf,  s4    vvc$h"**SX"66QEEr8   c                     S[         R                  " U5      -  nSU-   U[        R                  " SU-  [	        U5      U-  5      -  -
  $ r   )rQ   rR   r~   rW  r  rE   rv   r  ra  s       r6   r{   gennorm_gen._cdf,  s?    "''!*a1r||CHc!fdlCCCCr8   c                     [         R                  " US-
  5      nU[        R                  " SU-  SU-   SU-  U-  -
  5      SU-  -  -  $ )Nr   r   r   )rQ   rR   r~   ra  r  s       r6   r   gennorm_gen._ppf,  sH    GGAG2??3t8cAgQq-@ACHMMMr8   c                 (    U R                  U* U5      $ rO   r	  r  s      r6   r   gennorm_gen._sf,  s    yy!T""r8   c                 &    U R                  X5      * $ rO   r  r  s      r6   r   gennorm_gen._isf,  s    		!"""r8   c                     [         R                  " SU-  SU-  SU-  /5      u  p#nS[        R                  " X2-
  5      S[        R                  " XB-   SU-  -
  5      S-
  4$ )Nr   r  r  r   r   )r~   r  rQ   r   )rE   r  c1c3c5s        r6   r   gennorm_gen._stats,  sY    ZZT3t8SX >?
266"'?BrwR/?(@2(EEEr8   c                 t    SU-  [         R                  " SU-  5      -
  [        R                  " SU-  5      -   $ rw  r}  rE   r  s     r6   r  gennorm_gen._entropy,  s0    Dy266"t),,rzz"t)/DDDr8   Nc                     UR                  SU-  US9nUSU-  -  n[        R                  " U5      nUR                  UR                  S9S:  nXV   * XV'   U$ )Nr   r  r   )r(  rQ   r"  randomre  )rE   r  r   r   r  r  r  s          r6   r   gennorm_gen._rvs,  sc     qvD1!D&MJJqM"""0367(r8   r   r-  )r   r   r   r   r   ro   rw   r   r{   r   r   r   r   r  r   r   r   r8   r6   r  r  ,  s@    )TH-FD
N
##FE	r8   r  gennormc                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)halfgennorm_geni-  aY  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                 @    [        SSS[        R                  4S5      /$ r  rl   rn   s    r6   ro   halfgennorm_gen._shape_info&-  r  r8   c                 L    [         R                  " U R                  X5      5      $ rO   r.  r  s      r6   rw   halfgennorm_gen._pdf)-  s     vvdll1+,,r8   c                 l    [         R                  " U5      [        R                  " SU-  5      -
  X-  -
  $ r>  r}  r  s      r6   r   halfgennorm_gen._logpdf/-  s)    vvd|bjjT22QW<<r8   c                 :    [         R                  " SU-  X-  5      $ r>  rR  r  s      r6   r{   halfgennorm_gen._cdf2-  s    {{3t8QW--r8   c                 B    [         R                  " SU-  U5      SU-  -  $ r>  r  r  s      r6   r   halfgennorm_gen._ppf5-  s     ~~c$h*SX66r8   c                 :    [         R                  " SU-  X-  5      $ r>  rV  r  s      r6   r   halfgennorm_gen._sf8-  s    ||CHag..r8   c                 B    [         R                  " SU-  U5      SU-  -  $ r>  r  r  s      r6   r   halfgennorm_gen._isf;-  s     s4x+c$h77r8   c                 n    SU-  [         R                  " U5      -
  [        R                  " SU-  5      -   $ r>  r}  r  s     r6   r  halfgennorm_gen._entropy>-  s+    4x"&&,&CH)===r8   r   Nr  r   r8   r6   r  r  -  s1    "FH-=.7/8>r8   r  halfgennormc                   \   ^  \ rS rSrSrS rS rU 4S jrS rS r	S r
S	 rS
 rS rSrU =r$ )crystalball_geniE-  aY  
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                     US:  US:  -  $ )z0
Shape parameter bounds are m > 1 and beta > 0.
r   r   r   )rE   r  r  s      r6   rf   crystalball_gen._argchecki-  s     A$(##r8   c                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )Nr  Fr   r3  r  r   rl   )rE   ibetaims      r6   ro   crystalball_gen._shape_infoo-  s:    651bff+~FUQK@{r8   c                     > [         TU ]  USS9$ )N)r   rd  r  ry  rz  s     r6   r  crystalball_gen._fitstartt-  s    w H 55r8   c                     SX2-  US-
  -  [         R                  " US-  * S-  5      -  [        [        U5      -  -   -  nS nS nU[	        X* :  XU4XVS9-  $ )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   rW   r   c                 <    [         R                  " U S-  * S-  5      $ rD  rL  rv   r  r  s      r6   rhs!crystalball_gen._pdf.<locals>.rhs-  s    661a4%!)$$r8   c                 j    X!-  U-  [         R                  " US-  * S-  5      -  X!-  U-
  U -
  U* -  -  $ r   rL  r  s      r6   lhs!crystalball_gen._pdf.<locals>.lhs-  sB    VaK"&&$'C"88Vd]Q&1"-. /r8   r  rQ   r   r   r   r   rE   rv   r  r  r	  r  r  s          r6   rw   crystalball_gen._pdfx-  sk     16QqS>BFFD!G8c>$::401 2	%	/ :a%i!1EEEr8   c                     SX2-  US-
  -  [         R                  " US-  * S-  5      -  [        [        U5      -  -   -  nS nS n[         R                  " U5      [        X* :  XU4XVS9-   $ )z8
Return the log of the PDF of the crystalball function.
r   r   rW   r   c                     U S-  * S-  $ rD  r   r  s      r6   r  $crystalball_gen._logpdf.<locals>.rhs-  s    qD57Nr8   c                     U[         R                  " X!-  5      -  US-  S-  -
  U[         R                  " X!-  U-
  U -
  5      -  -
  $ rD  rg  r  s      r6   r  $crystalball_gen._logpdf.<locals>.lhs-  sB    RVVAF^#dAgai/!BFF16D=1;L4M2MMMr8   r  )rQ   r   r   r   r  r   r  s          r6   r   crystalball_gen._logpdf-  st     16QqS>BFFD!G8c>$::401 2		N vvay:a%i!1MMMr8   c                     SX2-  US-
  -  [         R                  " US-  * S-  5      -  [        [        U5      -  -   -  nS nS nU[	        X* :  XU4XVS9-  $ )z(
Return CDF of the crystalball function
r   r   rW   r   c                     X!-  [         R                  " US-  * S-  5      -  US-
  -  [        [        U 5      [        U* 5      -
  -  -   $ NrW   r   r   rQ   r   r   r   r  s      r6   r  !crystalball_gen._cdf.<locals>.rhs-  sL    VrvvtQwhn551=9Q<)TE2B#BCD Er8   c                 |    X!-  U-  [         R                  " US-  * S-  5      -  X!-  U-
  U -
  U* S-   -  -  US-
  -  $ r  rL  r  s      r6   r  !crystalball_gen._cdf.<locals>.lhs-  sR    VaK"&&$'C"88Vd]Q&1"Q$/034Q38 9r8   r  r  r  s          r6   r{   crystalball_gen._cdf-  sl     16QqS>BFFD!G8c>$::401 2	E	9 :a%i!1EEEr8   c                 6   ^  S nU 4S jn[        X* :  XU4XES9$ )z4
Survival function of the crystalball distribution.
c                     X!-  US-
  -  [         R                  " US-  * S-  5      -  [        [        U5      -  -   n[        [	        U 5      -  U-  $ rf  )rQ   r   r   r   r   )rv   r  r  Ms       r6   r   crystalball_gen._sf.<locals>.rhs-  sK    ArvvtQwhqj11K	$4OOAx{*1,,r8   c                 .   > STR                  XU5      -
  $ ra   r	  )rv   r  r  rE   s      r6   r   crystalball_gen._sf.<locals>.lhs-  s    tyy!,,,r8   r  r@  )rE   rv   r  r  r  r  s   `     r6   r   crystalball_gen._sf-  s&    
	-
	- !e)aq\SAAr8   c                     SX2-  US-
  -  [         R                  " US-  * S-  5      -  [        [        U5      -  -   -  nXCU-  -  [         R                  " US-  * S-  5      -  US-
  -  nS nS n[	        X:  XU4XgS9$ )Nr   r   rW   r   c                     [         R                  " US-  * S-  5      nX!-  U-  US-
  -  nSU[        [        U5      -  -   -  nX!-  U-
  US-
  X!-  U* -  -  U-  U -  U-  SSU-
  -  -  -
  $ r  r  rK  r  r  eb2r)  r	  s         r6   ppf_less&crystalball_gen._ppf.<locals>.ppf_less-  s    &&$'!$C3!A#&A1{Yt_445AFTM!eaf^+C/1!3q!A#w?@ Ar8   c                     [         R                  " US-  * S-  5      nX!-  U-  US-
  -  nSU[        [        U5      -  -   -  n[	        [        U* 5      S[        -  X-  U-
  -  -   5      $ r  )rQ   r   r   r   r   r  s         r6   ppf_greater)crystalball_gen._ppf.<locals>.ppf_greater-  sl    &&$'!$C3!A#&A1{Yt_445AYu-;q0IIJJr8   r  r  )rE   rK  r  r  r	  pbetar  r  s           r6   r   crystalball_gen._ppf-  s    16QqS>BFFD!G8c>$::401 2tVrvvtQwhqj11QU;	A	K !)aq\XNNr8   c           
         SX2-  US-
  -  [         R                  " US-  * S-  5      -  [        [        U5      -  -   -  nS nU[	        US-   U:  XU4[         R
                  " U[         R                  /S9[         R                  5      -  $ )zB
Returns the n-th non-central moment of the crystalball function.
r   r   rW   r   c                 
   X!-  U-  [         R                  " US-  * S-  5      -  nX!-  U-
  nSU S-
  S-  -  [        R                  " U S-   S-  5      -  SSU -  [        R                  " U S-   S-  US-  S-  5      -  -   -  n[         R
                  " UR                  5      n[        [        U 5      S-   5       HA  nU[        R                  " X5      X@U-
  -  -  SU-  -  X'-
  S-
  -  X!-  U* U-   S-   -  -  -  nMC     X6-  U-   $ )z_
Returns n-th moment. Defined only if n+1 < m
Function cannot broadcast due to the loop over n
rW   r   r   r   r  )
rQ   r   r~   r(  rS  r	  re  rU  r*  binom)re   r  r  r  r  r  r  rq  s           r6   r  *crystalball_gen._munp.<locals>.n_th_moment-  s   
 !bffdAgX^44AA!Sy>BHHac1W$552'BKK1aq1$EEEGC((399%C3q6A:&qS1R!G;quqyIA26A:./ 0 ' 7S= r8   r;  )rQ   r   r   r   r   r2  r>  rm   )rE   re   r  r  r	  r  s         r6   r+  crystalball_gen._munp-  s     16QqS>BFFD!G8c>$::401 2	! :a!eai!1 ll;

|L ff& & 	&r8   r   )r   r   r   r   r   rf   ro   r  rw   r   r{   r   r   r+  r   r  r   s   @r6   r  r  E-  s@    "F$
6F,NF"B O(& &r8   r  crystalballzA Crystalball Function)r   longnamec                 B    [         R                  " SU S-  S-  5      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.
rd  rW   rR  )rw  s    r6   
_argus_phir  -  s"     ;;sCF1H%))r8   c                   P    \ rS rSrSrS rS rS rS rS r	SS	 jr
SS
 jrS rSrg)	argus_geni-  a  
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                 @    [        SSS[        R                  4S5      /$ )Nrw  Fr   r3  rl   rn   s    r6   ro   argus_gen._shape_info'.      5%!RVVnEFFr8   c                 t   [         R                  " SS9   SX-  -
  nS[         R                  " U5      -  [        -
  [         R                  " [	        U5      5      -
  nU[         R                  " U5      -   S[         R
                  " U* U-  5      -  -   US-  U-  S-  -
  sS S S 5        $ ! , (       d  f       g = f)Nrp  rq  r   r  r   rW   )rQ   rs  r  r   r  r  )rE   rv   rw  r  r  s        r6   r   argus_gen._logpdf*.  s    [[)ac	A"&&+.
31HHArvvay=3rxx1~#55Q
QF *))s   B
B))
B7c                 L    [         R                  " U R                  X5      5      $ rO   r.  rE   rv   rw  s      r6   rw   argus_gen._pdf1.  s    vvdll1*++r8   c                 *    SU R                  X5      -
  $ r>  rM	  r
  s      r6   r{   argus_gen._cdf4.  s    TXXa%%%r8   c                 p    [        U[        R                  " SU-
  SU-   -  5      -  5      [        U5      -  $ ra   )r  rQ   r&  r
  s      r6   r   argus_gen._sf7.  s0    #QQ 889JsOKKr8   Nc                 h  ^	^
 [         R                  " U5      nUR                  S:X  a  U R                  XUS9nO[	        UR
                  U5      u  nm	[        [         R                  " U5      5      n[         R                  " U5      n[         R                  " U/S/S//S9m
T
R                  (       dt  [        U	U
4S j[        [        U5      * S5       5       5      nU R                  T
S   UUS9nUR                  U5      XG'   T
R                  5         T
R                  (       d  Mt  US:X  a  US   nU$ )	Nr   )r  r   r  r  r  c              3   l   >#    U  H)  nTU   (       d  TR                   U   O
[        S 5      v   M+     g 7frO   r  r  s     r6   rb  !argus_gen._rvs.<locals>.<genexpr>G.  r  r  r   r   )rQ   r"  r   r  r   re  r*  rT  r  r  r  r  rU  r  r  r  )rE   rw  r   r   rM  r  r  r  rL  r  r  s            @@r6   r   argus_gen._rvs:.  s   jjo88q=""30< # >C #399d3GCRWWS\*J((4.CC5"/&0\N4B kk ;%*CI:q%9; ;$$RUz2> % @99S> kkk 2:b'C
r8   c                 |   [        [        R                  " U5      5      n[        [        R                  " U5      5      n[        R
                  " U5      nSnX-  nUS::  a  U* S-  n	Xu:  a  XW-
  n
UR                  U
S9nUR                  U
S9nUS-  n[        R                  " U5      X-  :*  n[        R                  " U5      nUS:  a%  [        R                  " SX   -
  5      nUXgX-   & X-  nXu:  a  M  GO0US::  a  [        R                  " U* S-  5      nXu:  a  XW-
  n
UR                  U
S9nUR                  U
S9nS[        R                  " USU-
  -  U-   5      -  U-  nUS-  U-   S:*  n[        R                  " U5      nUS:  a%  [        R                  " SX   -   5      nUXgX-   & X-  nXu:  a  M  OpXu:  aL  XW-
  n
UR                  SU
S9nUUS-  :*  n[        R                  " U5      nUS:  a  UU   XgX-   & X-  nXu:  a  ML  [        R                  " SSU-  U-  -
  5      n[        R                  " Xd5      $ )	Nr   r   rW   r  r  r   g?rd  )r  rQ   r	  r*  rT  r	  r  r  r  r&  r   r  r  )rE   rw  r  r   r	  r	  rv   r	  rG  r  rq  r  r  r  r	  r	  r)  echirc  s                      r6   r  argus_gen._rvs_scalarR.  sE   h r}}Z01 HHQK	y#:	A-M ((a(0 ((a(0H&&)qu,VVF^
>''!ai-0C<?A!79+I - CZ664%!)$D-M ((a(0 ((a(0tq1u~122T9 Q$(a-VVF^
>''!ai-0C<?A!79+I - -M //!/<tax-VVF^
><=fIA!79+I - AEDL()Azz!$$r8   c                    [         R                  " U[        S9n[        U5      n[         R                  " [         R
                  S-  5      U-  [        R                  " SUS-  S-  5      -  U-  n[         R                  " U5      nUS:  nX   nSSUS-  -  -
  U[        U5      -  X%   -  -   XE'   X)    n/ SQn[         R                  " Xv5      XE) '   X4US-  -
  S S 4$ )	Nr.	  rb  r   rW   rU  g?r  )	g_1g־r   gWBar   gp|RH?r   gE'卡?r   g?)rQ   r"  r  r  r&  r  r~   r  r  r   r
  )rE   rw  r	  r  r~  r  ra  coefs           r6   r   argus_gen._stats.  s     jjE*oGGBEE!Gs"RVVAsAvax%883>mmC SyIAqDL1y|#3ci#??	JKZZ(E
1*dD((r8   r   r-  )r   r   r   r   r   ro   r   rw   r{   r   r   r  r   r   r   r8   r6   r  r  -  s5    'PGG,&L0c%J)r8   r  arguszAn Argus Function)r   r  r   r   c                   v   ^  \ rS rSrSr\R                  rSS.U 4S jjrS rS r	S r
S	 rS
 rU 4S jrSrU =r$ )rv_histogrami.  a  
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                  > Xl         X l        [        U5      S:w  a  [        S5      e[        R
                  " US   5      U l        [        R
                  " US   5      U l        [        U R                  5      S-   [        U R                  5      :w  a  [        S5      eU R                  SS U R                  SS -
  U l        [        R                  " U R                  U R                  S   5      (       + nUc&  U(       a  Sn[        R                  " U[        SS	9  S
nO%U(       d  U R                  U R                  -  U l        U R                  [        [        R                  " U R                  U R                  -  5      5      -  U l        [        R                  " U R                  U R                  -  5      U l        [        R"                  " SU R                  S/5      U l        [        R"                  " SU R                   /5      U l        U R                  S   =US'   U l        U R                  S   =US'   U l        [(        TU ]T  " U0 UD6  g)a  
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.
rW   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.r  Tr   r   r   )
_histogram_densityr  r!  rQ   r"  _hpdf_hbins_hbin_widthsallcloser  r  r  r  r  cumsum_hcdfhstackr   r   rA   r  )rE   	histogramr  rG   r  	bins_varyr  r  s          r6   r  rv_histogram.__init__)/  s   & $y>QHIIZZ	!-
jj1.tzz?Q#dkk"22 3 4 4 !KKOdkk#2.>>D$5$5t7H7H7KLL	?yOGMM'>a@Gd&7&77DJZZ%tzzD<M<M/M(N"OO
YYtzzD,=,==>
YYTZZ56
YYTZZ01
#{{1~-sdf#{{2.sdf$)&)r8   c                 \    U R                   [        R                  " U R                  USS9   $ )z
PDF of the histogram
rT	  )side)r!  rQ   searchsortedr"  r   s     r6   rw   rv_histogram._pdfY/  s$     zz"//$++qwGHHr8   c                 X    [         R                  " XR                  U R                  5      $ )z#
CDF calculated from the histogram
)rQ   interpr"  r&  r   s     r6   r{   rv_histogram._cdf_/  s     yyKK44r8   c                 X    [         R                  " XR                  U R                  5      $ )z3
Percentile function calculated from the histogram
)rQ   r0  r&  r"  r   s     r6   r   rv_histogram._ppfe/  s     yyJJ44r8   c                     U R                   SS US-   -  U R                   SS US-   -  -
  US-   -  n[        R                  " U R                  SS U-  5      $ )z$Compute the n-th non-central moment.r   Nr  )r"  rQ   r  r!  )rE   re   	integralss      r6   r+  rv_histogram._munpk/  s[    [[_qs+dkk#2.>1.EE!A#N	vvdjj2&233r8   c                     [        U R                  SS S:  U R                  SS 4[        R                  S5      n[        R                  " U R                  SS U-  U R
                  -  5      * $ )zCompute entropy of distributionr   r  r   )r   r!  rQ   r  r  r#  )rE   r  s     r6   r  rv_histogram._entropyp/  sh    Ab)C/**Qr*, tzz!B'#-0A0AABBBr8   c                 `   > [         TU ]  5       nU R                  US'   U R                  US'   U$ )z6
Set the histogram as additional constructor argument
r(  r  )rA   _updated_ctor_paramr  r   )rE   dctr  s     r6   r:   rv_histogram._updated_ctor_paramx/  s2     g)+??KI
r8   )r   r#  r"  r&  r  r!  r   r   )r   r   r   r   r   r   rJ  r  rw   r{   r   r+  r  r:  r   r  r   s   @r6   r  r  .  sJ    Zv "//M15 .* .*`I554
C r8   r  c                   J   ^  \ rS rSrSrS rS rU 4S jrS rS r	S r
S	rU =r$ )
studentized_range_geni/  u  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                     US:  US:  -  $ r  r   )rE   rq  rC  s      r6   rf   studentized_range_gen._argcheck/  s    A"q&!!r8   c                     [        SSS[        R                  4S5      n[        SSS[        R                  4S5      nX/$ )Nrq  Fr   r3  rC  r   rl   )rE   rS  r"  s      r6   ro   !studentized_range_gen._shape_info/  s:    UQK@uq"&&k>Byr8   c                     > [         TU ]  USS9$ )N)rW   r   r  ry  rz  s     r6   r  studentized_range_gen._fitstart/  s    w F 33r8   c                    ^^^ SmU R                  5       u  mmUUU4S jn[        R                  " USS5      n[        R                  " U" XU5      [        R                  S9S   $ )N_studentized_range_momentc                   > [         R                  " X5      nXX#/n[        R                  " U[        5      R
                  R                  [
        R                  5      n[        R                  " [         TU5      n[        R                  * [        R                  4S[        R                  4T	T
4/n[        SSS9n[        R                  " XgUS9S   $ )Nr   r  -q=rC  rB  rangesopts)r   _studentized_range_pdf_logconstrQ   rD  r  rE  rF  rG  r   rH  rm   dictr   nquad)rm  rq  rC  	log_constargusr_datarN  rK  rL  r;  r:  cython_symbols            r6   _single_moment3studentized_range_gen._munp.<locals>._single_moment/  s    >>qEI'CxxU+22::6??KH"..v}hOCw'!RVVr2h?FuU3D??3DA!DDr8   r  r   r.	  r   )r   rQ   
frompyfuncr"  r>  )	rE   rm  rq  rC  rT  ufuncr;  r:  rS  s	         @@@r6   r+  studentized_range_gen._munp/  sT    3""$B
	E na3zz%b/<R@@r8   c                     S n[         R                  " USS5      n[         R                  " U" XU5      [         R                  S9S   $ )Nc                 ~   US:  a  Sn[         R                  " X5      nXX$/n[        R                  " U[        5      R
                  R                  [
        R                  5      n[        R                  * [        R                  4S[        R                  4/nOiSnX/n[        R                  " U[        5      R
                  R                  [
        R                  5      n[        R                  * [        R                  4/n[        R                  " [         X65      n[        SSS9n	[        R                  " XU	S9S   $ )	N順 _studentized_range_pdfr   !_studentized_range_pdf_asymptoticr  rH  rI  rJ  )r   rM  rQ   rD  r  rE  rF  rG  rm   r   rH  rN  r   rO  
r   rq  rC  rS  rP  rQ  rR  rK  rN  rL  s
             r6   _single_pdf/studentized_range_gen._pdf.<locals>._single_pdf0  s     F{ 8"BB1I	R+88C/66>>vOFF7BFF+a[9 !Df88C/66>>vOFF7BFF+,"..v}OCuU3D??3DA!DDr8   r  r   r.	  r   )rQ   rV  r"  r>  )rE   rv   rq  rC  r_  rW  s         r6   rw   studentized_range_gen._pdf0  s<    	E( k1a0zz%b/<R@@r8   c           	          S n[         R                  " USS5      n[         R                  " [         R                  " U" XU5      [         R                  S9S   SS5      $ )Nc                 ~   US:  a  Sn[         R                  " X5      nXX$/n[        R                  " U[        5      R
                  R                  [
        R                  5      n[        R                  * [        R                  4S[        R                  4/nOiSnX/n[        R                  " U[        5      R
                  R                  [
        R                  5      n[        R                  * [        R                  4/n[        R                  " [         X65      n[        SSS9n	[        R                  " XU	S9S   $ )	Nr[  _studentized_range_cdfr   !_studentized_range_cdf_asymptoticr  rH  rI  rJ  )r   _studentized_range_cdf_logconstrQ   rD  r  rE  rF  rG  rm   r   rH  rN  r   rO  r^  s
             r6   _single_cdf/studentized_range_gen._cdf.<locals>._single_cdf)0  s    
 F{ 8"BB1I	R+88C/66>>vOFF7BFF+a[9 !Df88C/66>>vOFF7BFF+,"..v}OCuU3D??3DA!DDr8   r  r   r.	  r   r   )rQ   rV  r  r"  r>  )rE   rv   rq  rC  rg  rW  s         r6   r{   studentized_range_gen._cdf'0  sK    	E, k1a0 wwrzz%b/DRH!QOOr8   r   )r   r   r   r   r   rf   ro   r  r+  rw   r{   r   r  r   s   @r6   r>  r>  /  s1    hT"
4A*A2P Pr8   r>  studentized_range)r   r   r   c                   f   ^  \ rS rSrSrS rS rS rS rS r	S r
\" \5      U 4S	 j5       rS
rU =r$ )rel_breitwigner_geniI0  aO  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                     US:  $ r  r   rE   rhos     r6   rf   rel_breitwigner_gen._argcheck0  s    Qwr8   c                 @    [        SSS[        R                  4S5      /$ )Nro  Fr   r3  rl   rn   s    r6   ro   rel_breitwigner_gen._shape_info0  r  r8   c           
      <   [         R                  " SSSUS-  -  -   -  S[         R                  " SSUS-  -  -   5      -   -  5      S-  [         R                  -  n[         R                  " SS9   X1U-
  X-   -  U-  S-  S-   -  sS S S 5        $ ! , (       d  f       g = f)NrW   r   rp  r  )rQ   r&  r  rs  )rE   rv   ro  r)  s       r6   rw   rel_breitwigner_gen._pdf0  s    GGQsAvX!bgga!CF(l&;";<
 [[h'c'AG,S014q89 (''s   .B
Bc           
         [         R                  " SS[         R                  " SSUS-  -  -   5      -   -  5      [         R                  -  n[         R                  " SSU-  -   5      [         R                  " U[         R                  " U* US-   -  5      -  5      -  nUS-  [         R                  " U5      -  n[         R
                  " US S5      $ )NrW   r   r  rM  )rQ   r&  r  r  imagr  )rE   rv   ro  r)  rG	  s        r6   r{   rel_breitwigner_gen._cdf0  s    GGAq2771qax<00122558GGBCK ii"''3$b/2234 	 Q(wwvtQ''r8   c                 f   US:X  a  gUS:X  a  [         R                  " SSSUS-  -  -   -  S[         R                  " SSUS-  -  -   5      -   -  5      [         R                  -  U-  nU[         R                  S-  [         R                  " U5      -   -  $ US:X  a  [         R                  " SSUS-  -  -   SS[         R                  " SSUS-  -  -   5      -   -  -  5      U-  nSUS-  -
  [         R                  " SSU-  -
  5      -  nSU-  [         R                  " U5      -  $ [         R
                  $ )Nr   r   r   rW   rM  r  )rQ   r&  r  r  r(  rm   )rE   re   ro  r)  rG	  s        r6   r+  rel_breitwigner_gen._munp0  s   66Q36\"a"''!aQh,*?&?@A a"))C.0116QsAvX!q2771qax<+@'@"ABA #(lbggb2c6k&::Fq52776?**66Mr8   c                 F    S S [         R                  [         R                  4$ rO   r*  rn  s     r6   r   rel_breitwigner_gen._stats0  s     T266266))r8   c                   > [        XX#5      u  ppV[        U[        5      nU(       a"  UR                  5       S:X  a  UR                  nSnUb  U(       a  [
        TU ]  " U/UQ70 UD6$ Uc;  [        R                  " X-
  / SQ5      u  pn
X-
  nX-  nU(       d  U/nSU;  a  XS'   O&[        R                  " X-
  5      nX-  nU(       d  U/n[
        TU ]  " U/UQ70 UD6$ )Nr   F)r  r   g      ?r/   )
rj  r?   r*   r@   rD   rA   rC   rQ   quantiler
  )rE   rF   rG   r5   r+  r  r  rH   r9  r:  r;  scale_0rho_0M_0r  s                 r6   rC   rel_breitwigner_gen.fit0  s     !<!
 dL1  "a' '' <87;t3d3d33> KK5FGMCciGMEwd" 'W))DK(CLEww{4/$/$//r8   r   )r   r   r   r   r   rf   ro   rw   r{   r+  r   r   r   rC   r   r  r   s   @r6   rl  rl  I0  sA    <zG:	(&* M* 0 + 0r8   rl  rel_breitwignerrO   (Q  r  collections.abcr   	functoolsr   r   rE  numpyrQ   numpy.polynomialr   scipy.interpolater   scipy._lib.doccerr	   r
   r   scipy._lib._ccallbackr   scipyr   r   scipy.specialspecialr~   scipy.special._ufuncsr  rs   scipy._lib._utilr   r   r  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.statsrI  r7   rL   r\   r^   r   r   r   r   r   r&  r  r   r  r   r   r   r   r   r   r   r   r   r   r.  r0  rK  rM  rj  rl  r  r!  r  rY   r  r  r  r  r"  r\  r^  r{  r}  r  r  r  r  r  r
  r>  r@  rw  ry  rG  r  r  r  r  r  r  r   rD  rF  rf  rk  r  r  r  r  r  r  r  r  r  r  r  r  r)  r=  r?  r$  rq  r  _supportr  r  r  r  r  r  r  r/  r1  r  r  r  r(  r  r  r  r  r  r   r"  rs  ru  r  r  r  r  r  r  r  r  r  r/  r2  rL  rR  rf  rh  ru  rw  r  r  r  r  rZ  r6	  ra	  rc	  rz	  r|	  r	  r	  r	  r	  r	  r	  r	  r	  r	  r
  r#
  rj  r8
  rM
  rO
  r_
  ra
  re
  r
  r
  r
  r
  r
  r
  r  r  r2  r4  rO  rQ  re  rg  r  r  r  r  r  r  r  r  r  rW  rY  rz  r|  r  r  r  r  r  r  r  r  r@  rB  rZ  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rO  rQ  rf  rh  rz  r|  r  r  r  r  r  r  r  r  _method_namesr  r  setattrr  r-  r/  rF  rK  r  r\  r^  r  r  r  r  r  r  r  r  r.  r4  r[  r  r  rx  r  r  r  r  r  r  r  r  r  r  r  r>  rm   rj  rl  r  listglobalsr  itemspairs_distn_names_distn_gen_names__all__r   r8   r6   <module>r     sL  
  $ ,   ' %7 7 3    # # 4 BJ J J ? 1 1H H H ( & 1 7&*.W! W!t 	C3W-Z) Z)| 	!sc85M 5p Ck2	 ggag$+(m} m` V3' 3'l 	Cg&( (V 
ruufQh"%%'	9*'- *'Z s
3

: 

	X 	w!} w!t #6*mM m` Ck2	4#= 4#n #:6~"} ~"B #F#T, T,n 
c	)Ox Od #F#J" J"Z 
	"O1m O1d % V1} V1r #F#4# 4#n 
ruufH	5J6 J6Z 
	"D- DN &0ABE= EP Z(j( j(Z 	Cg&K!M K!\ {+	&&E4M E4P Ck2	23= 23j #J/Jm JZ -8-.] -.` c5
k@M k@\ 
Cc;= ;| #J/^Fm ^FB -8h!= h!V (-?@ &  D4m D4N -8Q?m Q?h =1uM up Ck2	=;= =;@ #J/\"] \"~ .
)dP Pf 	Cg&40 40n 
c	)^= ^B #J//%- /%d &2CDb bJ "7->= ->` #J/*~= ~B Z(K= K\ Z(W] Wt c5
{} {|  #N;P= Pf #J/+M +\ {+	5] 5p cS|<
S= Sl #J/T!= T!n #J/ym yx	 -8P2} P2f  ^4@2] @2F al3
a
M a
H {+	56M 56p C3[9	ZM Zz {+	V Vr 
	"E- EP 9
%])] ])@ ,1EF .*bb.} b.J #F#b. b.J 
c	)q7= q7h Z(o= od Z(^] ^@ c5
C!- C!L )
,:- :-z 
c	)>0- >0B )
,;@ ;@| 
c	)LI LI^ 
	"JI JIZ 
c	)Y$ Y$x 	wa#= a#H #J/ `
} `
F #F#]m ]@ % sM sl 
sOEm EP 5[! [!| 
c	)6! 6!r 	Cg&AD= ADH Z(W4= W4t #:640} 40n  #N;31M 31l {+	:3 :3z 	DCg.v= vr #J/c?] c?T .
.
 
  
 <&} <&~ #F#}&M }&@ {+		 29 29j "Co>9&} 9&x  $#NC@'] @'F .
^F= ^FB Z(gEM gEV2* * C3[9	C3W-	, 	, 
AE1)!,- 
F FR 
cSx	0<4] <4~ c5
 
 0
9%Pg7M g7T {A6		 zm zz	 -8! 8.m 8.v =1
L 
t(- t(n s
3o= od Z(v_E:&| :&z #F#<9] <9~ cQruuW<@
T- Tn 9
%=>m =>@ 6e&m e&P =;ST*G) G)T 	w)<sKt= tn@PM @PF */Ba,.FF4 Q0- Q0h &2CD 	WY^^##%&!7}!M 
)
)^,<
<r8   