L i84ddlZddlmZddlmZmZddlZddlZddlZ ddl m Z ddl m Z ddlmZmZmZddlmZddlmZdd lmZddlmZddlmcmZdd lmZddlm cm!Z"d d l#m$Z$d d l%m&Z'm(Z)d dl*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3d dl4m5Z5m6Z6m7Z7d dl8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@d dlAmBZBddlCmDZDddlEmFZFddlGmHZHdZIdZJddZKGdde/ZLeLdddZMGdde/ZNeNdddd ZOGd!d"e/ZPePdd#$ZQe jd%e jzZTe jeTZVd&ZWd'ZXd(ZYd)ZZd*Z[d+Z\d,Z]d-Z^Gd.d/e/Z_e_d01Z`Gd2d3e/Zaeadd4$ZbGd5d6e/Zcece j d7z e jd7z d8ZdGd9d:e/Zeeeddd;ZfGd<d=egZhGd>d?eFZid@ZjdAZkGdBdCe/ZleldddDZmGdEdFe/ZnenddG$ZoGdHdIe/ZpepdddJZqGdKdLe/ZrerddM$ZsGdNdOe/ZtetddP$ZuGdQdRerZvevddS$ZwGdTdUe/ZxexdV1ZyGdWdXe/ZzezddY$Z{GdZd[e/Z|e|dd\$Z}Gd]d^e/Z~e~e j e jd_ZGd`dae/Zedb1ZGdcdde/Zedde$ZGdfdge/Zedh1ZGdidje/Zeddk$ZGdldme/Zedn1ZdoZGdpdqe/Zeddr$ZGdsdte/Zeddu$ZGdvdwe/Zeddx$ZGdydze/Zedd{$ZGd|d}e/Zedd~$ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zed1Zde_Gdde/ZeddZGdde/Zed1ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zed1ZdZGdde/Zedd$ZGddeZedd$ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zed1ZGdde/Zedd$ZdZGdde/Zed1ZGdde/Zed1ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zed1ZGdde/ZedddZGd„de/ZeddĬ$ZGdńde/ZeddǬ$ZGdȄde/Zeddʬ$ZGd˄de/Zedͬ1ZGd΄de/ZeddЬ$ZGdфde/ZedӬ1ZGdԄde/Zeddd֬ZGdׄde/Zed٬1ZGdڄde/Zedܬ1ZGd݄de/Zed߬1ZGdde/Zed1ZdZGdde/Zedd$ZGdde/Zedd鬌ZGdde/Zed1ZGdde/Zed1ZGdde/Zedd$ZdZGdde/Zedd$ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zedd$ZGdde/Zed1ZGdde/Zedd$ZGdde/Zed1ZGd d e/Zedd $Zd ZGd de/Zedd$ZGdde/Zedd$ZGdde/Zed1ZGdde/Zed1ZGdde/Zedd$ZGdde/Zedd$ZGdd e/Zed!1ZGd"d#e/Zeddd$ZGd%d&e/Zedd'$ZGd(d)e/Zed*1ZGd+d,e/Z e d-dd.Z Gd/d0e/Z e dd1$Z Gd2d3e/Z e d41Ze d51Zde_de_Gd6d7e/Zedd8$ZGd9d:e/Zed;1Zd<e_Gd=d>e/Zedd?$ZGd@dAe/Zed-ddBZGdCdDe/ZedE1ZGdFdGe/ZedH1ZGdIdJe/ZedddKZGdLdMe/ZedddNZGdOdPe/Z e ddQ$Z!dRe!_dSZ"dTZ#dUZ$GdVdWe/Z%e%dXd YZ&de&_GdZd[e/Z'e'dd\$Z(d]e(_Gd^d_e/Z)e)d`1Z*GdadbehZ+Gdcdde/Z,e,dddeZ-Gdfdge/Z.e.dh1Z/e.e j e jdiZ0GdjdkeīZ1e1ddl$Z2Gdmdne/Z3e3dd%e jzdoZ4Gdpdqe/Z5e5dr1Z6Gdsdte/Z7e7ddu$Z8Gdvdwe/Z9e9dxdyzZ:d{Z;Gd|d}e/Z<e<d~dddZ=Gdde/Z>Gdde/Z?e?dde jZAGdde/ZBeBdd$ZCeDeEjjZHe,eHe/\ZIZJeIeJzdgzZKy(N)Iterable)wrapscached_property Polynomial)BSpline)extend_notes_in_docstringreplace_notes_in_docstringinherit_docstring_from)LowLevelCallable)optimize) integrate _lazyselect)_stats)tukeylambda_variancetukeylambda_kurtosis) _vectorize_rvs_over_shapesget_distribution_names _kurtosis _isintegral rv_continuous_skew_get_fixed_fit_value _check_shape _ShapeInfo)kolmognkolmognpkolmogni)_XMIN_LOGXMIN_EULER_ZETA3_SQRT_PI_SQRT_2_OVER_PI_LOG_PI_LOG_SQRT_2_OVER_PI) CensoredData) root_scalar)FitErrorc|jdd|jdd|jdd|jdd|rtd|dy)a Remove the optimizer-related keyword arguments 'loc', 'scale' and 'optimizer' from `kwds`. Then check that `kwds` is empty, and raise `TypeError("Unknown arguments: %s." % kwds)` if it is not. This function is used in the fit method of distributions that override the default method and do not use the default optimization code. `kwds` is modified in-place. locNscale optimizermethodzUnknown arguments: .)pop TypeError)kwdss d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/stats/_continuous_distns.py_remove_optimizer_parametersr6(sY HHUDHHWdHH[$HHXt -dV1566 c.tfd}|S)Nc|jddj}t|t}|dk(s|r/|j dkDrt t |||g|i|S|r |j}||g|i|S)Nr0mlemmr) getlower isinstancer) num_censoredsupertypefit _uncensored)selfdataargsr4r0censoredfuns r5wrapperz _call_super_mom..wrapper?s(E*002dL1 T>h4+<+<+>+BdT.tCdCdC C''tT1D1D1 1r7)r)rHrIs` r5_call_super_momrJ;s" 3Z 2 2 Nr7c|xs|dz }||z }fd}|||s6|dz}||z }d}tj|r t||||s6|S)Nrcrtj|tj|k7SNnpsign)lbrackrbrackrHs r5interval_contains_rootz1_get_left_bracket..interval_contains_rootWs(wws6{#rwws6{';;;r7zVThe solver could not find a bracket containing a root to an MLE first order condition.)rOisinfFitSolverError)rHrRrQdiffrSmsgs` r5_get_left_bracketrYPsn  !vzF F?D<%VV4  $7 88F  % %%VV4 Mr7c:eZdZdZdZdZdZdZdZdZ dZ y ) ksone_genaKolmogorov-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>|dk\|tj|k(zSNrrOroundrDns r5 _argcheckzksone_gen._argcheckQ1 +,,r7c@tdddtjfdgSNraTrTFrrOinfrDs r5 _shape_infozksone_gen._shape_info3q"&&k=ABBr7c0tj|| SrM)scu _smirnovprDxras r5_pdfzksone_gen._pdfs a###r7c.tj||SrM)rm _smirnovcros r5_cdfzksone_gen._cdfs}}Q""r7c.tj||SrM)scsmirnovros r5_sfz ksone_gen._sfszz!Qr7c.tj||SrM)rm _smirnovcirDqras r5_ppfzksone_gen._ppfs~~a##r7c.tj||SrM)rvsmirnovir{s r5_isfzksone_gen._isf{{1a  r7N) __name__ __module__ __qualname____doc__rbrjrqrtrxr}rr7r5r[r[gs-BF-C$# $!r7r[?ksone)abnamec@eZdZdZdZdZdZdZdZdZ dZ d Z y ) kstwo_genadKolmogorov-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>|dk\|tj|k(zSr]r^r`s r5rbzkstwo_gen._argcheckrcr7c@tdddtjfdgSrergris r5rjzkstwo_gen._shape_info rkr7cbdt|ts|z dfStj|z dfSN?r)r>rrO asanyarrayr`s r5 _get_supportzkstwo_gen._get_support s;jH5QL 2==;KL r7ct||SrM)rros r5rqzkstwo_gen._pdfs1~r7ct||SrMrros r5rtzkstwo_gen._cdfsq!}r7ct||dSNFcdfrros r5rxz kstwo_gen._sfsq!''r7ct||dS)NTrr r{s r5r}zkstwo_gen._ppfs1$''r7ct||dSrrr{s r5rzkstwo_gen._isfs1%((r7N) rrrrrbrjrrqrtrxr}rrr7r5rrs2AD-C(()r7rkstwo)momtyperrrc4eZdZdZdZdZdZdZdZdZ y) kstwobign_genaLimiting 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 cgSrMrris r5rjzkstwobign_gen._shape_infoJ r7c.tj| SrM)rm_kolmogprDrps r5rqzkstwobign_gen._pdfMs Qr7c,tj|SrM)rm_kolmogcrs r5rtzkstwobign_gen._cdfPs||Ar7c,tj|SrM)rv kolmogorovrs r5rxzkstwobign_gen._sfSs}}Qr7c,tj|SrM)rm _kolmogcirDr|s r5r}zkstwobign_gen._ppfVs}}Qr7c,tj|SrM)rvkolmogirs r5rzkstwobign_gen._isfYszz!}r7N) rrrrrjrqrtrxr}rrr7r5rr%s&#H   r7r kstwobign)rrrTcHtj|dz dz tz SNrT@)rOexp _norm_pdf_Crps r5 _norm_pdfris 661a4%) { **r7c"|dz dz tz Sr)_norm_pdf_logCrs r5 _norm_logpdfrms qD53; ''r7c,tj|SrM)rvndtrrs r5 _norm_cdfrqs 771:r7c,tj|SrM)rvlog_ndtrrs r5 _norm_logcdfrus ;;q>r7c,tj|SrM)rvndtrir|s r5 _norm_ppfrys 88A;r7ct| SrMrrs r5_norm_sfr}s aR=r7ct| SrMrrs r5 _norm_logsfrs  r7ct| SrMrrs r5 _norm_isfrs aL=r7ceZdZdZdZddZdZdZdZdZ d Z d Z d Z d Z d ZdZeeeddZdZy)norm_genaA 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 cgSrMrris r5rjznorm_gen._shape_inforr7Nc$|j|SrM)standard_normalrDsize random_states r5_rvsz norm_gen._rvss++D11r7ct|SrMrrs r5rqz norm_gen._pdfs |r7ct|SrMrrs r5_logpdfznorm_gen._logpdf Ar7ct|SrMrrs r5rtz norm_gen._cdf |r7ct|SrMrrs r5_logcdfznorm_gen._logcdfrr7ct|SrMrrs r5rxz norm_gen._sfs {r7ct|SrM)rrs r5_logsfznorm_gen._logsfs 1~r7ct|SrMrrs r5r}z norm_gen._ppfrr7ct|SrMrrs r5rz norm_gen._isfrr7cy)N)rrrrrris r5rznorm_gen._stats!r7cZdtjdtjzdzzSNrrTrrOlogpiris r5_entropyznorm_gen._entropys"BFF1RUU7OA%&&r7a} 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 |jdd}|jdd}t|| | tdtj|}tj |j s td||j}n|}|-tj||z dzj}||fS|}||fS)Nflocfscale3All parameters fixed. There is nothing to optimize.$The data contains non-finite values.rT) r2r6 ValueErrorrOasarrayisfiniteallmeansqrt)rDrEr4rrr-r.s r5rBz norm_gen.fitsxx%(D)$T*   2)* *zz${{4 $$&CD D <))+CC >GGdSj1_2245EEzEEzr7cb|dk(ry|dzdk(r!tjt|dz Sy)z @returns Moments of standard normal distribution for integer n >= 0 See eq. 16 of https://arxiv.org/abs/1209.4340v2 rrrTrr)rv factorial2intr`s r5_munpznorm_gen._munps3 6 q5A:==Q!, ,r7NN)rrrrrjrrqrrtrrxrr}rrrrJr rrBrrr7r5rrsr,2"' 6?@@< r7rnorm)rcLeZdZdZej ZdZdZdZ dZ dZ dZ y) alpha_gena&An alpha continuous random variable. %(before_notes)s Notes ----- The probability density function for `alpha` ([1]_, [2]_) is: .. math:: f(x, a) = \frac{1}{x^2 \Phi(a) \sqrt{2\pi}} * \exp(-\frac{1}{2} (a-1/x)^2) where :math:`\Phi` is the normal CDF, :math:`x > 0`, and :math:`a > 0`. `alpha` takes ``a`` as a shape parameter. %(after_notes)s References ---------- .. [1] Johnson, Kotz, and Balakrishnan, "Continuous Univariate Distributions, Volume 1", Second Edition, John Wiley and Sons, p. 173 (1994). .. [2] Anthony A. Salvia, "Reliability applications of the Alpha Distribution", IEEE Transactions on Reliability, Vol. R-34, No. 3, pp. 251-252 (1985). %(example)s c@tdddtjfdgSNrFrFFrgris r5rjzalpha_gen._shape_info3266{NCDDr7cNd|dzz t|z t|d|z z zSNrrT)rrrDrprs r5rqzalpha_gen._pdf!s+AqDz)A,&y3q5'999r7cdtj|zt|d|z z ztjt|z S)Nr)rOrrrr s r5rzalpha_gen._logpdf%s8"&&)|l1SU733bffYq\6JJJr7c<t|d|z z t|z SNrrr s r5rtzalpha_gen._cdf(s3q5!IaL00r7c bdtj|t|t|zz z Sr)rOrrrrDr|rs r5r}zalpha_gen._ppf+s(2::a)AilN";;<<"44ME:K1='r7ralphac:eZdZdZdZdZdZdZdZdZ dZ y ) anglit_genaAn 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 cgSrMrris r5rjzanglit_gen._shape_infoIrr7c2tjd|zSr)rOcosrs r5rqzanglit_gen._pdfLsvvac{r7cZtj|tjdz zdzSNrrOsinrrs r5rtzanglit_gen._cdfPs"vvaai #%%r7cZtj|tjdz zdzSr")rOr rrs r5rxzanglit_gen._sfSs"vva"%%!)m$++r7cztjtj|tjdz z SNr#)rOarcsinrrrs r5r}zanglit_gen._ppfVs&yy$RUU1W,,r7cdtjtjzdz dz ddtjdzdz ztjtjzdz dzz fS) Nrrrr#`rTrOrris r5rzanglit_gen._statsYsRBEE"%%KN3&RB-?ruuQQR@R-RRRr7c2dtjdz SNrrTrOrris r5rzanglit_gen._entropy\{r7N) rrrrrjrqrtrxr}rrrr7r5rr5s+&&,-Sr7rr#anglitc4eZdZdZdZdZdZdZdZdZ y) arcsine_gena An arcsine continuous random variable. %(before_notes)s Notes ----- The probability density function for `arcsine` is: .. math:: f(x) = \frac{1}{\pi \sqrt{x (1-x)}} for :math:`0 < x < 1`. %(after_notes)s %(example)s cgSrMrris r5rjzarcsine_gen._shape_infowrr7ctjd5dtjz tj|d|z zz cdddS#1swYyxYw)Nignoredividerr)rOerrstaterrrs r5rqzarcsine_gen._pdfzsD [[ ) .ruu9RWWQ!W-- . . .s /AAczdtjz tjtj|zSNr)rOrr)rrs r5rtzarcsine_gen._cdfs&255y2771:...r7cZtjtjdz |zdzSr=r$rs r5r}zarcsine_gen._ppfs"vvbeeCik"C''r7cd}d}d}d}||||fS)Nrg?rrrDmumu2g1g2s r5rzarcsine_gen._statss$   3Br7cy)Ngοrris r5rzarcsine_gen._entropys&r7N rrrrrjrqrtr}rrrr7r5r5r5cs%&. /('r7r5arcsineceZdZdZdZy) FitDataErrorz=Raised when input data is inconsistent with fixed parameters.c(d|d|d|df|_y)Nz>Invalid values in `data`. Maximum likelihood estimation with z requires that z < (x - loc)/scale < z for each x in `data`.rF)rDdistrr=uppers r5__init__zFitDataError.__init__s/ $iui@""'*@ B  r7NrrrrrOrr7r5rJrJs G r7rJceZdZdZdZy)rVzN Raised when a solver fails to converge while fitting a distribution. cBd}||jddz }|f|_y)Nz1Solver for the MLE equations failed to converge:  )replacerF)rDmesgemsgs r5rOzFitSolverError.__init__s%B  T2&&G r7NrPrr7r5rVrVs  r7rVcttj||z}||| tj|zzz }|SrMrvpsi)rrras1psiabfuncs r5 _beta_mle_ar^s8 FF1q5ME eVbffQi'( (D Kr7c|\}}tj||z}||| tj|zzz ||| tj|zzz g}|SrMrY)thetarar[s2rrr\r]s r5 _beta_mle_abrbsb DAq FF1q5ME ufrvvay() ) ufrvvay() ) +D Kr7ceZdZdZdZddZdZdZdZdZ dZ d Z d Z fd Z eeed fdZdZxZS)beta_genaA 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 ctdddtjfd}tdddtjfd}||gSNrFrr rrgrDiaibs r5rjzbeta_gen._shape_info; UQK @ UQK @Bxr7c(|j|||SrMbeta)rDrrrrs r5rz beta_gen._rvss  At,,r7ctjd5tj|||cdddS#1swYyxYwNr8over)rOr;rm _beta_pdfrDrprrs r5rqz beta_gen._pdfs5[[h ' *==Aq) * * * 8Actj|dz | tj|dz |z}|tj||z}|Sr)rvxlog1pyxlogybetaln)rDrprrlPxs r5rzbeta_gen._logpdfsEjjS1"%S!(<< ryyA r7c0tj|||SrM)rvbetaincrss r5rtz beta_gen._cdfszz!Q""r7c0tj|||SrM)rvbetainccrss r5rxz beta_gen._sfs{{1a##r7c0tj|||SrM)rv betainccinvrss r5rz beta_gen._isfs~~aA&&r7c0tj|||SrM)rm _beta_ppfrDr|rrs r5r}z beta_gen._ppfs}}Q1%%r7c*||z}||z }||z|dz|dzzz }d||z ztj|dzz|dztj||zzz }d||z dz|dzz||z|dzzz z}||z|dzz|dzz}||z } |||| fS)NrTrrOr) rDrra_plus_b _beta_mean_beta_variance_beta_skewness_beta_kurtosis_excess_n_beta_kurtosis_excess_d_beta_kurtosis_excesss r5rzbeta_gen._statssq5xZ 1! x!| <=A;A)>>$qLBGGAEN:<"#AzX\'B'(1u1 '=(>#?"#a%8a<"8HqL"I 7:Q Q    ! # #r7ct|tr|j}t|t |fd}t j |d\}}t|!|||fS)NcJ|\}}d||z ztj||zdzz||zdzz tj||zz }|dz|dzd|zdz zz |dz|dzzzd|z|z|dzzz }|||z||zdzz||zdzzz}|dz}|z |z gS)NrTrrrr)rprrskkurDrEs r5r]z beta_gen._fitstart..funcsDAqAaCQ++q1uqy9BGGAaCLHBA1ac!e $q!tQqSz1AaCE1Q3K?B !A#qs1u+qs1u% %B !GBrE2b5> !r7)rrrL) r>r) _uncensorrrr fsolver@ _fitstart)rDrEr]rrrDrE __class__s @@r5rzbeta_gen._fitstarts_ dL )>>#D 4[ t_ "tZ01w QF 33r7z 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`. rc |jdd}|jdd}||t||g|i|S|jdd|jddt |gd}t |gd}t || | t dtj|js t dtj||z |z }tj|dkstj|dk\rtd |||z |j}||| |} d|z }d|z }n|} | |zd|z z } tjt | | t#|tj$|j'fd \} } } }| dk7r t)| | d} || | } } ntj$|j'}t+j,| j'}|d|z z|j/dz dz }||z} d|z |z} tjt0| | gt#|||fd \} } } }| dk7r t)| | \} } | | ||fS)Nrrf0fafix_a)f1fbfix_brrrrrmr=rNT)rF full_output)rV)ddof)r<r@rBr2rr6rrOrrravelanyrJrr rr^lenrsumrVrvlog1pvarrb)rDrErFr4rrrrxbarrrr`infoierrVr[rafacrs r5rBz beta_gen.fit$sxx%(D) <6>7;t3d3d3 3  4 !$(= > !$(= >$T* >bn)* *{{4 $$&CD D%/ 66$!) tqy 1vTG Gyy{ >R^~4x4x DAH%A&.__QTBFF4L$4$4$67 & "E4d ax$$//aA~!1!!#B4%$$&B!d(#dhhAh&66:Cs ATS A&.__q!f$iR( & "E4d ax$$//DAq!T6!!r7c d}d}d fd}d}||}||}t|dk\|dk\z|dk||z dk\z||k\z|dk||z dk\z||k\z|dk|dkzg| ||g||gS) Nctj|||dz tj|zz |dz tj|zz ||zdz tj||zzzSr0)rvrxrZrrs r5regularz"beta_gen._entropy..regularsfIIaOq1uq &99UbffQi'(+,q519q1u *EF Gr7c||z}dtjdtjztj|ztj|zdtj|zz dzz}d|z d|dzzz|dzzd|d zzz }d |z d |dzzz |dzz |d zz}d |z d |dzzz |dzz |d zz}|||z|zd z zS) NrrTrrni xr)rrsum_ablog_termt1t2t3s r5asymptotic_ab_largez.beta_gen._entropy..asymptotic_ab_largesUFqw"&&)+bffQi7!BFF6N:JJQNHVbo- .asymptotic_b_largesMUFA!a%266!9!44BQqS Ar!tH$q$wrz1AtGCK?!T'#+MT'#+ !4 ,./h79:BvIG$,q.!#)4<#346.asymptotic_a_larges%a+ +r7ctjtj|}tj|d|zz dz}tj|dk7||fddS)NrrTrc|dd|zzzS)Nrr)d_j_s r5z.threshold_large..sBaRTfDUr7i fill_value)rOfloorlog10xpx apply_where)vjds r5threshold_largez*beta_gen._entropy..threshold_largesV!%AR1W%)A??18aV5U.24 4r7gRAg(RAg.Ar) rDrrrrrr threshold_a threshold_brs @r5rzbeta_gen._entropys G 3 & , 4 &a( %a( Q&[Q&[9%ZAESL9Q+=MN%ZAESL9Q+=MNY1u95 01C.9q6  r7r)rrrrrjrrqrrtrxrr}rrrJr rrBr __classcell__rs@r5rdrdsj> -* #$'&# 4"}5+, c" , c"J. r7rdrmcZeZdZdZej ZdZd dZdZ dZ dZ dZ d Z d Zy) betaprime_genaA 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 ctdddtjfd}tdddtjfd}||gSrfrgrgs r5rjzbetaprime_gen._shape_inforjr7Ncltj|||}tj|||}||z SNrr)gammarvs)rDrrrru1u2s r5rzbetaprime_gen._rvss3 YYqt,Y ? YYqt,Y ?Bwr7cNtj|j|||SrMrOrrrss r5rqzbetaprime_gen._pdfvvdll1a+,,r7ctj|dz |tj||z|z tj||z Sr)rvrwrvrxrss r5rzbetaprime_gen._logpdfs:xxC#bjjQ&::RYYq!_LLr7cBtj|dkD|||fddS)Nrc<tjdd|zz ||Sr]rmrxx_a_b_s r5rz$betaprime_gen._cdf..stxxQV b"=r7c<tj|d|zz ||Sr]rmrtrs r5rz$betaprime_gen._cdf..styyq2vB?r7rrrss r5rtzbetaprime_gen._cdfs, EAq!9 = ?A Ar7cBtj|dkD|||fddS)Nrc<tjdd|zz ||Sr]rrs r5rz#betaprime_gen._sf..styya"fr2>r7c<tj|d|zz ||Sr]rrs r5rz#betaprime_gen._sf..stxxa"f r2>r7rrss r5rxzbetaprime_gen._sfs* EAq!9 > >@ @r7ctj|||\}}}tjj |||}tj d5|d|z z }ddd|dkD}tj |r+|r'dtjj|||z dz }Sdtjj||||||z dz |<|S#1swYxYw)Nr8r9rgH.?)rObroadcast_arraysstatsrmr}r;isscalarr)rDprrroutrnear1s r5r}zbetaprime_gen._ppfs%%aA.1a JJOOAq! $ [[ ) q1u+C V ;;q> 1a0014 EJJOOAfIqy!F)LLqPCK   s  CC'cbtj|kD||ffdtjS)NctjtdtdzDcgc]}||zdz ||z z c}dScc}w)Nrraxis)rOprodranger)rriras r5rz%betaprime_gen._munp...s@q#a&(9K!LA1Q3q51Q3-!LSTU!LsA rrrrOrh)rDrarrs ` r5rzbetaprime_gen._munp+s+ EAq6 Uvv r7r)rrrrrrrrjrrqrrtrxr}rrr7r5rrs@.^"44M  -M A@ $r7r betaprimec6eZdZdZdZdZdZdZd dZdZ y) bradford_genabA 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@tdddtjfdgSNcFrr rgris r5rjzbradford_gen._shape_infoKr r7cD|||zdzz tj|z SrrvrrDrpr s r5rqzbradford_gen._pdfNs!AaC#I!,,r7c^tj||ztj|z SrMrrs r5rtzbradford_gen._cdfRs!xx!}rxx{**r7c^tj|tj|z|z SrMrvexpm1rrDr|r s r5r}zbradford_gen._ppfUs"xxBHHQK(1,,r7cjtjd|z}||z ||zz }|dz|zd|zz d|z|z|zz }d}d}d|vr{tjdd|z|zd|z|z|dzzz d|z|z||dzzdzzzz}|tj|||dz zd|zzzd|z|dz zd|zzzz}d |vrj|dz|dz z|d|zd z zd zzd|z|z|z|d z z|dz zzd|z|z|zd|zd z zzd|dzzz}|d|z||dz zd|zzdzzz}||||fS)NrrrTsr rrkr+r#)rOrr)rDr momentsrrBrCrDrEs r5rzbradford_gen._statsXs FF3q5McAaC[#qyQ1Qq)   '>RT!VAaCE1Q3K/!Aq!A#wqy0AABB "''!Q!WQqS[/*AaC1IacM: :B '>Q$!*a1Rjm,RT!VAXqs^QqS-AAA#a%'1Q3r6"#%'1W-B !A#q!A#wqs{Q&& &B3Br7cntjd|z}|dz tj||z z SNrrr1)rDr rs r5rzbradford_gen._entropygs. FF1Q3Kurvvac{""r7NmvrGrr7r5r r 5s&*E-+- #r7r bradfordcReZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zy )burr_genaA 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 ctdddtjfd}tdddtjfd}||gSNr Frr rrgrDicids r5rjzburr_gen._shape_inforjr7cntj|dk(|||fdd}|jdk(r|dS|S)Nrc6||z|||zdz zzd||zzz Sr]rrc_rs r5rzburr_gen._pdf..s(rBw"r"uQw-8ABJGr7c@||z|| dz zzd|| zz|dzzz SNrrrr+s r5rzburr_gen._pdf..s6R22#)+< ="#bbSk/rCx!@!Br7rrrndimrDrpr routputs r5rqz burr_gen._pdfsE FQ1I G CD $[[A-vbz969r7cntj|dk(|||fdd}|jdk(r|dS|S)Nrctj|tj|ztj||zdz |z|dztj||zzz Sr])rOrrvrwrr+s r5rz"burr_gen._logpdf..sQr RVVBZ 7"((2b519b:Q Q#%a4288BH+="=!>r7ctj|tj|ztj| dz |ztj|dz|| zz Sr]rOrrvrwrvr+s r5rz"burr_gen._logpdf..sQr RVVBZ 7"$((B37B"7!8"$**RT29"=!>r7rr/r1s r5rzburr_gen._logpdfsF FQ1I ? ? @$[[A-vbz969r7cd|| zz| zSr]rrDrpr rs r5rtz burr_gen._cdfsAG r""r7c<tj|| z| zSrMrr8s r5rzburr_gen._logcdfsxxQB QB''r7cNtj|j|||SrMrOrrr8s r5rxz burr_gen._sfvvdkk!Q*++r7cDtjd|| zz| z Sr]rOrr8s r5rzburr_gen._logsfs%xx1qA2w;1"--..r7c$|d|z zdz d|z zSNrrrDr|r rs r5r}z burr_gen._ppfsDF a46**r7cltjd|z | }tj|d|z zSNrArvrvr)rDr|r r_qs r5rz burr_gen._isfs/ ZZq1" %xx|q))r7ctjddjdd|z }tj||zd|z |z\}}}}tj |dkD|tj }||dzz } tj |dkD| tj } tj|dkD|||| fdtj } tj|d kD||||| fd tj } tj|d k(r>|j| j| j| jfS|| | | fS) Nrr#rrTr@c\|d|z|zz d|dzzztj|dzz S)NrrTr)e1e2e3mu2_if_cs r5rz!burr_gen._stats..s52"R.sBqtBw,2b!e+aAg51DIr7r) rOarangereshapervrmwhererrrr0item) rDr rncrKrLrMrQrBrNrCrDrEs r5rzburr_gen._statss- YYq!_ $ $Qq )A -Rb1A5BB XXa#gr266 *A:hhq3w"&&1 __ Gb"b(+ Evv  __ Gb"b"h/ Kvv  771:?779chhj"'')RWWY> >3Br7cd}tj|tj|tj|}}}tj||kD||k(z||k(z|||f|tjS)NcPd|z|z }|tjd|z ||zzSrrvrmrar rrVs r5__munpzburr_gen._munp..__munp-a!BrwwsRxR00 0r7r)rOrrrr)rDrar r_burr_gen__munps r5rzburr_gen._munpsj 1**Q-A 1 a1A!q&1Q!V< !1ay&RVVE Er7N)rrrrrjrqrrtrrxrr}rrrrr7r5r#r#os@+` ::#(,/+**Er7r#burrcLeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z y ) burr12_gena}A Burr (Type XII) continuous random variable. %(before_notes)s See Also -------- fisk : a special case of either `burr` or `burr12` with ``d=1`` burr : Burr Type III distribution Notes ----- The probability density function for `burr12` is: .. math:: f(x; c, d) = c d \frac{x^{c-1}} {(1 + x^c)^{d + 1}} for :math:`x >= 0` and :math:`c, d > 0`. `burr12` takes ``c`` and ``d`` as shape parameters for :math:`c` and :math:`d`. This is the PDF corresponding to the twelfth CDF given in Burr's list; specifically, it is equation (20) in Burr's paper [1]_. %(after_notes)s The Burr type 12 distribution is also sometimes referred to as the Singh-Maddala distribution from NIST [2]_. References ---------- .. [1] Burr, I. W. "Cumulative frequency functions", Annals of Mathematical Statistics, 13(2), pp 215-232 (1942). .. [2] https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/b12pdf.htm .. [3] "Burr distribution", https://en.wikipedia.org/wiki/Burr_distribution %(example)s ctdddtjfd}tdddtjfd}||gSr%rgr&s r5rjzburr12_gen._shape_inforjr7cNtj|j|||SrMrr8s r5rqzburr12_gen._pdfrr7ctj|tj|ztj|dz |ztj| dz ||zzSr]r6r8s r5rzburr12_gen._logpdf"sLvvay266!9$rxxAq'99BJJr!tQPQT.moment_if_exists;r\r7rrrrOr)rDrar rrps r5rzburr12_gen._munp:s6 1q1uqy1a)5E*,&&2 2r7N)rrrrrjrqrrtrrxrr}rrrr7r5r`r`s;+X -S/+,$4 12r7r`burr12cXeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd Zy)fisk_genaA 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@tdddtjfdgSr rgris r5rjzfisk_gen._shape_infoqr r7c0tj||dSr)r^rqrs r5rqz fisk_gen._pdftsyyAs##r7c0tj||dSr)r^rtrs r5rtz fisk_gen._cdfxyyAs##r7c0tj||dSr)r^rxrs r5rxz fisk_gen._sf{sxx1c""r7c0tj||dSr)r^rrs r5rzfisk_gen._logpdf~s||Aq#&&r7c0tj||dSr)r^rrs r5rzfisk_gen._logcdfs||Aq#&&r7c0tj||dSr)r^rrs r5rzfisk_gen._logsfs{{1a%%r7c0tj||dSr)r^r}rs r5r}z fisk_gen._ppfrxr7c0tj||dSr)r^rrs r5rz fisk_gen._isfrxr7c0tj||dSr)r^rrDrar s r5rzfisk_gen._munpszz!Q$$r7c.tj|dSr)r^rrDr s r5rzfisk_gen._statss{{1c""r7c2dtj|z Srr1rs r5rzfisk_gen._entropy266!9}r7N)rrrrrjrqrtrxrrrr}rrrrrr7r5rtrtFsE)TE$$#''&$$%#r7rtfiskcNeZdZdZdZdZdZdZdZdZ dZ d Z d Z d d Z y ) cauchy_genaA 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 cgSrMrris r5rjzcauchy_gen._shape_inforr7ctjd5dtjz d||zzz cdddS#1swYyxYw)Nr8rpr)rOr;rrs r5rqzcauchy_gen._pdfs; [[h ' 'ruu9c!A#g& ' ' 's =Acftj|}tj|dk|ddS)NrcBt tj|dzz Sr)r'rOrabsxs r5rz$cauchy_gen._logpdf..s'BHHT1W$55r7czt dtj|ztjd|z dzzz SNrTr)r'rOrrrs r5rz$cauchy_gen._logpdf..s/7(at nrxx4! 7L&LMr7)rOabsrr)rDrprs r5rzcauchy_gen._logpdfs5 vvay 1Hd 5 NP Pr7cRtjd| tjz Sr]rOarctan2rrs r5rtzcauchy_gen._cdfszz!aR &&r7c0tj|ddSNrr)rm _cauchy_ppfrs r5r}zcauchy_gen._ppfq!Q''r7cPtjd|tjz Sr]rrs r5rxzcauchy_gen._sfszz!Q%%r7c0tj|ddSr)rm _cauchy_isfrs r5rzcauchy_gen._isfrr7c~tjtjtjtjfSrMrOrris r5rzcauchy_gen._stats!vvrvvrvvrvv--r7cNtjdtjzSr(rris r5rzcauchy_gen._entropyvvagr7Nct|tr|j}tj|gd\}}}|||z dz fSN2KrTr>r)rrO percentilerDrErFp25p50p75s r5rzcauchy_gen._fitstartA dL )>>#D dL9 S#S3YM!!r7rM)rrrrrjrqrrtr}rxrrrrrr7r5rrs:4' P'(&(."r7rcauchycNeZdZdZdZd dZdZdZdZdZ d Z d Z d Z d Z y)chi_genaA 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@tdddtjfdgSNdfFrr rgris r5rjzchi_gen._shape_info 4BFF ^DEEr7NcXtjtj|||Sr)rOrchi2rrDrrrs r5rz chi_gen._rvs s wwtxxLxIJJr7cLtj|j||SrMrrDrprs r5rqz chi_gen._pdfsvvdll1b)**r7ctjddtjdz|zz tjd|zz }|tj|dz |zd|dzzz S)NrTrr)rOrrvrrw)rDrprls r5rzchi_gen._logpdfs] FF1I266!9 R '"**RU*; ;288BGQ''"QT'11r7c@tjd|zd|dzzSNrrTrvgammaincrs r5rtz chi_gen._cdfs{{2b5"QT'**r7c@tjd|zd|dzzSrrv gammainccrs r5rxz chi_gen._sfs||BrE2ad7++r7c`tjdtjd|z|zSNrTrrOrrv gammaincinvrDr|rs r5r}z chi_gen._ppfs%wwq2q1122r7c`tjdtjd|z|zSrrOrrv gammainccinvrs r5rz chi_gen._isf"s%wwqB2233r7cztjdtjd|zdz}|||zz }d|dzz|dd|zz zztjtj |dz }d|zd|z zd|dzzz d|dzzd|zdz zz}|tj|d zz}||||fS) NrTrrIr?rrr#r)rOrrvpochrpowerrDrrBrCrDrEs r5rzchi_gen._stats%s WWQZ"''#(C0 02b5jCi"a"f+%rzz"((32D'E E rT3r6]1RU7 "Qr1uW"Q%7 7 bjjc""3Br7cDd}d}tj|dk|||S)Nctjd|zd|tjdz |dz tjd|zzz zzSr)rvrrOrdigammars r5regular_formulaz)chi_gen._entropy..regular_formula0sMJJrBw'R"&&)^rAvC"H9M.MMNO Pr7cdtjtjdz z|dzdz z |dzdz z d|dzzz |dzd z zS) NrrTrrrgll?rrs r5asymptotic_formulaz,chi_gen._entropy..asymptotic_formula4sY"&&-/)RVQJ6"b&!CBFm$')2vrk2 3r7i,r)rDrrrs r5rzchi_gen._entropy.s) P 3rCx_>PQQr7rrrrrrjrrqrrtrxr}rrrrr7r5rrs<<FK+ 2+,34 Rr7rchicNeZdZdZdZd dZdZdZdZdZ d Z d Z d Z d Z y)chi2_genaA 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@tdddtjfdgSrrgris r5rjzchi2_gen._shape_info`rr7Nc&|j||SrM) chisquarers r5rz chi2_gen._rvscs%%b$//r7cLtj|j||SrMrrs r5rqz chi2_gen._pdffsvvdll1b)**r7ctj|dz dz ||dz z tj|dz z tjd|zdz z S)NrrrT)rvrwrrOrrs r5rzchi2_gen._logpdfjsMxx2a#ad*RZZ2->>"&&)B,PRARRRr7c.tj||SrM)rvchdtrrs r5rtz chi2_gen._cdfmxxAr7c.tj||SrM)rvchdtrcrs r5rxz chi2_gen._sfpyyQr7c.tj||SrM)rvchdtrirDrrs r5rz chi2_gen._isfsrr7c:dtj|dz |zSrrvrrs r5r}z chi2_gen._ppfvs1a(((r7c\|}d|z}dtjd|z z}d|z }||||fS)NrTr(@rrs r5rzchi2_gen._statsys= d rwws2v  "W3Br7cNd|z}d}d}tj|dk|||S)Nrc|tjdztj|zd|z tj|zzSr)rOrrvrrZ)half_dfs r5rz*chi2_gen._entropy..regular_formulas>bffQi'"**W*==[BFF7O34 5r7ctjdddtjdtjzzzz}d|z }|d|d|d|dz zzzzzzdtj|zz|zS)NrTrrgUUUUUUUUUUUUտgllg@r)rr hs r5rz-chi2_gen._entropy..asymptotic_formulas q CRVVAbeeG_!455AG Ata51S5=(9!9::;w'(*+, -r7}r)rDrrrrs r5rzchi2_gen._entropys8( 5 -w}g.0BD Dr7r)rrrrrjrrqrrtrxrr}rrrr7r5rr>s= BF0+S  )Dr7rrcFeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) cosine_gena\A cosine continuous random variable. %(before_notes)s Notes ----- The cosine distribution is an approximation to the normal distribution. The probability density function for `cosine` is: .. math:: f(x) = \frac{1}{2\pi} (1+\cos(x)) for :math:`-\pi \le x \le \pi`. %(after_notes)s %(example)s cgSrMrris r5rjzcosine_gen._shape_inforr7cZdtjz dtj|zzSNrrrOrr rs r5rqzcosine_gen._pdfs!RUU{AbffQiK((r7ctj|}tj|dk7|dtj S)Nrcztj|tjdtjzz Sr)rOrrrr s r5rz$cosine_gen._logpdf..s#!rvvag)Fr7r)rOr rrrhrs r5rzcosine_gen._logpdfs4 FF1IqBwF+-66'3 3r7c,tj|SrMrm _cosine_cdfrs r5rtzcosine_gen._cdfsq!!r7c.tj| SrMrrs r5rxzcosine_gen._sfsr""r7c,tj|SrMrm_cosine_invcdfrDrs r5r}zcosine_gen._ppfs!!!$$r7c.tj| SrMrrs r5rzcosine_gen._isfs""1%%%r7ctjtjzdz dz }dtjdzdz zdtjtjzdz dzzz }d |d |fS) NrIrrr#Z@rrTrr.)rDrrs r5rzcosine_gen._statssa UURUU]S C ' BEE1HrM "cRUURUU]Q->,B&B CAsA~r7cTtjdtjzdz S)Nr#rrris r5rzcosine_gen._entropysvvags""r7N rrrrrjrqrrtrxr}rrrrr7r5rrs4()3 "#%& #r7rcosinecNeZdZdZdZd dZdZdZdZdZ d Z d Z d Z d Z y) dgamma_genaA 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@tdddtjfdgSrrgris r5rjzdgamma_gen._shape_infor r7Nc|j|}tj|||}|tj|dk\ddzSNrrrrr)uniformrrrOrT)rDrrrugms r5rzdgamma_gen._rvssE  d + YYqt,Y ?BHHQ#Xq"---r7ct|}ddtj|zz ||dz zztj| zSr )rrvrrOrrDrpraxs r5rqzdgamma_gen._pdfs> VAbhhqkM"2#;.<E. = F1 6 52 1 6r7rdgammaceZdZdZej ZejZejZ ejZ ejZejZdZdZdZdZddZdZd Zd Z d Z d Z d ZdZy)dpareto_lognorm_genaA 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 cH|j||j|z SrM)_Phic_phirDzs r5_Rzdpareto_lognorm_gen._R\szz!}tyy|++r7cH|j||j|z SrM)_logPhic_logphir*s r5_logRzdpareto_lognorm_gen._logR_s}}Q$,,q/11r7c  tddtj tjfdtdddtjfdtdddtjfdtdddtjfdgS)NrFr rrrrrgris r5rjzdpareto_lognorm_gen._shape_infobsm3'8.I3266{NC3266{NC3266{NCE Er7c$|dkD|dkDz|dkDzSNrr)rDrrrrs r5rbzdpareto_lognorm_gen._argcheckhsA!a% AE**r7Nc|j|||}|j|}|j|} tj|||z z| |z z SNr)normalstandard_exponentialrOr) rDrrrrrrZE1E2s r5rzdpareto_lognorm_gen._rvsksa   14  0  . .D . 9  . .D . 9vva"q&j26)**r7cftjdd5tj||}}||z |z }||z|z } ||z|z} tjtj|tj|ztj||zz |z } | |j |z } | tj |j | |j | z } dddtj  |dk(tj|z<| dS#1swY;xYw)Nr8invalidr:rr) rOr;rrr/ logaddexpr0rhrU) rDrprrrrlog_ymr+x1x2rs r5rzdpareto_lognorm_gen._logpdfts [[( ; @vvay!1EaAQBQB**RVVAY2RVVAE]BUJKC 4<<? "C 2<< 2 2? ?C @(*vvgQ!Vrxx{ "#2w @ @s CD''D0c tjdd5tj||}}||z |z }||z|z } ||z|z} |j|} |j |} tj||j | z} tj||j | z}tj | | | |d\} } } }}tj| |g|| gdd\}}| | |ztj||zz g}tjtj||| |zgd}dddtj |dk(<|dS#1swY%xYw) Nr8r<rrT)rr return_sign)rrr) rOr;r_logPhir/r0rrv logsumexprrh)rDrprrrrr?r@r+rArBrrrt4onet5rPtemprs r5rzdpareto_lognorm_gen._logcdfsZ [[( ; Mvvay!1EaAQBQBaBaB&&)djjn,B&&)djjn,B"$"5"5b"b"a"H BBC b"X#t1RVWHBR"&&Q-/0D**R\\$3T 2BKLC M vvgAF 2w# M Ms D1E--E6c Rtj|j|||||SrM)rm _log1mexprrDrprrrrs r5rzdpareto_lognorm_gen._logsfs"}}T\\!Q1a899r7c Rtj|j|||||SrMrrMs r5rqzdpareto_lognorm_gen._pdf"vvdll1aAq122r7c Rtj|j|||||SrMrOrrrMs r5rtzdpareto_lognorm_gen._cdfrOr7c Rtj|j|||||SrMr;rMs r5rxzdpareto_lognorm_gen._sfs"vvdkk!Q1a011r7c|t|}}||z||z ||zzz tj||z|dz|dzzdz zz}tj|}tj|||k<|Sr)floatrOrrr) rDrarrrrr@rrs r5rzdpareto_lognorm_gen._munpsu%(11u!a%AE*+bffQUQ!Va1f_q=P5P.QQjjoffAF  r7r)rrrrrrr/rrErr.rqr)rt_Phirxr(r,r0rjrbrrrr7r5r&r&#s}0bllGllG{{H 99D 99D HHE,2E ++ (: 332r7r&dpareto_lognormcTeZdZdZdZddZdZdZdZdZ d Z d Z d Z d Z d Zy) dweibull_genavA 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@tdddtjfdgSr rgris r5rjzdweibull_gen._shape_infor r7Nc|j|}tj|||}|tj|dk\ddzSr)r weibull_minrrOrT)rDr rrrws r5rzdweibull_gen._rvssE  d + OOAD|O DBHHQ#Xq"-..r7clt|}|dz ||dz zztj||z z}|SNrr)rrOr)rDrpr rPxs r5rqzdweibull_gen._pdfs9 V WrAcE{ "RVVRUF^ 3 r7ct|}tj|tjdz tj|dz |z||zz Sr^)rrOrrvrw)rDrpr rs r5rzdweibull_gen._logpdfsC Vvvay266#;&!c'2)>>QFFr7cdtjt||z z}tj|dkDd|z |SNrrr)rOrrrT)rDrpr Cx1s r5rtzdweibull_gen._cdfs:BFFCFAI:&&xxAq3w,,r7cdtj|dk|d|z z}tjtj| d|z }tj|dkD|| SNrrr)rOrTrr)rDr|r rs r5r}zdweibull_gen._ppfsX288AHaa00hhs |S1W-xxCsd++r7cdtjjtj||z}tj |dkD|d|z Srb)rr[rxrOrrT)rDrpr half_weibull_min_sfs r5rxzdweibull_gen._sfsF!E$5$5$9$9"&&)Q$GGxxA2A8K4KLLr7cdtj|dk|d|z z}tjj ||}tj|dkD| |Sre)rOrTrr[r)rDr|r double_qweibull_min_isfs r5rzdweibull_gen._isfsSc1b1f55++001=xxC/!1?CCr7cPd|dzz tjdd|z|z zzS)NrrTrrvrrs r5rzdweibull_gen._munps+QU rxxcAgk(9:::r7cyN)rNrNrrs r5rzdweibull_gen._statsr7cptjj|tjdz }|Sr)rr[rrOr)rDr rs r5rzdweibull_gen._entropys*    & &q )BFF3K 7r7r)rrrrrjrrqrrtr}rxrrrrrr7r5rXrXsB*E/  G-, MD ;  r7rXdweibullc~eZdZdZdZddZdZdZdZdZ d Z d Z d Z d Z d ZeeeddZy) expon_genaEAn 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 cgSrMrris r5rjzexpon_gen._shape_inforr7Nc$|j|SrM)r7rs r5rzexpon_gen._rvss0066r7c.tj| SrMrOrrs r5rqzexpon_gen._pdfsvvqbzr7c| SrMrrs r5rzexpon_gen._logpdf r r7c0tj|  SrMrvrrs r5rtzexpon_gen._cdf ! }r7c0tj|  SrMrrs r5r}zexpon_gen._ppf#r|r7c.tj| SrMrwrs r5rxz expon_gen._sf&svvqbzr7c| SrMrrs r5rzexpon_gen._logsf)ryr7c.tj| SrMr1rs r5rzexpon_gen._isf,q zr7cy)N)rrr@rris r5rzexpon_gen._stats/rr7cyrrris r5rzexpon_gen._entropy2r7z 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. rct|dkDr td|jdd}|jdd}t|| | t dt j |}t j|js t d|j}||}n#|}||krtd|t j||j|z }n|}t|t|fS) NrToo many arguments.rrrrexponr)rr3r2r6rrOrrrminrJrhrrT) rDrErFr4rrdata_minr-r.s r5rBz expon_gen.fit5s t9q=12 2xx%(D)$T*   2)* *zz${{4 $$&CD D88: <CC#~"7$bffEE >IIK#%EESz5<''r7r)rrrrrjrrqrrtr}rxrrrrrJr rrBrr7r5rsrssf47" 6 &( &(r7rsrc<eZdZdZdZd dZdZdZdZdZ d Z y) exponnorm_genaAn 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@tdddtjfdgS)NKFrr rgris r5rjzexponnorm_gen._shape_infor r7NcV|j||z}|j|}||zSrM)r7r)rDrrrexpvalgvals r5rzexponnorm_gen._rvss122481<++D1}r7cLtj|j||SrMr)rDrprs r5rqzexponnorm_gen._pdfvvdll1a())r7cpd|z }|d|z|z z}|t||z ztj|z SNrrrrOr)rDrprinvKexpargs r5rzexponnorm_gen._logpdfs>Qwta( QX..::r7cd|z }|d|z|z z}|t||z z}t|tj|z SrrrrOrrDrprrrlogprods r5rtzexponnorm_gen._cdfsGQwta(<D11|bffWo--r7cd|z }|d|z|z z}|t||z z}t| tj|zSrrrs r5rxzexponnorm_gen._sfsIQwta(<D11!}rvvg..r7cZ||z}d|z}d|dzz|dzz}d|z|z|dzz}||||fS)NrrTrr@rrr)rDrK2opK2skwkrts r5rzexponnorm_gen._statssO URx!Q$h%BhmdRj($S  r7r) rrrrrjrrqrrtrxrrr7r5rrhs,(RE *; . / !r7r exponnormcTtjtj||S)a' Compute (1 + x)**y - 1. Uses expm1 and xlog1py to avoid loss of precision when (1 + x)**y is close to 1. Note that the inverse of this function with respect to x is ``_pow1pm1(x, 1/y)``. That is, if t = _pow1pm1(x, y) then x = _pow1pm1(t, 1/y) )rOrrvrvrpys r5_pow1pm1rs 88BJJq!$ %%r7c:eZdZdZdZdZdZdZdZdZ dZ y ) exponweib_genaAn 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 ctdddtjfd}tdddtjfd}||gSNrFrr r rgrDrhr's r5rjzexponweib_gen._shape_inforjr7cNtj|j|||SrMrrDrprr s r5rqzexponweib_gen._pdf vvdll1a+,,r7c||z }tj| }tj|tj|ztj|dz |z|ztj|dz |z}|Sr)rvrrOrrw)rDrprr negxcexm1clogps r5rzexponweib_gen._logpdfsoA% q BFF1I%S%(@@S!,- r7c@tj||z  }||zSrMr{)rDrprr rs r5rtzexponweib_gen._cdf s!1a4% axr7cntj|d|z z  tjd|z zSr)rvrrOr)rDr|rr s r5r}zexponweib_gen._ppf s01s1u:+&&CE):::r7cLttj||z  | SrM)rrOrrs r5rxzexponweib_gen._sf s""&&!Q$-+++r7cXtjt| d|z   d|z zSr])rOrr)rDrrr s r5rzexponweib_gen._isf s-1"ac**++qs33r7N rrrrrjrqrrtr}rxrrr7r5rrs+'P - ;,4r7r exponweibc:eZdZdZdZdZdZdZdZdZ dZ y ) exponpow_genaAn 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@tdddtjfdgSNrFrr rgris r5rjzexponpow_gen._shape_info3 r r7cLtj|j||SrMrrDrprs r5rqzexponpow_gen._pdf6 vvdll1a())r7c||z}dtj|ztj|dz |z|ztj|z }|SNrr)rOrrvrwr)rDrprxbfs r5rzexponpow_gen._logpdf: sG T q MBHHQWa0 02 5r Br7c\tjtj||z  SrMr{rs r5rtzexponpow_gen._cdf? s""((1a4.)))r7cZtjtj||z SrMrOrrvrrs r5rxzexponpow_gen._sfB svvrxx1~o&&r7c`tjtj| d|z zSrrvrrOrrs r5rzexponpow_gen._isfE s$"&&)$1--r7cpttjtj|  d|z SrpowrvrrDr|rs r5r}zexponpow_gen._ppfH s(288RXXqb\M*CE22r7N) rrrrrjrqrrtrxrr}rr7r5rr s+6E* *'.3r7rexponpowc`eZdZdZej ZdZd dZdZ dZ dZ dZ d Z d Zd Zy) fatiguelife_gena0A 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@tdddtjfdgSr rgris r5rjzfatiguelife_gen._shape_infol r r7Nc|j|}d|z|z}||z}dd|zzd|ztjd|zzz}|S)NrrrTr)rrOr)rDr rrr+rprBts r5rzfatiguelife_gen._rvso sT  ( ( . E!G qS !B$J1RWWQV_, ,r7cLtj|j||SrMrrs r5rqzfatiguelife_gen._pdfv svvdll1a())r7ctj|dz|dz dzd|z|dzzz z tjd|zz dtjdtjzdtj|zzzz S)NrrTrrrrrs r5rzfatiguelife_gen._logpdf{ ssqs qsQh#a%1*55qs CRVVAbeeG_q{234 5r7c|td|z tj|dtj|z z zSr)rrOrrs r5rtzfatiguelife_gen._cdf s/qBGGAJRWWQZ$?@AAr7cf|t|z}d|tj|dzdzzdzzSN?rTr#rrOrrDr|r tmps r5r}zfatiguelife_gen._ppf s6)A,sRWWS!VaZ001444r7c|td|z tj|dtj|z z zSr)rrOrrs r5rxzfatiguelife_gen._sf s/a2771:BGGAJ#>?@@r7ch| t|z}d|tj|dzdzzdzzSrrrs r5rzfatiguelife_gen._isf s8b9Q<sRWWS!VaZ001444r7c||z}|dz dz}d|zdz}||zdz }d|zd|zdzztj|dz }d |zd |zd zz|dzz }||||fS) Nrrr rOr# rrr]gD@rOr)rDr c2rBdenrCrDrEs r5rzfatiguelife_gen._stats s qS #X^Bhnfsl Ubeck "RXXc3%7 7 Vr"ut| $sCx /3Br7r)rrrrrrrrjrrqrrtr}rxrrrr7r5rrO sD4"44ME* 5B5A5 r7r fatiguelifec<eZdZdZdZdZd dZdZdZdZ d Z y) foldcauchy_genaoA 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 |dk\Sr3rrs r5rbzfoldcauchy_gen._argcheck Av r7c@tdddtjfdgSNr Frrfrgris r5rjzfoldcauchy_gen._shape_info 3266{MBCCr7NcDttj|||S)Nr-rr)rrrrDr rrs r5rzfoldcauchy_gen._rvs s&6::!$+79: :r7cddtjz dd||z dzzz dd||zdzzz zzSNrrrTr.rs r5rqzfoldcauchy_gen._pdf s<255y#q!A#z*S!QqS1H*-==>>r7cdtjz tj||z tj||zzzSrrOrarctanrs r5rtzfoldcauchy_gen._cdf s2255y"))AaC.299QqS>9::r7ctjd||z tjd||zztjz Sr]rrs r5rxzfoldcauchy_gen._sf s6  1a!e$rzz!QU';;RUUBBr7c~tjtjtjtjfSrMrrs r5rzfoldcauchy_gen._stats rr7r rrrrrbrjrrqrtrxrrr7r5rr s,&D:?;C.r7r foldcauchycHeZdZdZdZd dZdZdZdZdZ d Z d Z d Z y) f_genaAn 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 ctdddtjfd}tdddtjfd}||gS)NdfnFrr dfdrg)rDidfnidfds r5rjzf_gen._shape_info s<%BFF ^D%BFF ^Dd|r7Nc(|j|||SrM)r)rDrrrrs r5rz f_gen._rvs s~~c3--r7cNtj|j|||SrMrrDrprrs r5rqz f_gen._pdf s vvdll1c3/00r7cFd|z}d|z}|dz tj|z|dz tj|zztj|dz dz |z||zdz tj|||zzztj|dz |dz zz }|SNrrTr)rOrrvrwrx)rDrprrrar@rys r5rz f_gen._logpdf s #I #IsRVVAY1rvvay0288AaC!GQ3GGaC7bffQ1Wo- !A#qs0CCE r7c0tj|||SrM)rvfdtrrs r5rtz f_gen._cdf swwsC##r7c0tj|||SrM)rvfdtrcrs r5rxz f_gen._sf xxS!$$r7c0tj|||SrM)rvfdtri)rDr|rrs r5r}z f_gen._ppf r r7cd|zd|z}}|dz |dz |dz |dz f\}}}}tj|dkD||fdtj} tj|d kD||||fd tj} tj|d kD||||fd tj} | tj dz} tj|d kD| ||fdtj} | dz} | | | | fS)NrrrOr @rTc ||z SrMr)v2v2_2s r5rzf_gen._stats.. s R$Yr7rr#c6d|z|z||zz||dzz|zz Srr)v1rrv2_4s r5rzf_gen._stats.. s- FRK29 %dAg)< =r7rcVd|z|z|z tj||||zzz zSrr)rrrv2_6s r5rzf_gen._stats..& s3 Vd]d "RWWTR295E-F%G Gr7r-cd||z|zz|z S)Nr-r)rDrv2_8s r5rzf_gen._stats..- sAR$$6$#>r7r)rrrOrhrr) rDrrrrrrrrrBrCrDrEs r5rz f_gen._stats sc28B!#b"r'27BG!CdD$ __ FRJ &vv oo FRT4( >vv  __ FRtT* Hvv  bggbk __ FRt$ >vv g 3Br7cLd|z}d|z}d||zz}tj|tj|z tj||zd|z tj|zzd|ztj|zz |tj|zzSr)rOrrvrxrZ)rDrrhalf_dfnhalf_dfdhalf_sums r5rzf_gen._entropy3 s99#)$s bffSk)BIIh,IIX!11256\x 5!!#+bffX.>#>? @r7r) rrrrrjrrqrrtrxr}rrrr7r5rr s6#H .1 $%%< @r7rrc<eZdZdZdZdZd dZdZdZdZ d Z y) foldnorm_genazA 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 |dk\Sr3rrs r5rbzfoldnorm_gen._argchecka rr7c@tdddtjfdgSrrgris r5rjzfoldnorm_gen._shape_infod rr7Nc<t|j||zSrMrrrs r5rzfoldnorm_gen._rvsg s<//59::r7c<t||zt||z zSrMrrs r5rqzfoldnorm_gen._pdfj sQ)AaC.00r7ctjd}dtj||z |z tj||z|z zzSr)rOrrverf)rDrpr sqrt_twos r5rtzfoldnorm_gen._cdfn sC771:bffa!eX-.Q8H1IIJJr7c<t||z t||zzSrMrrs r5rxzfoldnorm_gen._sfr sA!a%00r7c||z}tjd|ztjdtjzz }d|z|t j |tjdz zz}|dz||zz }d||z|z||zz |z z}|tj |dz}||dzzdzd|z|zz}|d|d z zd |dzzz |dzzz }||dzz d z }||||fS) NrrTrrrrr rI)rOrrrrvr$r)rDr rexpfacrBrCrDrEs r5rzfoldnorm_gen._statsu s qSR2772bee8#44 YRVVAbggajL11 11fr"un 2b58be#f, - bhhsC   27^a "V)B, . rR"W~RU *b!e33 #s(]R 3Br7rrrr7r5rrK s,*D;1K1r7rfoldnormcxeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z eed fdZxZS)weibull_min_genaWeibull 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@tdddtjfdgSr rgris r5rjzweibull_min_gen._shape_info r r7ch|t||dz ztjt|| zSr]rrOrrs r5rqzweibull_min_gen._pdf s,Q!}RVVSAYJ///r7cztj|tj|dz |zt ||z Sr]rOrrvrwrrs r5rzweibull_min_gen._logpdf s/vvay288AE1--Aq 99r7cDtjt||  SrMrvrrrs r5rtzweibull_min_gen._cdf s#a)$$$r7cJttj|  d|z Srrrs r5r}zweibull_min_gen._ppf sBHHaRL=#a%((r7cLtj|j||SrMr;rs r5rxzweibull_min_gen._sf vvdkk!Q'((r7ct|| SrMrrs r5rzweibull_min_gen._logsf sAq zr7c:tj| d|z zSr]r1rs r5rzweibull_min_gen._isf s ac""r7c>tjd|dz|z zSrrlrs r5rzweibull_min_gen._munp sxxAcE!G $$r7cVt |z tj|z tzdzSr]r#rOrrs r5rzweibull_min_gen._entropy %w{RVVAY&/!33r7a 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. rc 4t|tr7|jdk(r|j}nt ||g|i|S|j ddrt ||g|i|St||||\}}}}|jddj}dtj|d}|} | kr|dk7r||st ||g|i|S|dk(rd \} } } n6t|r|dnd} |j d d} |j d d} |!| tfd d |gdj} n||} |h| ftj |} tj"| t%j&dd| z zt%j&dd| z zdzz z } n||} |9| 7tj(|}|| t%j&dd| z zzz } n||} |dk(r| | | fSt ||| f| | d|S)NrsuperfitFr0r:ctjdd|z z}tjdd|z z}tjdd|z z}d|dzzd|z|zz |z}||dzz dz}||z S)NrrTrrrl)r gamma1gamma2gamma3numrs r5skewz!weibull_min_gen.fit..skew s|XXa!e_FXXa!e_FXXa!e_Ffai-!F(6/1F:CFAI%-Cs7Nr7g@r;NNNr-r.c|z SrMr)r rrEs r5rz%weibull_min_gen.fit.. sd1gkr7g{Gz?bisect)bracketr0rrTr-r.)r>r)r?rr@rBr2_check_fit_input_parametersr<r=rrErr*rootrOrrrvrr)rDrErFr4fcrrr0max_cs_minr r-r.rr@rrErs @@r5rBzweibull_min_gen.fit s< dL )  "a'~~'w{47$7$77 88J &7;t3d3d3 3"=T4=A4"Ib$(E*002  JJt U  u94BJt7;t3d3d3 3 T>,MAsEt9Q$A((5$'CHHWd+E :!)1D%=#+--1T  ^A >emt AGGA!AaC%288AacE?A3E!EFGE  E c5= 7;tQECuEE Er7)rrrrrjrqrrtr}rxrrrrr rrBrrs@r5r,r, s`+XE0:%))#%4}5JFJFr7r,r[cjeZdZdZdZdZfdZdZdZdZ dZ d Z d Z d Z d Zd ZdZxZS)truncweibull_min_gena9A 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$|dk\||kDz|dkDzSNrrrDr rrs r5rbztruncweibull_min_gen._argcheck] sRAE"a"f--r7ctdddtjfd}tdddtjfd}tdddtjfd}|||gS)Nr Frr rrfrrg)rDr'rhris r5rjz truncweibull_min_gen._shape_info` sV UQK @ UQK ? UQK @B|r7c&t||dS)N)rrrrLr@rrDrErs r5rztruncweibull_min_gen._fitstartf sw I 66r7c ||fSrMrrTs r5rz!truncweibull_min_gen._get_supportj !t r7ctjt|| tjt|| z }|t||dz ztjt|| z|z Sr]rOrr)rDrpr rrdenums r5rqztruncweibull_min_gen._pdfm s]Q #bffc!QiZ&88C1Q3K"&&#a)"44==r7c (tjtjt|| tjt|| z }tj|t j |dz |zt||z |z Sr])rOrrrrvrw)rDrpr rrlogdenums r5rztruncweibull_min_gen._logpdfq si66"&&#a),rvvs1ayj/AABvvay288AE1--Aq 9HDDr7ctjt|| tjt|| z }tjt|| tjt|| z }||z SrMr\rDrpr rrrDr]s r5rtztruncweibull_min_gen._cdfu dvvs1ayj!BFFC1I:$66Q #bffc!QiZ&88U{r7c \tjtjt|| tjt|| z }tjtjt|| tjt|| z }||z SrMrOrrrrDrpr rrlognumr_s r5rztruncweibull_min_gen._logcdfz wAq z*RVVSAYJ-??@66"&&#a),rvvs1ayj/AAB  r7ctjt|| tjt|| z }tjt|| tjt|| z }||z SrMr\ras r5rxztruncweibull_min_gen._sf rbr7c \tjtjt|| tjt|| z }tjtjt|| tjt|| z }||z SrMrdres r5rztruncweibull_min_gen._logsf rgr7c ttjd|z tjt|| z|tjt|| zz d|z Sr]rrOrrrDr|r rrs r5rztruncweibull_min_gen._isf Y VVQUbffc!QiZ001rvvs1ayj7I3II J JAaC r7c ttjd|z tjt|| z|tjt|| zz d|z Sr]rkrls r5r}ztruncweibull_min_gen._ppf rmr7c `tj||z dztj||z dzt||tj||z dzt||z z}t j t|| t j t|| z }||z Sr)rvrrrrOr)rDrar rr gamma_funr]s r5rztruncweibull_min_gen._munp sHHQqS2X& KK!b#a) ,r{{1Q38SAY/O O Q #bffc!QiZ&885  r7)rrrrrbrjrrrqrrtrrxrrr}rrrs@r5rQrQ0 sK+X. 7>E !  !   !r7rQtruncweibull_minrcFeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) weibull_max_gena0Weibull 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@tdddtjfdgSr rgris r5rjzweibull_max_gen._shape_info r r7cl|t| |dz ztjt| | zSr]r/rs r5rqzweibull_max_gen._pdf s0aR1~bffc1"aj[111r7c~tj|tj|dz | zt | |z Sr]r1rs r5rzweibull_max_gen._logpdf s3vvay288AaC!,,sA2qz99r7cDtjt| | SrMr\rs r5rtzweibull_max_gen._cdf svvsA2qzk""r7ct| | SrMr8rs r5rzweibull_max_gen._logcdf sQB {r7cFtjt| |  SrMr3rs r5rxzweibull_max_gen._sf s#qb!*%%%r7cJttj| d|z  Sr)rrOrrs r5r}zweibull_max_gen._ppf s RVVAYJA&&&r7cvtjd|dz|z z}t|dzrd}||zSd}||zS)NrrTrr)rvrr)rDrar valsgns r5rzweibull_max_gen._munp sIhhs1S57{# q6A:CSyCSyr7cVt |z tj|z tzdzSr]r<rs r5rzweibull_max_gen._entropy r=r7N) rrrrrjrqrrtrrxr}rrrr7r5rsrs s6#HE2:#&'4r7rs weibull_max)rrcLeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z y ) genlogistic_genaA 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@tdddtjfdgSr rgris r5rjzgenlogistic_gen._shape_info r r7cLtj|j||SrMrrs r5rqzgenlogistic_gen._pdf rr7c|dz |dkzdz }tj|}tj|||zz|dztjtj | zz SNrr)rOrrrvrr)rDrpr multrs r5rzgenlogistic_gen._logpdf sbQx1q5!A%vvayvvay49$!rxxu /F'FFFr7c@dtj| z| z}|Sr]rw)rDrpr Cxs r5rtzgenlogistic_gen._cdf s!r lqb ! r7c\| tjtj| zSrM)rOrrrs r5rzgenlogistic_gen._logcdf s"rBHHRVVQBZ(((r7c\tjtj|d|z  SrD)rOrrvpowm1rs r5r}zgenlogistic_gen._ppf s#rxx46*+++r7cNtj|j|| SrMrvrrrs r5rxzgenlogistic_gen._sf# a+,,,r7c,|jd|z |Sr]r}rs r5rzgenlogistic_gen._isf& syyQ""r7cttj|z}tjtjzdz tj d|z}dtj d|zdt zz}|tj|dz}tjdzdz dtj d|zz}||d zz}||||fS) NrrTrrrr#.@rr)r#rvrZrOrzetar$rrDr rBrCrDrEs r5rzgenlogistic_gen._stats) s bffQi eeBEEk#o1 - 1 & ( bhhsC   UUAXd]Qrwwq!}_ , c3h3Br7c<tj|dk|ddS)Ng^Acttj| tj|dzztzdzSr])rOrrvrZr#rs r5rz*genlogistic_gen._entropy..5 s+rvvayj266!a%=069A=r7c&dd|zz tzdzSr0r#rs r5rz*genlogistic_gen._entropy..; sa1q5kF*Q.r7rrs r5rzgenlogistic_gen._entropy2 s$ GQ = /0 0r7N)rrrrrjrqrrtrr}rxrrrrr7r5rr s<@E*G),-# 0r7r genlogisticc`eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z dd Zd ZdZy) genpareto_genaA 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,tj|SrMrOrrs r5rbzgenpareto_gen._argchecke {{1~r7c^tddtj tjfdgSNr Fr rgris r5rjzgenpareto_gen._shape_infoh %3'8.IJJr7ctj|}tj|j|dj }t j |dk|dtj}||fS)Nrc d|z SrDrrs r5rz,genpareto_gen._get_support..n s ar7r)rOrrrcopyrrrhrTs r5rzgenpareto_gen._get_supportk s\ JJqM    *1 - 2 2 4 OOAE1&7')vv /!t r7cLtj|j||SrMrrs r5rqzgenpareto_gen._pdfr rr7cNtj||k(|dk7z||fd| S)NrcBtj|dz||z |z Srrjrpr s r5rz'genpareto_gen._logpdf..x s!RZZB!-D,Dq,Hr7rrrs r5rzgenpareto_gen._logpdfv s0Q162QFH+,". .r7c4tj| |  SrM)rv inv_boxcox1prs r5rtzgenpareto_gen._cdf{ sQB'''r7c2tj| | SrM)rv inv_boxcoxrs r5rxzgenpareto_gen._sf~ s}}aR!$$r7cNtj||k(|dk7z||fd| S)Nrc:tj||z |z SrMrrs r5rz&genpareto_gen._logsf.. sRXXac]NQ,>r7rrrs r5rzgenpareto_gen._logsf s0Q162QF>+,". .r7c4tj| |  SrM)rvboxcox1prs r5r}zgenpareto_gen._ppf s QB###r7c2tj||  SrM)rvboxcoxrs r5rzgenpareto_gen._isf s !aR   r7cd\}}}}d|vr+tj|dk|dtj}d|vr+tj|dk|dtj}d |vr+tj|d k|d tj}d |vr+tj|d k|dtj}||||fS)NNNNNr@rcdd|z z Sr]rxis r5rz&genpareto_gen._stats.. s1B<r7rrrc*dd|z dzz dd|zz z Sr0rrs r5rz&genpareto_gen._stats.. s1B{?a!b&j+Ir7rgUUUUUU?c\dd|zztjdd|zz zdd|zz z S)NrTrrrrs r5rz&genpareto_gen._stats.. s11B<"''!ad(*;;q1R4xHr7rrc`ddd|zz zd|dzz|zdzzdd|zz z dd|zz z dz S)NrrrTr#rrs r5rz&genpareto_gen._stats.. sP1AbD>Qr1uWr\A-=>!B$h(+,qt85789r7rrrOrhr)rDr rr@rrrs r5rzgenpareto_gen._stats s+ 1a '>Aq 7+-663A '>C I+-663A '>CH66#A '>C966 #A !Qzr7c rfd}tj|dk7||tjdzS)Ncd}tjddz}t|tj|D]\}}||d|zzd||zz z z}tj |zdk|d|z zztj S)NrrrrrrA)rOrRziprvcombrTrh)r r|rkicnkras r5r[z#genpareto_gen._munp..__munp sC !QU#Aq"''!Q-0 >CC2"*,a"f == >88AEAIsdQh1_' 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 ctdddtjfd}tdddtjfd}tdddtjfd}|||gS)NrFrr rr rg)rDrhrir's r5rjzgenexpon_gen._shape_info sV UQK @ UQK @ UQK @B|r7c ||tj| |z zztj| |z |z|tj| |z z|z zzSrMrvrrOrrDrprrr s r5rqzgenexpon_gen._pdf shA!A''!Aq01BHHaRTN?0CA0E1F*GG Gr7ctj||tj| |z zz| |z |zz|tj| |z z|z zSrMrOrrvrrs r5rzgenexpon_gen._logpdf sYvvaBHHaRTN?++,1ax7BHHaRTN?8KA8MMMr7c~tj| |z |z|tj| |z z|z z SrMr{rs r5rtzgenexpon_gen._cdf s=1"Q$A!A$7$99:::r7c||z}||tj| zz |z }|tj| |z tj| zj z|z SrM)rOrrvlambertwrrealrDrrrr rrs r5r}zgenexpon_gen._ppf s\ E 288QB<  "BKK1rvvqbz 12777::r7c|tj| |z |z|tj| |z z|z zSrMrrs r5rxzgenexpon_gen._sf s:vvr!tQhRXXqbd^O!4Q!6677r7c||z}||tj|zz |z }|tj| |z tj| zj z|z SrM)rOrrvrrrrs r5rzgenexpon_gen._isf sY E 266!9_a BKK1rvvqbz 12777::r7Nrrr7r5rr s,> G N;; 8;r7rgenexponcveZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZfdZdZdZxZS)genextreme_genaBA 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,tj|SrMrrs r5rbzgenextreme_gen._argcheck# rr7c^tddtj tjfdgSrrgris r5rjzgenextreme_gen._shape_info& rr7ctj|dkDdtj|tz tj}tj|dkdtj |t z tj }||fSNrr)rOrTmaximumr!rhminimum)rDr _b_as r5rzgenextreme_gen._get_support) sc XXa!eS2::a#77 @ XXa!eS2::a%#88266' B2v r7cNtj||k(|dk7z||fd| S)Nrc:tj| |z|z SrMrrs r5rz+genextreme_gen._loglogcdf..2 s1"Q$)r7rrrs r5 _loglogcdfzgenextreme_gen._loglogcdf. s1 !VQ !Q )r r7cLtj|j||SrMrrs r5rqzgenextreme_gen._pdf5 svvdll1a())r7c tj||k(|dk7z||ftjd}t j | }|j ||}tj|}tj||dk(|tj k(zdtj|dk(|tj k(z|||fdtj }tj||dk(|dk(zd|S)Nrrrrc| |z|z SrMr)pex2lpex2lex2s r5rz(genextreme_gen._logpdf..G steemd&:r7) rroperatormulrvrrrOrputmaskrh)rDrpr cxlogex2logpex2rlogpdfs r5rzgenextreme_gen._logpdf; s __a1fa01a&%\\c;2#//!Q'vvg 7Q!VbffW 5s;Qw2"&&=) * 7F # :w   6AFqAv.4 r7cNtj|j|| SrM)rOrrrs r5rzgenextreme_gen._logcdfL stq!,---r7cLtj|j||SrMrQrs r5rtzgenextreme_gen._cdfO rr7cNtj|j|| SrMrrs r5rxzgenextreme_gen._sfR rr7ctjtj|  }tj||k(|dk7z||fd|S)Nrc<tj| |z |z SrMr{rs r5rz%genextreme_gen._ppf..Y "((A26**Q.r7r)rOrrrrDr|r rps r5r}zgenextreme_gen._ppfU sJ VVRVVAYJ   !VQ !Q . r7ctjtj|   }t j ||k(|dk7z||fd|S)Nrc<tj| |z |z SrMr{rs r5rz%genextreme_gen._isf..` rr7r)rOrrvrrrrs r5rzgenextreme_gen._isf\ sL VVRXXqb\M " " !VQ !Q . r7cfd}|d}|d}|d}|d}tjtdktjzdzdz ||dzz }d }t j tdk\|tjdzdz } d } d } t j t| k\| t } tjd ktj| } tjdktj|dz| z}d}dtjdztztjdzz }||||f}t j t| dzkDg||| }d}|||||f}t j t| dzkDg||d }| |||fS)Nc:tj|zdzSr]rl)rar s r5gz genextreme_gen._stats..gd s88AEAI& &r7rrTrr#gHz>rrctjtjd|zdzdtj|dzzz |dzz S)NrrrTrvrrrs r5gam2k_fz&genextreme_gen._stats..gam2k_fk sB88BJJs1uSy1!BJJq3w4G2GGHCO Or7r+=c^tjtj|dz|z Sr]rrs r5gamk_fz%genextreme_gen._stats..gamk_fo s#88BJJq1u-.q0 0r7rAr(cdd}tj|dk\|g||tjS)NcXtj|| |d|zz|zzz|dzz SNrTrrN)r rDrEg3g2mg12s r5 sk1_eval_fz;genextreme_gen._stats..sk1_eval..sk1_eval_f{ s2wwqzB3"qx-);#;.sk1_evalz s2 I??1:zDz#-"&&B Br7rrg(\?c\d}tj|dk\||tjS)NcB|d|zd||zz|zz|zz|dzz dz S)NrrrTr)rDrErg4rs r5 ku1_eval_fz;genextreme_gen._stats..ku1_eval..ku1_eval_f s6beafob&88"<.ku1_eval s% L??1:tZBFFS Sr7gq= ףp?333333@) rOrTrrrrr#rrr$)rDr rrDrErr rrgam2kepsrgamkr@rrsk_fillrFrr rs ` r5rzgenextreme_gen._statsc s ' qT qT qT qT#a&4-!BEE'C);RCZH PA$7ruuczRU~V 1s1v}aVGL HHQXrvvu - HHQXrvvr3wu} 5 B RWWQZ-&ruuax/BF# __SVc4i/!d%'; T BB' __SVc4i/!d%(<!R|r7ct|tr|j}t|}|dkrd}nd}t|||fS)Nrrr(rLr>r)rrr@r)rDrErrrs r5rzgenextreme_gen._fitstart sJ dL )>>#D $K q5AAw QD 11r7c6tjd|dz}d||zz tjtj||d|zztj ||zdzzdz}tj ||zdkD|tjS)Nrrrrr)rOrRrrvrrrTrh)rDrar rvalss r5rzgenextreme_gen._munp s IIa1 1a4x"&& GGAqMR!G #bhhqsQw&7 7xx!b$//r7c td|z zdzSr]rrs r5rzgenextreme_gen._entropy sq1u~!!r7)rrrrrbrjrrrqrrrtrxr}rrrrrrrs@r5rr sV%LK * ".*-,\ 20"r7r genextremecJd}fd}dkDr7tjdz}dkrDtj||d}|SdkDrtjd z d z}n d |z z }tj||d d \}}}}|dk7rt d|dS)afInverse 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 gox?c4tj|z SrM)rvrrs r5r]z_digammainv..func szz!}q  r7grr绽|=)tolrg-@g뭁,?rdy=T)xtolrrz _digammainv: fsolve failed, y = r)rOrr newtonr RuntimeError)r_emr]x0valuerrrVs` r5 _digammainvr$ s$ &C! 6z VVAY_ r6OOD"%8EL R VVAeG_w & QBH %__T2E9=?E4d ax=aUCDD 8Or7ceZdZdZdZddZdZdZdZdZ dZ d Z d Z d Z d Zfd ZeedfdZxZS) gamma_genaA 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@tdddtjfdgSrrgris r5rjzgamma_gen._shape_infor r7c&|j||SrMstandard_gamma)rDrrrs r5rzgamma_gen._rvss**1d33r7cLtj|j||SrMrr s r5rqzgamma_gen._pdf rr7cftj|dz ||z tj|z Sr)rvrwrr s r5rzgamma_gen._logpdfs)xx#q!A% 1 55r7c.tj||SrMrr s r5rtzgamma_gen._cdfrr7c.tj||SrMrr s r5rxz gamma_gen._sfs||Aq!!r7c.tj||SrMrrs r5r}zgamma_gen._ppfs~~a##r7c.tj||SrMrvrrs r5rzgamma_gen._isfsq!$$r7c@||dtj|z d|z fS)Nrrrrs r5rzgamma_gen._statss!!S^SU**r7c.tj||SrMrvrrDrars r5rzgamma_gen._munp!swwq!}r7cDd}d}tj|dk|||S)Ncjtj|d|z z|ztj|zSr]rvrZrrs r5rz+gamma_gen._entropy..regular_formula&s+66!9!$q(2::a=8 8r7cddtjdtjzztj|zzdd|zz z |dzdz z |dzd z z |d zd z zS) NrrrTrrrrrr rrrr9s r5rz.gamma_gen._entropy..asymptotic_formula)sq 2qw/"&&);rTrLr)rDrErrrs r5rzgamma_gen._fitstart3sM dL )>>#D 4[ A w QD 11r7a< 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. rc|jdd}|jdd}t|ts|&|jdk7rt ||g|i|S|j ddt|gd}|j dd}t||| | tdtj|}tj|js td|jdk(rtj|}tj|} tj||z d z} |||} } } | | | | d | zz } | | tj | | z } | | | || z z } | | | | d zz } | || z | z } | || | zz } | || z | z } | | | fStj"||krt%d |tj& |d k7r||z }|j}|||} ntj(|tj(|jz d z tj d z d zdzzzdzz }|dz}|dz}t+j,fd||d } || z } nFtj(|jtj(|z }t/|} |} | || fS)Nrr0r:r;rrrrrrTrrrrrg333333?gffffff?c`tj|tj|z z SrM)rOrrvr)rrs r5rzgamma_gen.fit..s!bffQi"**Q-.G!.Kr7)disp)r<r>r)r=r@rBr2rr6rrOrrrrrrrrJrhrr brentqr$)rDrErFr4rr0rrm1m2m3rr-r.raestxarr rrs @r5rBz gamma_gen.fit?sxx%(E* t\ * 4!77;t3d3d3 3  !$(= >(D)$T* >d.63E)* *zz${{4 $$&CD D <<>T !BB$))*BfEsAyS[U]a"f {u}QyU]b3hyS[%1*%y#X&{1u9n}cQc5= 66$$, wd"&&A A 19$;Dyy{ >~ FF4L266$<#4#4#66!bggqsQhAo662a4@5\5\OO$K$&4 1HE t !!#bffVn4AAAE$~r7r)rrrrrjrrqrrtrxr}rrrrrr rrBrrs@r5r&r& si'PE4*6!"$%+ P 2}5eer7r&rcReZdZdZdZdZfdZeedfdZ xZ S) erlang_genaAn 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. ctjtj||k(}|s"d|d}tj|t d|dkDS)NzRThe shape parameter of the erlang distribution has been given a non-integer value r1r stacklevelr)rOrrwarningswarnRuntimeWarning)rDrallintmessages r5rbzerlang_gen._argchecksM q()==>EDG MM'>a @1u r7c@tdddtjfdgS)NrTrrfrgris r5rjzerlang_gen._shape_inforkr7ct|tr|j}tddt |dzzz }t t |||fS)NrOr=rTrL)r>r)rrrr@r&r)rDrErrs r5rzerlang_gen._fitstartsP dL )>>#D teDk1n,- .Y/A4/@@r7a 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=`, the fit method can be constrained to fit the data to a specific integer shape parameter.rc*t||g|i|SrM)r@rBrDrErFr4rs r5rBzerlang_gen.fitsw{4/$/$//r7) rrrrrbrjrr rrBrrs@r5rHrHs9&CA}5/0000r7rHerlangcTeZdZdZdZdZdZdZdZddZ d Z d Z d Z d Z d Zy) gengamma_genaA 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|dkD|dk7zSr3r)rDrr s r5rbzgengamma_gen._argcheck A!q&!!r7ctdddtjfd}tddtj tjfd}||gSrrgrs r5rjzgengamma_gen._shape_infoB UQK @ UbffWbff$5~ FBxr7cNtj|j|||SrMrrs r5rqzgengamma_gen._pdfvvdll1a+,,r7cptj|dk7|dkDz||ffdtj S)Nrctjt|tj|zdz |z||zz tj z Sr])rOrrrvrwr)rpr rs r5rz&gengamma_gen._logpdf..sB"&&Q.288AaC!GQ+??!Q$FTUVr7rrrs ` r5rzgengamma_gen._logpdfs6 !VA A Ww  r7c||z}tj||}tj||}tj|dkD||Sr3rvrrrOrTrDrprr xcval1val2s r5rtzgengamma_gen._cdfB T{{1b!||Ar"xxAtT**r7Nc8|j||}|d|z zS)Nrrr))rDrr rrrs r5rzgengamma_gen._rvs"s%  ' ' ' 52a4yr7c||z}tj||}tj||}tj|dkD||Sr3rarbs r5rxzgengamma_gen._sf&rfr7ctj||}tj||}tj|dkD||d|z zSrrvrrrOrTrDr|rr rdres r5r}zgengamma_gen._ppf,B~~a#q!$xxAtT*SU33r7ctj||}tj||}tj|dkD||d|z zSrrjrks r5rzgengamma_gen._isf1rlr7c:tj||dz|z Srr4)rDrarr s r5rzgengamma_gen._munp6swwq!C%'""r7cHd}d}tj|dk\||f||S)Nctj|}|d|z z||z z}tj|tjt |z }||z}|Sr])rvrZrrOrr)rr r|ABrs r5rz&gengamma_gen._entropy..regular;sQ&&)CQW a'A 1 s1v.AAAHr7c:tjtj|dz z tjtj|z |dzdz z|dzdz z tj||dzdz z |dzdz z |dzd z z|z zS) NrTrArrr rrrr)rrrOrr)rr s r5 asymptoticz)gengamma_gen._entropy..asymptoticBsMMObffQik1ffRVVAY'(+,c61*5893{CvvayAsFA:-C ;q#vslJAMN Or7r)rDrr rrts r5rzgengamma_gen._entropy:s,  O qCx!QWEEr7r)rrrrrbrjrqrrtrrxr}rrrrr7r5rWrWs?>" - + + 4 4 #Fr7rWgengammac4eZdZdZdZdZdZdZdZdZ y) genhalflogistic_genaA 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@tdddtjfdgSr rgris r5rjzgenhalflogistic_gen._shape_infodr r7c$|jd|z fSrr9rs r5rz genhalflogistic_gen._get_supportgsvvs1u}r7cxd|z }tjd||zz }||dz z}||z}d|zd|zdzz SrrOr)rDrpr limitrtmp0tmp2s r5rqzgenhalflogistic_gen._pdfjsPAjj1Q3U1W~Cxv4! ##r7cbd|z }tjd||zz }||z}d|z d|zz Sr.r|)rDrpr r}rrs r5rtzgenhalflogistic_gen._cdfss=Ajj1Q3U|DQtV$$r7c0d|z dd|z d|zz |zz zSr.rrs r5r}zgenhalflogistic_gen._ppfys'1ua#a%#a%1,,--r7cDdd|zdztjdzz Srr1rs r5rzgenhalflogistic_gen._entropy|s"AaCE266!9$$$r7N) rrrrrjrrqrtr}rrr7r5rxrxNs&*E$% .%r7rxgenhalflogisticcpeZdZdZdZdZfdZdZdZde dZ d Z d Z d d Z d ZxZS)genhyperbolic_genu A generalized hyperbolic continuous random variable. %(before_notes)s See Also -------- t, norminvgauss, geninvgauss, laplace, cauchy Notes ----- The probability density function for `genhyperbolic` is: .. math:: f(x, p, a, b) = \frac{(a^2 - b^2)^{p/2}} {\sqrt{2\pi}a^{p-1/2} K_p\Big(\sqrt{a^2 - b^2}\Big)} e^{bx} \times \frac{K_{p - 1/2} (a \sqrt{1 + x^2})} {(\sqrt{1 + x^2})^{1/2 - p}} for :math:`x, p \in ( - \infty; \infty)`, :math:`|b| < a` if :math:`p \ge 0`, :math:`|b| \le a` if :math:`p < 0`. :math:`K_{p}(.)` denotes the modified Bessel function of the second kind and order :math:`p` (`scipy.special.kv`) `genhyperbolic` takes ``p`` as a tail parameter, ``a`` as a shape parameter, ``b`` as a skewness parameter. %(after_notes)s The original parameterization of the Generalized Hyperbolic Distribution is found in [1]_ as follows .. math:: f(x, \lambda, \alpha, \beta, \delta, \mu) = \frac{(\gamma/\delta)^\lambda}{\sqrt{2\pi}K_\lambda(\delta \gamma)} e^{\beta (x - \mu)} \times \frac{K_{\lambda - 1/2} (\alpha \sqrt{\delta^2 + (x - \mu)^2})} {(\sqrt{\delta^2 + (x - \mu)^2} / \alpha)^{1/2 - \lambda}} for :math:`x \in ( - \infty; \infty)`, :math:`\gamma := \sqrt{\alpha^2 - \beta^2}`, :math:`\lambda, \mu \in ( - \infty; \infty)`, :math:`\delta \ge 0, |\beta| < \alpha` if :math:`\lambda \ge 0`, :math:`\delta > 0, |\beta| \le \alpha` if :math:`\lambda < 0`. The location-scale-based parameterization implemented in SciPy is based on [2]_, where :math:`a = \alpha\delta`, :math:`b = \beta\delta`, :math:`p = \lambda`, :math:`scale=\delta` and :math:`loc=\mu` Moments are implemented based on [3]_ and [4]_. For the distributions that are a special case such as Student's t, it is not recommended to rely on the implementation of genhyperbolic. To avoid potential numerical problems and for performance reasons, the methods of the specific distributions should be used. References ---------- .. [1] O. Barndorff-Nielsen, "Hyperbolic Distributions and Distributions on Hyperbolae", Scandinavian Journal of Statistics, Vol. 5(3), pp. 151-157, 1978. https://www.jstor.org/stable/4615705 .. [2] Eberlein E., Prause K. (2002) The Generalized Hyperbolic Model: Financial Derivatives and Risk Measures. In: Geman H., Madan D., Pliska S.R., Vorst T. (eds) Mathematical Finance - Bachelier Congress 2000. Springer Finance. Springer, Berlin, Heidelberg. :doi:`10.1007/978-3-662-12429-1_12` .. [3] Scott, David J, Würtz, Diethelm, Dong, Christine and Tran, Thanh Tam, (2009), Moments of the generalized hyperbolic distribution, MPRA Paper, University Library of Munich, Germany, https://EconPapers.repec.org/RePEc:pra:mprapa:19081. .. [4] E. Eberlein and E. A. von Hammerstein. Generalized hyperbolic and inverse Gaussian distributions: Limiting cases and approximation of processes. FDM Preprint 80, April 2003. University of Freiburg. https://freidok.uni-freiburg.de/fedora/objects/freidok:7974/datastreams/FILE1/content %(example)s ctjtj||k|dk\tjtj||k|dkzSr3)rO logical_andr)rDrrrs r5rbzgenhyperbolic_gen._argchecksHrvvay1}a1f5..aQ78 9r7ctddtj tjfd}tdddtjfd}tddtj tjfd}|||gS)NrFr rrrfrrg)rDiprhris r5rjzgenhyperbolic_gen._shape_infosd UbffWbff$5~ F UQK ? UbffWbff$5~ FB|r7c&t||dS)N)rrrrLrWrXs r5rzgenhyperbolic_gen._fitstartsw K 88r7cDtjd}|||||S)Nc2tj||||SrM)rgenhyperbolic_logpdfrprrrs r5_logpdf_singlez1genhyperbolic_gen._logpdf.._logpdf_singles..q!Q: :r7rO vectorize)rDrprrrrs r5rzgenhyperbolic_gen._logpdfs-  ;  ;aAq))r7cDtjd}|||||S)Nc2tj||||SrM)rgenhyperbolic_pdfrs r5 _pdf_singlez+genhyperbolic_gen._pdf.._pdf_singles++Aq!Q7 7r7r)rDrprrrrs r5rqzgenhyperbolic_gen._pdfs-  8  81aA&&r7cNtj|tjgS)NotypesrOrfloat64)r]s r5rzgenhyperbolic_gen.s",,tRZZL9r7ctj|||gtjj tj }t jtd|}tj||z||z z}||z tj|dz|ztj||z }d} d} ||cxkr|kr?nnr>  nnS"d,26CCDF!sD".4VEEFHHF ^^CR+1&BBCEF 88F HC MM#~! <3C())r7cJ|jtj ||||SrMrrOrhrDrprrrs r5rtzgenhyperbolic_gen._cdf#s!""BFF7Aq!Q77r7cH|j|tj|||SrMrrs r5rxzgenhyperbolic_gen._sf&s""1bffaA66r7cRtj|dtj|dz }tj|d}tj|d}tj|||||} tj||} || ztj | | zzS)NrTrr()rrr.rrr)rO float_power geninvgaussrrr) rDrrrrrrrrgignormsts r5rzgenhyperbolic_gen._rvs)s ^^Aq !BNN1a$8 8 ^^B $ ^^B &oo% t,?3w...r7ctj|||\}}}tj|dtj|dz }tj|d}tjddtj|dz}tjddd}|j |j d|j zz}tj||z|\}}} } fd ||| | fD\} } } }||z| z}|| ztj|dtj|dz| tj| dz zz}tj|d tj|d z| d |z|ztjd zz dtj| d zzzd |ztj|dz| tj| dz zz}|tj|d z}tj|dtj|dz|d| z|ztjd zz d |ztj|dztjdzzd tj| dzz ztj|dtj|d zd | zd|z|ztjd zz d tj| d zzzzd tj|dz| zz}|tj|d zd z }||||fS)NrTrrrrr#rH)rc3(K|] }|z  ywrMr).0rb0s r5 z+genhyperbolic_gen._stats..Js;Q!b&;srrr@rrr) rOrrlinspacerSshaper0rvr)rDrrrrrintegersb1b2b3b4r1r2r3r4r@rm3erm4errs @r5rzgenhyperbolic_gen._stats>s%%aA.1a ^^Aq !BNN1a$8 8 ^^B $ ^^Aq !BNN2s$; ;;;q!Q'##HNNTAFF]$BCUU1x<4BB;2r2r*:;BB FRK GbnnQ*R^^B-BB "..Q' ') ) NN1a 2>>"a#8 8 !b&2+r2 66 6 A& &' ( EBNN2q) ) "..Q' ' ) )  "..G, , NN1a 2>>"a#8 8 !b&2+r3 77 7 VbnnR+ +bnnR.E EF A& &' ( NN1a 2>>"a#8 8 Vb2glR^^B%<< < A& &' (  ( r1% % * +  "..B' '! +!Qzr7r)rrrrrbrjrrrq staticmethodrrtrxrrrrs@r5rrsTWr9 9 *':*:*@87/*'r7r genhyperbolicc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) gompertz_genaqA 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@tdddtjfdgSr rgris r5rjzgompertz_gen._shape_infor r7cLtj|j||SrMrrs r5rqzgompertz_gen._pdfrr7cdtj||z|tj|zz SrMrrs r5rzgompertz_gen._logpdfs%vvay1}q288A;..r7c\tj| tj|z SrMr{rs r5rtzgompertz_gen._cdfs#!bhhqk)***r7c`tjd|z tj| zSrDrrs r5r}zgompertz_gen._ppfs$xxq288QB</00r7cZtj| tj|zSrMrrs r5rxzgompertz_gen._sfs vvqb288A;&''r7cZtjtj| |z SrMrrDrr s r5rzgompertz_gen._isfsxx 1 %%r7cxdtj|z tjj ||z z Sr)rOrrv_ufuncs _scaled_exp1rs r5rzgompertz_gen._entropys-RVVAY!8!8!;A!===r7N rrrrrjrqrrtr}rxrrrr7r5rrks0*E*/+1(&>r7rgompertzctj|}tj|}|j}tj||z }tj||S)N)weights)rOrrraverage)rp logweightsmaxlogwrs r5_average_with_log_weightsrsM 1 AJ'JnnGffZ')*G ::a ))r7creZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z eeed Zy ) gumbel_r_genaA 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 cgSrMrris r5rjzgumbel_r_gen._shape_inforr7cJtj|j|SrMrrs r5rqzgumbel_r_gen._pdfvvdll1o&&r7c6| tj| z SrMrwrs r5rzgumbel_r_gen._logpdfsrBFFA2Jr7cVtjtj|  SrMrwrs r5rtzgumbel_r_gen._cdfsvvrvvqbzk""r7c0tj|  SrMrwrs r5rzgumbel_r_gen._logcdfsr {r7cVtjtj|  SrMr1rs r5r}zgumbel_r_gen._ppfsq z"""r7cXtjtj|   SrMrrs r5rxzgumbel_r_gen._sfs "&&!*%%%r7cXtjtj|   SrMrOrrrs r5rzgumbel_r_gen._isfs ! }%%%r7cttjtjzdz dtjdztjdzz tzdfS)Nrrrrrr#rOrrr$ris r5rzgumbel_r_gen._statss?ruuRUU{32771: beeQh(>(GOOr7ctdzSrrris r5rzgumbel_r_gen._entropys {r7c t|||\}}fd}||}|||fS| |fd nfd |jdd}|dz |dz} } fd} | | | sE| dkDs| tjkr-| dz} | dz} | | | s| dkDr| tjkr-t j | | fd d } | j }||n|||fS) Nc|| tj |z tjt z zSrM)rvrFrOrr)r.rEs r5get_loc_from_scalez,gumbel_r_gen.fit..get_loc_from_scales16R\\4%%-8266#d);LLM Mr7cz tjz |z zz}t|zz}|j|z SrM)rOrrr)r.term1term2rEr-s r5r]zgumbel_r_gen.fit..funcsK 4Z2663:2F+GG$NEIu5E 99;..r7cV |z }t|}j|z |z S)N)r)rr)r.sdatawavgrEs r5r]zgumbel_r_gen.fit..func s0!EEME4TeLD99;-55r7r.rrTcrtj|tj|k7SrMrN)rQrRr]s r5rSz0gumbel_r_gen.fit..interval_contains_roots-V -V -./r7rr)rIrtolr)rKr<rOrhr r*rL)rDrErFr4rrrr. brack_startrQrRrSresr]r-s ` @@r5rBzgumbel_r_gen.fits9t9=tEdF N  E$U+C\EzU/6((7A.K(1_kAoFF  /.ff= frvvo! ! .ff= frvvo&&tff5E,1?CHHE*$0B50ICEzr7N)rrrrrjrqrrtrr}rxrrrrJr rrBrr7r5rrs]6'##&&PM*@+@r7rgumbel_rcreZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z eeed Zy ) gumbel_l_gena A left-skewed Gumbel continuous random variable. %(before_notes)s See Also -------- gumbel_r, gompertz, genextreme Notes ----- The probability density function for `gumbel_l` is: .. math:: f(x) = \exp(x - e^x) for real :math:`x`. The Gumbel distribution is sometimes referred to as a type I Fisher-Tippett distribution. It is also related to the extreme value distribution, log-Weibull and Gompertz distributions. %(after_notes)s %(example)s cgSrMrris r5rjzgumbel_l_gen._shape_infoGrr7cJtj|j|SrMrrs r5rqzgumbel_l_gen._pdfJrr7c2|tj|z SrMrwrs r5rzgumbel_l_gen._logpdfNrr7cVtjtj|  SrMrrs r5rtzgumbel_l_gen._cdfQs"&&)$$$r7cVtjtj|  SrMrOrrvrrs r5r}zgumbel_l_gen._ppfTsvvrxx|m$$r7c.tj| SrMrwrs r5rzgumbel_l_gen._logsfWrr7cTtjtj| SrMrwrs r5rxzgumbel_l_gen._sfZvvrvvayj!!r7cTtjtj| SrMr1rs r5rzgumbel_l_gen._isf]rr7ct tjtjzdz dtjdztjdzz tzdfS)Nrrrrrris r5rzgumbel_l_gen._stats`sFwbee C2771:~beeQh&/8 8r7ctdzSrrris r5rzgumbel_l_gen._entropyds {r7c|jd |d |d<tjtj| g|i|\}}| |fS)Nr)r<rrBrOr)rDrErFr4loc_rscale_rs r5rBzgumbel_l_gen.fitgsV 88F  ' L=DL",, 4(8'8H4H4Hwvwr7N)rrrrrjrqrrtr}rrxrrrrJr rrBrr7r5rr*sZ8'%%""8M* + r7rgumbel_lcxeZdZdZdZdZdZdZdZdZ dZ d Z d Z e eefd ZxZS) halfcauchy_gena A Half-Cauchy continuous random variable. %(before_notes)s Notes ----- The probability density function for `halfcauchy` is: .. math:: f(x) = \frac{2}{\pi (1 + x^2)} for :math:`x \ge 0`. %(after_notes)s %(example)s cgSrMrris r5rjzhalfcauchy_gen._shape_inforr7c:dtjz d||zzz Sr^r.rs r5rqzhalfcauchy_gen._pdfs255y#ac'""r7ctjdtjz tj||zz Sr=rOrrrvrrs r5rzhalfcauchy_gen._logpdfs*vvc"%%i 288AaC=00r7cTdtjz tj|zSr=rrs r5rtzhalfcauchy_gen._cdfs255y1%%r7cTtjtjdz |zSrrOtanrrs r5r}zhalfcauchy_gen._ppfsvvbeeAgai  r7cVdtjz tjd|zSNrr)rOrrrs r5rxzhalfcauchy_gen._sfs 255y2::a+++r7cZdtjtj|zdz z Sr rrs r5rzhalfcauchy_gen._isfs"266"%%'!)$$$r7c~tjtjtjtjfSrMrris r5rzhalfcauchy_gen._statsrr7cNtjdtjzSrrris r5rzhalfcauchy_gen._entropyrr7c|jddrt ||g|i|St||||\}}}t j |}|$||krt d|tj|}n|}d}||} || fS|||} || fS)Nr?F halfcauchyrc||z }|jtj|fd}tjdjdz}t ||tj |f}|jS)NcP|dzz}dtj|z zz SrrOr)r. denominatorrashifted_data_squareds r5 fun_to_solvez.find_scale..fun_to_solves1#Qh)== 266"6{"BCCaGGr7rrrI)rrOsquarefinfotinyr*rrL)r-rE shifted_datar$smallrrar#s @@r5 find_scalez&halfcauchy_gen.fit..find_scalesg#:L A#%99\#:  HHHSM&&+ElUBFF<.s"((37*;);r7c8dtjd|z zSrr5rs r5rz'halflogistic_gen._isf.. s2::a!e+<)<r7rrs r5rzhalflogistic_gen._isfs!q3w;<> >r7c||dk(ry|dk(rdtjdzS|dk(r$tjtjzdz S|dk(r dtzS|dk(rdtjdzzd z Sddt d d|z z zt j |dzzt j|dzS) NrrrTrIrrr#rrr)rOrrr$rrvrrr`s r5rzhalflogistic_gen._munp s 6 6RVVAY;  655;s? " 6V8O 6RUUAX:$ $!CQqSM/"288AaC=0A>>r7c2dtjdz Srr1ris r5rzhalflogistic_gen._entropyr2r7c|jddrt ||g|i|St||||\}}}d}t j |}|$||krt d|tj|}n|}||n|||} || fS)Nr?Fc|jd}tj|d}tjd|dz|dzz }d|z }d|z}|d|z|ztj||z zz }d|z|z}||z }dtj |dd|ddzz} dtj |dd|dddzzz} | tj | dzd|z| zzzd|zz } d} d} |j}| | kDrN|tj| | z z}|d|z |j zz }t| |z | z } |} | | kDrN| S) NrrrrrTr-r#r=) rrOsortrRrrrrrvr9r)rEr-n_observations sorted_datarr|pp1rrmrrCr.rrelative_residual shifted_meansum_term scale_news r5r+z(halflogistic_gen.fit..find_scale$s"ZZ]N''$Q/K !^a/0.12DEAAAa%Ca# sQw77E7S=D%+KBFF59{12677ABFF48k!"oq&8899A"''!Q$^);a)?"?@@.(*ED ! &++-L $d*&;,u2D)EE(1^+;hlln+LL $'):E(A$B!! $d* Lr7 halflogisticrr,) rDrErFr4rrr+rr-r.rs r5rBzhalflogistic_gen.fits 88J &7;t3d3d3 38t9=tEdF D66$<  $">RVVLLCC!,*T32GEzr7)rrrrrjrqrrtr}rxrrrrJr rrBrrs@r5r.r.sV2' 9 > ?M*6+6r7r.rLceZdZdZdZd dZdZdZdZdZ dZ d Z d Z d Z eeefd ZxZS) halfnorm_genaFA 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 cgSrMrris r5rjzhalfnorm_gen._shape_infoorr7c8t|j|Sr5r!rs r5rzhalfnorm_gen._rvsrs<//T/:;;r7ctjdtjz tj| |zdz zSr=rOrrrrs r5rqzhalfnorm_gen._pdfus1wws255y!"&&!Ac"222r7cfdtjdtjz z||zdz z SNrrrrs r5rzhalfnorm_gen._logpdfys+RVVCI&&1S00r7cXtj|tjdz Srrvr$rOrrs r5rtzhalfnorm_gen._cdf|svva"''!*n%%r7c$td|zdz Srrrs r5r}zhalfnorm_gen._ppfs!A#s##r7cdt|zSrrrs r5rxzhalfnorm_gen._sfs8A;r7ct|dz Srrrs r5rzhalfnorm_gen._isfs1~r7cPtjdtjz ddtjz z tjddtjz ztjdz dzz dtjdz ztjdz dzz fS)NrrrTr#rr-rrOrrris r5rzhalfnorm_gen._statssxBEE "#bee)  AbeeG$beeAg^32557 RUU1WqL(* *r7cZdtjtjdz zdzSrTrris r5rzhalfnorm_gen._entropys#266"%%)$$S((r7c:|jddrt ||g|i|St||||\}}}t j |}|$||krt d|tj|}n|}||}||fStj|d|dz}||fS)Nr?FhalfnormrrT)ordercenterr) r2r@rBrKrOrrJrhrmoment) rDrErFr4rrrr-r.rs r5rBzhalfnorm_gen.fits 88J &7;t3d3d3 38t9=tEdF66$<  $":THHCC  EEzLLQs;S@EEzr7r)rrrrrjrrqrrtr}rxrrrrJr rrBrrs@r5rNrNYs[*<31&$* )M*+r7rNr^c@eZdZdZdZdZdZdZdZdZ dZ d Z y ) hypsecant_genaA 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 cgSrMrris r5rjzhypsecant_gen._shape_inforr7cTdtjtj|zz Sr)rOrcoshrs r5rqzhypsecant_gen._pdfsBEE"''!*$%%r7czdtjz tjtj|zSr=rOrrrrs r5rtzhypsecant_gen._cdfs&255y266!9---r7cztjtjtj|zdz Sr=rOrrrrs r5r}zhypsecant_gen._ppfs&vvbffRUU1WS[)**r7c|dtjz tjtj| zSr=rhrs r5rxzhypsecant_gen._sfs(255y2661":...r7c|tjtjtj|zdz  Sr=rjrs r5rzhypsecant_gen._isfs)rvvbeeAgck*+++r7cRdtjtjzdz ddfS)Nrr#rTr.ris r5rzhypsecant_gen._statss!"%%+a-A%%r7cNtjdtjzSrrris r5rzhypsecant_gen._entropyrr7N) rrrrrjrqrtr}rxrrrrr7r5rcrcs/&&.+/,&r7rc hypsecantc(eZdZdZdZdZdZdZy)gausshyper_gena_A Gauss hypergeometric continuous random variable. %(before_notes)s Notes ----- The probability density function for `gausshyper` is: .. math:: f(x, a, b, c, z) = C x^{a-1} (1-x)^{b-1} (1+zx)^{-c} for :math:`0 \le x \le 1`, :math:`a,b > 0`, :math:`c` a real number, :math:`z > -1`, and :math:`C = \frac{1}{B(a, b) F[2, 1](c, a; a+b; -z)}`. :math:`F[2, 1]` is the Gauss hypergeometric function `scipy.special.hyp2f1`. `gausshyper` takes :math:`a`, :math:`b`, :math:`c` and :math:`z` as shape parameters. %(after_notes)s References ---------- .. [1] Armero, C., and M. J. Bayarri. "Prior Assessments for Prediction in Queues." *Journal of the Royal Statistical Society*. Series D (The Statistician) 43, no. 1 (1994): 139-53. doi:10.2307/2348939 %(example)s c0|dkD|dkDz||k(z|dkDzS)Nrrr)rDrrr r+s r5rbzgausshyper_gen._argchecks'A!a% AF+q2v66r7ctdddtjfd}tdddtjfd}tddtj tjfd}tdddtjfd}||||gS) NrFrr rr r+rrg)rDrhrir'izs r5rjzgausshyper_gen._shape_infosx UQK @ UQK @ UbffWbff$5~ F URL. ABBr7ctj||tj||||z| z}d|z ||dz zzd|z |dz zzd||zz|zz Srrvrmhyp2f1)rDrprrr r+normalization_constants r5rqzgausshyper_gen._pdf sm!#A1aQ1K!K))ABK726QW:MM19q.! "r7ctj||z|tj||z }tj|||z||z|z| }tj||||z| }||z|z SrMrv) rDrarrr r+rrDrs r5rzgausshyper_gen._munpsnggac1o1 -ii1Q3!Ar*ii1acA2&3w}r7N)rrrrrbrjrqrrr7r5rqrqs@7 " r7rq gausshyperc`eZdZdZej ZdZdZdZ dZ dZ dZ dZ d d Zd Zy ) invgamma_gena_An inverted gamma continuous random variable. %(before_notes)s Notes ----- The probability density function for `invgamma` is: .. math:: f(x, a) = \frac{x^{-a-1}}{\Gamma(a)} \exp(-\frac{1}{x}) for :math:`x >= 0`, :math:`a > 0`. :math:`\Gamma` is the gamma function (`scipy.special.gamma`). `invgamma` takes ``a`` as a shape parameter for :math:`a`. `invgamma` is a special case of `gengamma` with ``c=-1``, and it is a different parameterization of the scaled inverse chi-squared distribution. Specifically, if the scaled inverse chi-squared distribution is parameterized with degrees of freedom :math:`\nu` and scaling parameter :math:`\tau^2`, then it can be modeled using `invgamma` with ``a=`` :math:`\nu/2` and ``scale=`` :math:`\nu \tau^2/2`. %(after_notes)s %(example)s c@tdddtjfdgSrrgris r5rjzinvgamma_gen._shape_info;r r7cLtj|j||SrMrr s r5rqzinvgamma_gen._pdf>rr7cr|dz tj|ztj|z d|z z SrrOrrvrr s r5rzinvgamma_gen._logpdfBs11vq !BJJqM1CE99r7c4tj|d|z Srrr s r5rtzinvgamma_gen._cdfEs||AsQw''r7c4dtj||z Srr1rs r5r}zinvgamma_gen._ppfHsR__Q***r7c4tj|d|z Srrr s r5rxzinvgamma_gen._sfKs{{1cAg&&r7c4dtj||z Srrrs r5rzinvgamma_gen._isfNsR^^Aq)))r7ctj|dkD|dtj}tj|dkD|dtj}d\}}d|vr+tj|dkD|d tj}d |vr+tj|d kD|d tj}||||fS) Nrcd|dz z Srrrs r5rz%invgamma_gen._stats..SsrQV}r7rrTc$d|dz dzz |dz z S)NrrTrrrs r5rz%invgamma_gen._stats..VsrQVaK'71r6'Br7rrrcDdtj|dz z|dz z S)NrOrrIrrs r5rz%invgamma_gen._stats..\s 2B+?1r6+Jr7rr#c0dd|zdz z|dz z |dz z S)Nrr g&@rIrOrrs r5rz%invgamma_gen._stats..`s&2a#+>!b&+IQQSV+Tr7r)rDrrrBrCrDrEs r5rzinvgamma_gen._statsQs __QUA4(*0__QUAB(*0B '>Q!J,.FF4B '>Q!T,.FF4B2r2~r7cHd}d}tj|dk\|||}|S)Ncn||dztj|zz tj|z}|Srr8rrs r5rz&invgamma_gen._entropy..regularfs/QWq ))BJJqM9AHr7cddtj|zz tjdztjtjzdz d|dzzz|dzdz z|dzd z z |d zd z z }|S) NrrrTUUUUUU?rArrrr rrrrs r5rtz)invgamma_gen._entropy..asymptoticjsaq k/BFF1I-ruu =q@q#v: !3r *,-sF2I6893s CAHr7rur)rDrrrtrs r5rzinvgamma_gen._entropyes+   OOAHaW =r7Nmvsk)rrrrrrrrjrqrrtr}rxrrrrr7r5r|r|sB:"44ME*:(+'*( r7r|invgammaceZdZdZej ZdZddZdZ dZ dZ dZ dZ d Zfd Zfd Zd Zeefd ZdZxZS) invgauss_genaUAn 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@tdddtjfdgSNrBFrr rgris r5rjzinvgauss_gen._shape_inforr7c*|j|d|SNrrwaldrDrBrrs r5rzinvgauss_gen._rvss  St 44r7cdtjdtjz|dzzz tjdd|zz ||z dz dzzzS)NrrTrIrArrRrDrprBs r5rqzinvgauss_gen._pdfsO2771RUU71c6>**266$!*adQh]2J+KKKr7cdtjdtjzzdtj|zz ||z dz dzd|zz z S)Nr(rTrrrrs r5rzinvgauss_gen._logpdfsHBFF1RUU7O#c"&&)m3qtax!mQqS6IIIr7cdtj|z }t|||z dz z}d|z t| ||z dzzz}|tjtj||z zSr0)rOrrrrrDrprBrrrs r5rzinvgauss_gen._logcdfsl"''!*n "q) * F\3$!B$("34 4288BFF1q5M***r7cdtj|z }t|||z dz z}d|z t| ||z dzzz}|tjtj ||z  zSr0)rOrrrrrrs r5rzinvgauss_gen._logsfsn"''!*n qtax( ) F\3$!B$("34 4288RVVAE]N+++r7cLtj|j||SrMr;rs r5rxzinvgauss_gen._sfsvvdkk!R())r7cLtj|j||SrMrQrs r5rtzinvgauss_gen._cdfvvdll1b)**r7ctjddd5tj||\}}tjt j ||d}|dkD}t j d||z ||d||<tj|}t|%||||||<ddd|S#1swYSxYwNr8)r:rqr=rr) rOr;rrrm _invgauss_ppf _invgauss_isfrr@r})rDrprBppfi_wti_nanrs r5r}zinvgauss_gen._ppfs [[x J ;''2.EAr**S..q"a89Cs7D))!AdG)RXqACIHHSMEah5 :CJ  ;  ; s BB>>Ccptjddd5tj||\}}tj||d}|dkD}tj d||z ||d||<tj |}t|!||||||<ddd|S#1swYSxYwr) rOr;rrmrrrr@r)rDrprBisfrrrs r5rzinvgauss_gen._isfs [[x J ;''2.EAr##Ar1-Cs7D))!AdG)RXqACIHHSMEah5 :CJ  ;  ; s BB++B5cF||dzdtj|zd|zfS)NrIrrr)rDrBs r5rzinvgauss_gen._statss%2s7AbggbkM2b500r7c|jdd}t|ts#t|ts|j dk(rt ||g|i|St||||\}}}} ||t ||g|i|Stj||z dkrtddtj||z }tj|}|*t|tj|dz|dzz z }||z }|||fS)Nr0r:r;rinvgaussrr)r<r>r)wald_genr=r@rBrKrOrrJrhrrr) rDrErFr4r0fshape_srrfshape_nrs r5rBzinvgauss_gen.fits(E* t\ *jx.H<<>T)7;t3d3d3 3'B4CG(O$hf  <8/7;t3d3d3 3 VVD4K!O $z"&&A A$;Dwwt}H~TbffTRZ(b.-H&IJ&(Hv%%r7cdtjdtjzzdtj|zz}d|z }tjj ||z }d|zd|zz S)zV Ref.: https://moser-isi.ethz.ch/docs/papers/smos-2012-10.pdf (eq. 9) rrTrrr)rOrrrvrr)rDrBrrrs r5rzinvgauss_gen._entropysg BEE " "Q^ 3 bD JJ # #A &q (Qwq  r7r)rrrrrrrrjrrqrrrrxrtr}rrr rBrrrs@r5rrxso(R"44MF5L J+ , *+1M*&+&B !r7rrcNeZdZdZdZdZdZdZdZdZ d d Z d Z d Z d Z y)geninvgauss_genabA Generalized Inverse Gaussian continuous random variable. %(before_notes)s Notes ----- The probability density function for `geninvgauss` is: .. math:: f(x, p, b) = x^{p-1} \exp(-b (x + 1/x) / 2) / (2 K_p(b)) where ``x > 0``, `p` is a real number and ``b > 0``\([1]_). :math:`K_p` is the modified Bessel function of second kind of order `p` (`scipy.special.kv`). %(after_notes)s The inverse Gaussian distribution `stats.invgauss(mu)` is a special case of `geninvgauss` with ``p = -1/2``, ``b = 1 / mu`` and ``scale = mu``. Generating random variates is challenging for this distribution. The implementation is based on [2]_. References ---------- .. [1] O. Barndorff-Nielsen, P. Blaesild, C. Halgreen, "First hitting time models for the generalized inverse gaussian distribution", Stochastic Processes and their Applications 7, pp. 49--54, 1978. .. [2] W. Hoermann and J. Leydold, "Generating generalized inverse Gaussian random variates", Statistics and Computing, 24(4), p. 547--557, 2014. %(example)s c||k(|dkDzSr3rrDrrs r5rbzgeninvgauss_gen._argcheck7sQ1q5!!r7ctddtj tjfd}tdddtjfd}||gS)NrFr rrrg)rDrris r5rjzgeninvgauss_gen._shape_info:B UbffWbff$5~ F UQK @Bxr7cd}tj|tjg}||||}tj|j rd}t j |td|S)Nc0tj|||SrM)rgeninvgauss_logpdfrprrs r5 logpdf_singlez.geninvgauss_gen._logpdf..logpdf_singleCs,,Q15 5r7rzjInfinite values encountered in scipy.special.kve(p, b). Values replaced by NaN to avoid incorrect results.rrJ)rOrrrrrLrMrN)rDrprrrr+rXs r5rzgeninvgauss_gen._logpdf?s\ 6 ]BJJ<H !Q " 88A;?? HC MM#~! <r7cNtj|j|||SrMrrDrprrs r5rqzgeninvgauss_gen._pdfOrr7c|j||\}fd}tj|tjg}||||S)Nctj||gtjj tj }t jtd|}tj||dS)N_geninvgauss_pdfr) rOrrTrrrr rrrr)rprrrrrs r5 _cdf_singlez)geninvgauss_gen._cdf.._cdf_singleVs^!Q/66>>vOI"..v7I/8:C>>#r1-a0 0r7r)rrOrr)rDrprrrrrs @r5rtzgeninvgauss_gen._cdfSsE""1a(B 1ll; |D 1a##r7c`tj|dkD|||fdtj S)NrcV|dz tj|z||d|z zzdz z Sr0r1rs r5rz.geninvgauss_gen._logquasipdf..ds,Arvvay/@1a!A#g;q=/Pr7rrrs r5 _logquasipdfzgeninvgauss_gen._logquasipdfas-q1uq!QiP+-66'3 3r7NcX tj|r+tj|r|j||||}nR|jdk(rA|jdk(r2|j|j |j ||}ntj ||\}}t |j|\} ttj|}tj|}tj||gdgdgdgg jsrt fdtt| dD}|j d d||j!|||< j# jsr|dk(r|j }|S)Nr multi_indexreadonlyflagsop_flagsc3\K|]#}|sj|n td%ywrMrslicerrbcits r5rz'geninvgauss_gen._rvs..1; !79eR^^A.tL;),rr)rOr _rvs_scalarrrUrrrrremptynditerfinishedtuplerrrSiternext) rDrrrrrshp numsamplesidxrrs @@r5rzgeninvgauss_gen._rvsgsi ;;q>bkk!n""1a|.logqpdfs,,Q15::r7c*j|SrMr)rprrrDs r5rz,geninvgauss_gen._rvs_scalar..logqpdfs,,Q155r7zvmin must be smaller than vmax.zumax must be positive.riPz2Not a single random variate could be generated in zH attempts. Sampling does not appear to work for the provided parameters.)rr)_moderrOrr atleast_1drzerosarccosr rrrrrrrr r logical_notrS)4rDrrrr invert_resr@ ratio_unif mode_shiftsize1dNrp simulateda2a1p1q1phir[root1root2d1d2vminvmaxumaxrr xplusrrrrraccept num_acceptrXr"xsk1A1k2A2k3A3rqrcond1cond2cond3r+rs4``` @r5rzgeninvgauss_gen._rvs_scalars J q5AJ JJq!  6QUJ #c1rwwq1u~-12 2JJr}}Z01 GGFO HHQK 1q5\A%)Ua!e_q(1,"a%!)^QY^b2gk1A5iibggcBEk&: :Q >?ggb2gk**RVVC!Gbeeai$78826AbffS1Wo-Q6&&q!Q/&&ua3b8&&ua3b8 RVVC"H%55 RVVC"H%55;vvc$"3"3Aq!"<<=a%277AEA:1+<#==q@rvvcD,=,=eQ,J&JKK6t| !BCCqy !9::Aa- M<//Q/77 ((a(0D4K1,,!eaiBFF1I+5VVF^ >uu}5!E(]R/E %q5"$a%1U8b=A*=*B"Ba!e!LCJ!"RVVQuX]bffQi,G%H!HCJE QU 33%FFB37Q;'!qx"}r/A*Ba"f*MM!VbffQi/E E {Q': ;;%&&Q-4+<+sffQUAq! 88C=288E?2 <<>.C MM#~! < S"&& ;Ay>E8),< r7rrcfeZdZdZej ZdZdZfdZ dZ dZ dZ d dZ d ZxZS) norminvgauss_genaA 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>|dkDtj||kzSr3)rOabsoluterDrrs r5rbznorminvgauss_gen._argchecksA"++a.1,--r7ctdddtjfd}tddtj tjfd}||gSrfrgrgs r5rjznorminvgauss_gen._shape_infor[r7c&t||dS)N)rrrLrWrXs r5rznorminvgauss_gen._fitstartsw H 55r7ctj|dz|dzz }|tjz }tjd|}|t j ||zztj ||z||zz |zz|z Sr)rOrrhypotrvk1er)rDrprrrfac1sqs r5rqznorminvgauss_gen._pdfss1q!t $255y XXa^bffQVn$rvvacAbDj5.@'AABFFr7c tj|r6tj|j|tj ||fdStj |}tj |}g}t|||D]K\}}}|jtj|j|tj ||fdMtj|S)NrLr) rOrrrrqrhrrappendr)rDrprrresultr"a0rs r5rxznorminvgauss_gen._sfs ;;q>>>$))QaVDQG G a A a AF #Aq!  @ R innTYYBFF35r(<<=?@ @88F# #r7cfd}tj|r ||||Sg}t|||D]\}}}|j||||!tj|S)Nct fd} j||}|||||}|dk(r|S|dkDr1d}|}||z}|||||dkDrJd|z}||z}|||||dkDrn0d}|}||z }|||||dkrd|z}||z }|||||dkrtj||||||f j} | S)Nc0j||||z SrMrx)rprrr|rDs r5eqz6norminvgauss_gen._isf.._isf_scalar..eqsxx1a(1,,r7rrrT)rFr)rr rAr) r|rrr&xmemdeltaleftrightr rDs r5 _isf_scalarz*norminvgauss_gen._isf.._isf_scalars -1aBB1aBQw AvU 1a(1,eGEJE1a(1, Ezq!Q'!+eGE:Dq!Q'!+__RuAq!9*.))5FMr7)rOrrrr) rDr|rrr,r q0r!rs ` r5rznorminvgauss_gen._isfsk B ;;q>q!Q' 'F #Aq!  7 R k"b"56 788F# #r7ctj|dz|dzz }tjd|z ||}||ztj|tj||zzS)NrTr)rBrrr)rOrrrr)rDrrrrrigs r5rznorminvgauss_gen._rvsso1q!t $ \\QuW4l\ K2v dhhD 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@tdddtjfdgSr rgris r5rjzinvweibull_gen._shape_infor r7ctj|| dz }tj|| }tj| }||z|zSrrOrr)rDrpr xc1xc2s r5rqzinvweibull_gen._pdf sFhhq1"s(#hhq1"offcTl3w}r7c\tj|| }tj| SrMr9)rDrpr r:s r5rtzinvweibull_gen._cdfs#hhq1"ovvsd|r7c8tj|| z  SrM)rOrrs r5rxzinvweibull_gen._sfs!aR%   r7c\tjtj| d|z SrD)rOrrrs r5r}zinvweibull_gen._ppfs!xx DF++r7c<tj|  d|z zSNrr>rs r5rzinvweibull_gen._isfs1" A&&r7c8tjd||z z Sr]rlrs r5rzinvweibull_gen._munpsxxAE ""r7cTdtzt|z ztj|z Sr]r<rs r5rzinvweibull_gen._entropy!s"x&1*$rvvay00r7c2|dn|}t|||S)N)rrLrW)rDrErFrs r5rzinvweibull_gen._fitstart$s#v4w D 11r7rM)rrrrrrrrjrqrtrxr}rrrrrrs@r5r6r6sH:"44ME!,'#122r7r6 invweibullc<eZdZdZdZdZd dZdZdZdZ d Z y) jf_skew_t_genaJones 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:`ab`, 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 ctdddtjfd}tdddtjfd}||gSrfrgrgs r5rjzjf_skew_t_gen._shape_infoRrjr7c0d||zdz ztj||ztj||zz}d|tj||z|dzzz z|dzz}d|tj||z|dzzz z |dzz}||z|z SNrTrr)rvrmrOr)rDrprrr rrs r5rqzjf_skew_t_gen._pdfWs !a%!) rwwq!} ,rwwq1u~ =!bgga!ea1fn---1s7 ;!bgga!ea1fn---1s7 ;Bw{r7Nc|j|||}d|zdz tj||zz}dtj|d|z zz}||z Sr)rmrOr)rDrrrrrrd3s r5rzjf_skew_t_gen._rvs]sX   q!T *"fqjBGGAEN * q2v' 'Bwr7c~d|tj||z|dzzz zdz}tj|||SNrrTr)rOrrvr{rDrprrrs r5rtzjf_skew_t_gen._cdfcs> RWWQUQ!V^,, , 3zz!Q""r7c~d|tj||z|dzzz zdz}tj|||SrM)rOrrvr}rNs r5rxzjf_skew_t_gen._sfgs> RWWQUQ!V^,, , 3{{1a##r7ctj|||}d|zdz tj||zz}dtj|d|z zz}||z Sr)rmrrOr)rDr|rrrrrKs r5r}zjf_skew_t_gen._ppfksV XXaA "fqjBGGAEN * q2v' 'Bwr7cd}|d|zkD|d|zkDz|dk\z}tj||||ftj|tjgtj S)zReturns the n-th moment(s) where all the following hold: - n >= 0 - a > n / 2 - b > n / 2 The result is np.nan in all other cases. cn||zd|zz}d|ztj||z}tj|dz}tj|dzdkDdd}tj|d|zz|z |d|zz |z}tj |||z|z}||z |j zS)zgComputes E[T^(n_k)] where T is skew-t distributed with parameters a_k and b_k. rrTrrr)rvrmrOrRrTrr) n_ka_kb_krDrindicesr}r sum_termss r5 nth_momentz'jf_skew_t_gen._munp..nth_momentzs9#),CHrwwsC00Eiia(G((7Q;?B2CcCi'13s?W3LMAW-3a7I;0 0r7rrrrrrrOrrr)rDrarrrXnth_moment_valids r5rzjf_skew_t_gen._munpqse 1aKAaK8AFC  1I LLRZZL 9vv   r7r) rrrrrjrqrrtrxr}rrr7r5rFrF-s+#H   #$  r7rF jf_skew_tcReZdZdZej ZdZdZdZ dZ dZ dZ dZ y ) johnsonsb_gena!A Johnson SB continuous random variable. %(before_notes)s See Also -------- johnsonsu Notes ----- The probability density function for `johnsonsb` is: .. math:: f(x, a, b) = \frac{b}{x(1-x)} \phi(a + b \log \frac{x}{1-x} ) where :math:`x`, :math:`a`, and :math:`b` are real scalars; :math:`b > 0` and :math:`x \in [0,1]`. :math:`\phi` is the pdf of the normal distribution. `johnsonsb` takes :math:`a` and :math:`b` as shape parameters. %(after_notes)s %(example)s c|dkD||k(zSr3rrs r5rbzjohnsonsb_gen._argcheckrYr7ctddtj tjfd}tdddtjfd}||gSNrFr rrrgrgs r5rjzjohnsonsb_gen._shape_inforr7clt||tj|zz}|dz|d|z zz |zSr.)rrvr=)rDrprrtrms r5rqzjohnsonsb_gen._pdfs8AbhhqkM)*ua1gs""r7cJt||tj|zzSrM)rrvr=rss r5rtzjohnsonsb_gen._cdfsQrxx{]*++r7cPtjd|z t||z zSr)rvr9rrs r5r}zjohnsonsb_gen._ppf#xxa9Q 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|dkD||k(zSr3rrs r5rbzjohnsonsu_gen._argcheckrYr7ctddtj tjfd}tdddtjfd}||gSr`rgrgs r5rjzjohnsonsu_gen._shape_inforr7c||z}t||tj|zz}|dztj|dzz |zSr)rrOarcsinhr)rDrprrrBrbs r5rqzjohnsonsu_gen._pdfsIqSA 1 --.uRWWRV_$S((r7cJt||tj|zzSrM)rrOrnrss r5rtzjohnsonsu_gen._cdfsQA..//r7cJtjt||z |z SrM)rOsinhrrs r5r}zjohnsonsu_gen._ppfww ! q(A-..r7cJt||tj|zzSrM)rrOrnrss r5rxzjohnsonsu_gen._sfsA 1 --..r7cJtjt||z |z SrM)rOrqrrss r5rzjohnsonsu_gen._isf rrr7cd\}}}}|dz}tj|} ||z } d|vr| dz tj| z}d|vr7dtj|z| tj d| zzdzz}d|vr| dztj|dzz} d tj| z} | | dzztjd | zz} tj dd| tj d| zzzd zz}| | | zz|z }d |vrd d | zz} d | dzz| dzztj d| zz} | dztj d | zz} dd | dzzzd| d zzz| d zz}dd| tj d| zzzdzz}| | z| |zz|z d z }||||fS)Nrrr@rrrTrrrrrrr#r)rOrrqrvrrfr)rDrrrrBrCrDrEbn2expbn2a_brrrrrGs r5rzjohnsonsu_gen._statss1CRf!e '>#+ ,B '>bhhsm#VBGGAcEN%:Q%>?C '>bhhsmS00B2773<B6A:&37BGGAJ!frwwqu~&="=!EEER5(B '>QvXB619 +bggaenffRVVD4K01SY>FV|r7r)rrrrrjrrqrtrxr}rrrrJr rrBrr7r5rrsa&5#H@ 6FG  G r7rrcFeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) laplace_asymmetric_genuAn 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@tdddtjfdgS)NkappaFrr rgris r5rjz"laplace_asymmetric_gen._shape_infos7EArvv;GHHr7cLtj|j||SrMrrDrprs r5rqzlaplace_asymmetric_gen._pdfsvvdll1e,--r7cd|z }|tj|dk\| |z}|tj||zz}|Srr)rDrprkapinvrys r5rzlaplace_asymmetric_gen._logpdfsD5"((16E6622 rvveFl## r7cd|z }||z}tj|dk\dtj| |z||z zz tj||z||z zSrrOrTrrDrprr kappkapinvs r5rtzlaplace_asymmetric_gen._cdfsf56\ xxQBFFA2e8,fZ.?@@qx(% *:;= =r7c d|z }||z}tj|dk\tj| |z||z zdtj||z||z zz Srrrs r5rxzlaplace_asymmetric_gen._sfsh56\ xxQr%x(&*;<BFF1V8,eJ.>??A Ar7cd|z }||z}tj|||z k\tjd|z |z|z |ztj||z|z |zSr]rrDr|rrrs r5r}zlaplace_asymmetric_gen._ppfsm56\ xxU:--Q 25 899&@q|E1258: :r7cd|z }||z}tj|||z ktj||z|z |ztjd|z |z|z |zSr]rrs r5rzlaplace_asymmetric_gen._isf#so56\ xxVJ..* U 233F:Az1%78>@ @r7c`d|z }||z }||z||zz}ddtj|dz ztjdtj|dzdz }ddtj|dzztjdtj|dzdz }||||fS) Nrrrr#rrr-rTr)rDrrmnrrDrEs r5rzlaplace_asymmetric_gen._stats*s5 e^VmeEk) !BHHUA&& '288E13E1Es(K K !BHHUA&& '288E13E1Eq(I I3Br7c>dtj|d|z zzSr]r1rDrs r5rzlaplace_asymmetric_gen._entropy2s266%%-(((r7Nr rr7r5rrs8*VI. =A:@)r7rlaplace_asymmetricct|tstj|}|j dd}|j dd}|j r$t |j jdnd}g}g}|j r|j jddj} t| D]T\} } dt| z} | d| zd| zg} t|| }|j| |j||P||| <Vdd d d ddh|}t|j|}|rtd |d t ||kDr tdd||h|vr t!dt|tr|j#n|}tj$|j's t)d|g|||S)Nrr,r rfix_r-r.r/r0zUnknown keyword arguments: r1zToo many positional arguments.rr)r>r)rOrr<shapesrsplitrU enumeratestrrrset differencer3r rrrr)distrErFr4rr num_shapes fshape_keysfshapesrrrkeynamesr| known_keys unknown_keys uncensoreds r5rKrK9s dL )zz$ 88FD !D XXh %F04 T[[&&s+,JKG  {{$$S#.446f% DAqA,C#'6A:.E&tU3C   s # NN3 S  +x(2%02Jt9'' 3L5l^1EFF 4y:899 D&+7++'( (&0l%C!J ;;z " & & (?@@  )7 )D )& ))r7cReZdZdZej ZdZdZdZ dZ dZ dZ dZ y ) levy_genagA 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() cgSrMrris r5rjzlevy_gen._shape_inforr7cdtjdtjz|zz |z tjdd|zz zSNrrTrrRrs r5rqz levy_gen._pdfs=2771RUU719%%)BFF2qs8,<<ddtj|dzzz Sr0)rverfinvrs r5rz levy_gen._isfs!BIIaL!O#$$r7c~tjtjtjtjfSrMrris r5rzlevy_gen._statsrr7Nrrrrrrrrjrqrtrxr}rrrr7r5rrjs9GP"44M=)(! %.r7rlevycReZdZdZej ZdZdZdZ dZ dZ dZ dZ y ) levy_l_genaA 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() cgSrMrris r5rjzlevy_l_gen._shape_inforr7ct|}dtjdtjz|zz |z tjdd|zz zSr)rrOrrrrDrprs r5rqzlevy_l_gen._pdfsF V255$$R'r1R4y(999r7cft|}dtdtj|z zdz Sr)rrrOrrs r5rtzlevy_l_gen._cdf$s, V9Q_--11r7c`t|}dtdtj|z zSr)rrrOrrs r5rxzlevy_l_gen._sf(s' V8A O,,,r7c4t|dzdz }d||zz S)NrrTrArrs r5r}zlevy_l_gen._ppf,s#SA &sSy!!r7c*dt|dz dzz S)NrrTrrs r5rzlevy_l_gen._isf0s)AaC.!###r7c~tjtjtjtjfSrMrris r5rzlevy_l_gen._stats3rr7Nrrr7r5rrs9FN"44M: 2-"$.r7rlevy_lceZdZdZdZddZdZdZdZdZ dZ d Z d Z d Z d Zd ZeeefdZxZS) logistic_genaA 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 cgSrMrris r5rjzlogistic_gen._shape_infoRrr7c&|j|Sr5)logisticrs r5rzlogistic_gen._rvsUs$$$$//r7cJtj|j|SrMrrs r5rqzlogistic_gen._pdfXrr7ctj| }|dtjtj|zz Sr=)rOrrvrr)rDrprs r5rzlogistic_gen._logpdf\s2 VVAYJ2++++r7c,tj|SrMr8rs r5rtzlogistic_gen._cdf`xx{r7c,tj|SrMrv log_expitrs r5rzlogistic_gen._logcdfcs||Ar7c,tj|SrMr<rs r5r}zlogistic_gen._ppffrr7c.tj| SrMr8rs r5rxzlogistic_gen._sfisxx|r7c.tj| SrMrrs r5rzlogistic_gen._logsfls||QBr7c.tj| SrMr<rs r5rzlogistic_gen._isfos |r7cRdtjtjzdz ddfS)NrrIg333333?r.ris r5rzlogistic_gen._statsrs!"%%+c/1g--r7cyr=rris r5rzlogistic_gen._entropyusr7c |jddrt |g|i|St|||\}}t  |j \}}|j d||j d|}}|f fd |f fd fd}|+|)tj |f} | jd}|}nT|+|)tj |f} | jd}|}n'tj|||f} | j\}}t|}| jr||fSt |g|i|S) Nr?Fr-r.cp|z |z }tjtj|dz z Sr)rOrrvr9)r-r.r rEras r5dl_dlocz!logistic_gen.fit..dl_dlocs1u$A66"((1+&1, ,r7cv|z |z }tj|tj|dz zz Sr)rOrr3)r.r-r rEras r5 dl_dscalez#logistic_gen.fit..dl_dscales5u$A66!BGGAaCL.)A- -r7c2|\}}||||fSrMr)paramsr-r.rrs r5r]zlogistic_gen.fit..funcs%JC3& %(== =r7r) r2r@rBrKrrr<r rLrprsuccess)rDrErFr4rrr-r.r]rrrrars ` @@@r5rBzlogistic_gen.fitysS 88J &7;t3d3d3 38t9=tEdF I^^D) UXXeS)488GU+CU & -"& . >  $,--#0C%%(CE  &.-- E84CEE!HEC--sEl3CJC E  # e  7W[555 7r7r)rrrrrjrrqrrtrr}rxrrrrrJr rrBrrs@r5rr:se.0', .M*07+07r7rrcNeZdZdZdZd dZdZdZdZdZ d Z d Z d Z d Z y) loggamma_genaA 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@tdddtjfdgSr rgris r5rjzloggamma_gen._shape_infor r7Nctj|j|dz|tj|j||z zS)Nrr)rOrrrrs r5rzloggamma_gen._rvssM|))!a%d);<&&--4-89!;< =r7ctj||ztj|z tj|z SrMrOrrvrrs r5rqzloggamma_gen._pdfs.vvac"&&)mBJJqM122r7cd||ztj|z tj|z SrMrrs r5rzloggamma_gen._logpdfs%sRVVAYA..r7cHtj|tk||fddS)Ncdtj||ztj|dzz Sr]rrs r5rz#loggamma_gen._cdf..s$!bjj1o 56r7cTtj|tj|SrM)rvrrOrrs r5rz#loggamma_gen._cdf..sQq 2r7rrr"rs r5rtzloggamma_gen._cdfs( L1a& 6 24 4r7cvtj||}tj|tk|||fddS)Ncdtj|tj|dzz|z Sr]rrr|r s r5rz#loggamma_gen._ppf..s$RVVAYAaC8!;r7c,tj|SrMr1r s r5rz#loggamma_gen._ppf..BFF1Ir7)rvrrrr!rDr|r rs r5r}zloggamma_gen._ppfs: NN1a  I1ay ; %' 'r7cHtj|tk||fddS)Ncftj||ztj|dzz  Sr])rOrrvrrs r5rz"loggamma_gen._sf..s'"((1Q3AaC#899r7cTtj|tj|SrM)rvrrOrrs r5rz"loggamma_gen._sf..sa3r7rrs r5rxzloggamma_gen._sfs& L1a& 9 35 5r7cvtj||}tj|tk|||fddS)Ncftj| tj|dzz|z Sr])rOrrvrr s r5rz#loggamma_gen._isf.. s&RXXqb\BJJqsO;Q>r7c,tj|SrMr1r s r5rz#loggamma_gen._isf.. r r7)rvrrrr!rs r5rzloggamma_gen._isfs: OOAq ! I1ay > %' 'r7ctj|}tjd|}tjd|tj|dz }tjd|||zz }||||fS)NrrTrr)rvr polygammarOr)rDr rrr2excess_kurtosiss r5rzloggamma_gen._statssizz!}ll1a <<1%c(::,,q!,C8S(O33r7cDd}d}tj|dk\|||S)Nchtj||tj|zz |z}|SrM)rvrr)r rs r5rz&loggamma_gen._entropy..regulars+ 1 BJJqM 11A5AHr7cdtj|z|dzdz z|dzdz z |dzdz z}tj|z}|S)Nr(rArrr r)rOrrr)r termrs r5rtz)loggamma_gen._entropy..asymptoticsOq >AsF1H,q#vby81c6#:ED $&AHr7-r)rDr rrts r5rzloggamma_gen._entropys'   qBw:w??r7rrrrrrjrrqrrtr}rxrrrrr7r5rrs;0E =3/4('5'4 @r7rloggammacreZdZdZdZdZdZdZdZdZ dZ d Z e e efd ZxZS) loglaplace_genaTA 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@tdddtjfdgSr rgris r5rjzloglaplace_gen._shape_infoJr r7cX|dz }tj|dk|| }|||dz zzSrrOrT)rDrpr cd2s r5rqzloglaplace_gen._pdfMs7e HHQUAr "1qs8|r7cVtj|dkd||zzdd|| zzz SNrrr$rs r5rtzloglaplace_gen._cdfTs/xxAs1a4x3qA2w;77r7cVtj|dkdd||zzz d|| zzSr'r$rs r5rxzloglaplace_gen._sfWs/xxAq3q!t8|SaR[99r7c`tj|dkd|zd|z zdd|z zd|z zSNrrrrTrAr$rs r5r}zloglaplace_gen._ppfZs7xxC#a%3q5!1As1uIa3HIIr7c`tj|dkDdd|z zd|z zd|zd|z zSr*r$rs r5rzloglaplace_gen._isf]s6xxC#sQw-3q5!9AaC46?KKr7ctjd5|dz|dz}}tj||k|||z z tjcdddS#1swYyxYw)Nr8r9rT)rOr;rTrh)rDrar rn2s r5rzloglaplace_gen._munp`sT [[ ) =T1a4B88BGR27^RVV< = = =s 8AA"c8tjd|z dzSr^r1rs r5rzloglaplace_gen._entropyesvvc!e}s""r7ct||||\}}}}|tt|||g|i|St j ||krt d|tj|dk7r||z }tjt j||t j|nd|d|z ndd\}}|} |t j|n|} |d|z n|} | | | fS)N loglaplacerrrr:)rrr0) rKr@rArBrOrrJrhrrr) rDrErFr4rMrrrrr-r.r rs r5rBzloglaplace_gen.fiths"=T4=A4"Ib$ <dT.tCdCdC C 66$$, |4rvvF F 19$;D{{266$<282Dv$*,.!B$d"')1#^q ZAER#u}r7)rrrrrjrqrtrxr}rrrrJr rrBrrs@r5r!r!)sU@E8:JL= #M*+r7r!r0c^tj|dk7||fdtj S)Nrctj|dz d|dzzz tj||ztjdtjzzz Sr)rOrrrrprs r5rz!_lognorm_logpdf..sLrvvay!|mq1a4x0q1urwwq255y'99:;r7rrr3s r5_lognorm_logpdfr4s. ?? QA <FF7  r7ceZdZdZej ZdZddZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZeeedfdZxZS) lognorm_genaA 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@tdddtjfdgS)NrFrr rgris r5rjzlognorm_gen._shape_infor r7cPtj||j|zSrMrOrr)rDrrrs r5rzlognorm_gen._rvss!vva,66t<<==r7cLtj|j||SrMrrDrprs r5rqzlognorm_gen._pdfrr7ct||SrMr4r;s r5rzlognorm_gen._logpdfsq!$$r7cDttj||z SrMrrOrr;s r5rtzlognorm_gen._cdfsQ''r7cDttj||z SrMrr;s r5rzlognorm_gen._logcdfsBFF1IM**r7cDtj|t|zSrMrOrrrDr|rs r5r}zlognorm_gen._ppfvva)A,&''r7cDttj||z SrMrrOrr;s r5rxzlognorm_gen._sfsq A &&r7cDttj||z SrM)rrOrr;s r5rzlognorm_gen._logsfs266!9q=))r7cDtj|t|zSrMrOrrrCs r5rzlognorm_gen._isfrDr7ctj||z}tj|}||dz z}tj|dz d|zz}tjgd|}||||fSNrrT)rrTrrr)rOrrpolyval)rDrrrBrCrDrEs r5rzlognorm_gen._statssf FF1Q3K WWQZ1g WWQqS\1Q3  ZZ*A .3Br7cddtjdtjzzdtj|zzzSNrrrTr)rDrs r5rzlognorm_gen._entropys3a"&&255/)Aq M9::r7aF 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 rc|jddrtg|i|St||}|\}t j }fdfd}fd}|&t j |} || z } || } || } d| z} | dk\r|| z } || } | dz} | dk\rt j| rt j| stg|i|St jt j| tj | dz }||}d| |z z} t j|rt j|rt j|t j| k(rh| | z }||}| dz} t j|rAt j|r,t j|t j| k(rht j|rt j|stg|i|St||| f }|jstg|i|S||j}|| kDr |jn|| z }n#||k\rtd d tj |}|\}}j!|r|d kDstg|i|S|||fS)Nr?Fctj|z }xs#tjj}xsAtjtjtj|z dz}||fSr)rOrrrr)r-lndatar.rrErfshapes r5get_shape_scalez(lognorm_gen.fit..get_shape_scalesq~s +3bffV[[]3EKbggbggvu /E.I&JKE%< r7c|\}}|z }tjdtj||z |dzz z|z Sr0rOrr)r-rr.shiftedrErSs r5dL_dLocz lognorm_gen.fit..dL_dLocsI*3/LE5SjG661rvvgem4UAX==wFG Gr7cF|\}}j|||f SrM)nnlf)r-rr.rErSrDs r5llzlognorm_gen.fit..lls,*3/LE5IIuc51488 8r7rTgưrr%lognormrrr)r2r@rBrKrOrspacingrr nextafterrhrPr* convergedrLrJrb)rDrErFr4 parametersrrrWrZr\rRdL_dLoc_rbrack ll_rbrackr)rQdL_dLoc_lbrackrll_rootr-rr.rrRrSrs`` @@@r5rBzlognorm_gen.fits$ 88J &7;t3d3d3 30tT4H %/"fdF66$<  H  9 <jj*G'F %V_N6 IKE E)!E)!( !E) ;;v&bkk..Iw{47$7$77 ZZ VbffW =vaxHF$V_N&)E;;v&2;;~+Fww~."''.2II%!(  ;;v&2;;~+Fww~."''.2II ;;v&bkk..Iw{47$7$77g/?@C==w{47$7$77 lG% 1#((x7GCx"9BbffEEC&s+ uu%%!)7;t3d3d3 3c5  r7r)rrrrrrrrjrrqrrtrr}rxrrrrrJr rBrrs@r5r6r6s}*V"44ME>*%(+('*(;}5 Z!!"Z!r7r6r[cfeZdZdZej ZdZd dZdZ dZ dZ dZ d Z d Zd Zd Zy) gibrat_gena[A Gibrat continuous random variable. %(before_notes)s Notes ----- The probability density function for `gibrat` is: .. math:: f(x) = \frac{1}{x \sqrt{2\pi}} \exp(-\frac{1}{2} (\log(x))^2) for :math:`x >= 0`. `gibrat` is a special case of `lognorm` with ``s=1``. %(after_notes)s %(example)s cgSrMrris r5rjzgibrat_gen._shape_infourr7NcJtj|j|SrMr9rs r5rzgibrat_gen._rvsxsvvl224899r7cJtj|j|SrMrrs r5rqzgibrat_gen._pdf{rr7ct|dSrr=rs r5rzgibrat_gen._logpdfsq#&&r7c>ttj|SrMr?rs r5rtzgibrat_gen._cdfs##r7c>tjt|SrMrBrs r5r}zgibrat_gen._ppfvvil##r7c>ttj|SrMrFrs r5rxzgibrat_gen._sfsq ""r7c>tjt|SrMrIrs r5rzgibrat_gen._isfrlr7ctj}tj|}||dz z}tj|dz d|zz}tjgd|}||||fSrK)rOerrL)rDrrBrCrDrEs r5rzgibrat_gen._statss^ DD WWQZ1q5k WWQU^q1u % ZZ*A .3Br7cZdtjdtjzzdzSrrris r5rzgibrat_gen._entropys#RVVAI&&,,r7r)rrrrrrrrjrrqrrtr}rxrrrrr7r5rere]sF*"44M:''$$#$-r7regibratcNeZdZdZdZd dZdZdZdZdZ d Z d Z d Z d Z y) maxwell_genaA 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 cgSrMrris r5rjzmaxwell_gen._shape_inforr7Nc2tjd||S)NrIrrrrs r5rzmaxwell_gen._rvsswwsLwAAr7cTt|z|ztj| |zdz zSr=)r&rOrrs r5rqzmaxwell_gen._pdfs*q "2661"Q$s(#333r7ctjd5tdtj|zzd|z|zz cdddS#1swYyxYw)Nr8r9rTr)rOr;r(rrs r5rzmaxwell_gen._logpdfsD [[ ) ?&266!94s1uQw> ? ? ?s (A  Ac:tjd||zdz SNrrrrs r5rtzmaxwell_gen._cdfs{{3!C((r7cZtjdtjd|zSrrrs r5r}zmaxwell_gen._ppfs!wwqQ//00r7c:tjd||zdz Sr{rrs r5rxzmaxwell_gen._sfs||C1S))r7cZtjdtjd|zSrrrs r5rzmaxwell_gen._isfs!wwqa0011r7cdtjzdz }dtjdtjz zddtjz z tjdddtjzz z|dzz dtjztjzd tjzzd z |dzz fS) Nrr-rTr rrrirOrrrDr|s r5rzmaxwell_gen._statssgai"''#bee)$$!BEE'  Br"%%xK(c1RUU2553ruu9,s2c3h>@ @r7chtdtjdtjzzzdz Sr)r#rOrrris r5rzmaxwell_gen._entropys'BFF1RUU7O++C//r7rrrr7r5rtrts;4B4? )1*2@0r7rtmaxwellc4eZdZdZdZdZdZdZdZdZ y) mielke_genaA 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 ctdddtjfd}tdddtjfd}||gS)NrFrr rrg)rDiki_ss r5rjzmielke_gen._shape_info< UQK @ea[.ACyr7cB|||dz zzd||zzd|dz|z zzz SrrrDrprrs r5rqzmielke_gen._pdfs2QsU|s1a4x3quQw;777r7ctjd5tj|tj||dz zztj||zd||z zzz cdddS#1swYyxYw)Nr8r9r)rOr;rrrs r5rzmielke_gen._logpdf sf [[ ) L66!9rvvay!a%00288AqD>1qs73KK L L Ls AA44A=c0||zd||zz|dz|z zz Srrrs r5rtzmielke_gen._cdfs&!ts1a4x1S57+++r7cPt||dz|z }t|d|z z d|z Srr8)rDr|rrqsks r5r}zmielke_gen._ppfs.!QsU1Wo3C=#a%((r7cbd}tj||k|||f|tjS)Nctj||z|z tjd||z z ztj||z z Sr]rl)rarrs r5rXz$mielke_gen._munp..nth_moments?88QqS!G$RXXa!e_4RXXac]B Br7rr)rDrarrrXs r5rzmielke_gen._munps- Cq1uq!QiOOr7N) rrrrrjrqrrtr}rrr7r5rrs( B 8L ,)Pr7rmielkecReZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zy ) kappa4_genap Kappa 4 parameter distribution. %(before_notes)s Notes ----- The probability density function for kappa4 is: .. math:: f(x, h, k) = (1 - k x)^{1/k - 1} (1 - h (1 - k x)^{1/k})^{1/h-1} if :math:`h` and :math:`k` are not equal to 0. If :math:`h` or :math:`k` are zero then the pdf can be simplified: h = 0 and k != 0:: kappa4.pdf(x, h, k) = (1.0 - k*x)**(1.0/k - 1.0)* exp(-(1.0 - k*x)**(1.0/k)) h != 0 and k = 0:: kappa4.pdf(x, h, k) = exp(-x)*(1.0 - h*exp(-x))**(1.0/h - 1.0) h = 0 and k = 0:: kappa4.pdf(x, h, k) = exp(-x)*exp(-exp(-x)) kappa4 takes :math:`h` and :math:`k` as shape parameters. The kappa4 distribution returns other distributions when certain :math:`h` and :math:`k` values are used. +------+-------------+----------------+------------------+ | h | k=0.0 | k=1.0 | -inf<=k<=inf | +======+=============+================+==================+ | -1.0 | Logistic | | Generalized | | | | | Logistic(1) | | | | | | | | logistic(x) | | | +------+-------------+----------------+------------------+ | 0.0 | Gumbel | Reverse | Generalized | | | | Exponential(2) | Extreme Value | | | | | | | | gumbel_r(x) | | genextreme(x, k) | +------+-------------+----------------+------------------+ | 1.0 | Exponential | Uniform | Generalized | | | | | Pareto | | | | | | | | expon(x) | uniform(x) | genpareto(x, -k) | +------+-------------+----------------+------------------+ (1) There are at least five generalized logistic distributions. Four are described here: https://en.wikipedia.org/wiki/Generalized_logistic_distribution The "fifth" one is the one kappa4 should match which currently isn't implemented in scipy: https://en.wikipedia.org/wiki/Talk:Generalized_logistic_distribution https://www.mathwave.com/help/easyfit/html/analyses/distributions/gen_logistic.html (2) This distribution is currently not in scipy. References ---------- J.C. Finney, "Optimization of a Skewed Logistic Distribution With Respect to the Kolmogorov-Smirnov Test", A Dissertation Submitted to the Graduate Faculty of the Louisiana State University and Agricultural and Mechanical College, (August, 2004), https://digitalcommons.lsu.edu/gradschool_dissertations/3672 J.R.M. Hosking, "The four-parameter kappa distribution". IBM J. Res. Develop. 38 (3), 25 1-258 (1994). B. Kumphon, A. Kaew-Man, P. Seenoi, "A Rainfall Distribution for the Lampao Site in the Chi River Basin, Thailand", Journal of Water Resource and Protection, vol. 4, 866-869, (2012). :doi:`10.4236/jwarp.2012.410101` C. Winchester, "On Estimation of the Four-Parameter Kappa Distribution", A Thesis Submitted to Dalhousie University, Halifax, Nova Scotia, (March 2000). http://www.nlc-bnc.ca/obj/s4/f2/dsk2/ftp01/MQ57336.pdf %(after_notes)s %(example)s cvtj||dj}tj|dS)NrTr)rOrrfull)rDrrrs r5rbzkappa4_gen._argcheck{s0##Aq)!,22wwu..r7ctddtj tjfd}tddtj tjfd}||gS)NrFr rrg)rDihrs r5rjzkappa4_gen._shape_infosI UbffWbff$5~ F UbffWbff$5~ FBxr7c  tj|dkD|dkDtj|dkD|dk(tj|dkD|dktj|dk|dkDtj|dk|dk(tj|dk|dkg}d}d}d}d}t|||||||g||gtj}d}d}t|||||||g||gtj} || fS) Nrc<dtj|| z |z Sr)rOrrrs r5rz#kappa4_gen._get_support..f0s"..QB//2 2r7c,tj|SrMr1rs r5rz#kappa4_gen._get_support..f1s66!9 r7c~tjtj|}tj |dd|SrMrOrrrhrrrs r5f3z#kappa4_gen._get_support..f3s,!%AFF7AaDHr7c d|z Srrrs r5f5z#kappa4_gen._get_support..f5 q5Lr7defaultc d|z Srrrs r5rz#kappa4_gen._get_support..f0rr7c|tjtj|}tj|dd|SrMrrs r5rz#kappa4_gen._get_support..f1s*!%A66AaDHr7rOrrr) rDrrcondlistrrrrrrs r5rzkappa4_gen._get_supportsNN1q5!a%0NN1q5!q&1NN1q5!a%0NN161q51NN16162NN161q51 3 3    b"b"b1Q!#)    b"b"b1Q!#)2v r7cNtj|j|||SrMrrDrprrs r5rqzkappa4_gen._pdfrr7c>tj|dk7|dk7tj|dk(|dk7tj|dk7|dk(tj|dk(|dk(g}d}d}d}d}t|||||g|||gtjS)Nrctjd|z dz | |ztjd|z dz | d||zz d|z zzzS)zpdf = (1.0 - k*x)**(1.0/k - 1.0)*( 1.0 - h*(1.0 - k*x)**(1.0/k))**(1.0/h-1.0) logpdf = ... rrjrprrs r5rzkappa4_gen._logpdf..f0sZ JJs1us{QBqD1JJs1us{QBac SU/C,CDE Fr7c`tjd|z dz | |zd||zz d|z zz S)z~pdf = (1.0 - k*x)**(1.0/k - 1.0)*np.exp(-( 1.0 - k*x)**(1.0/k)) logpdf = ... rrjrs r5rzkappa4_gen._logpdf..f1s9 ::c!eckA2a40C!A#IQ3GG Gr7cr| tjd|z dz | tj| zzS)z]pdf = np.exp(-x)*(1.0 - h*np.exp(-x))**(1.0/h - 1.0) logpdf = ... r)rvrvrOrrs r5f2zkappa4_gen._logpdf..f2s42 3q53;2661": >> >r7c6| tj| z S)zDpdf = np.exp(-x-np.exp(-x)) logpdf = ... rwrs r5rzkappa4_gen._logpdf..f3s2r ? "r7rr rDrprrrrrrrs r5rzkappa4_gen._logpdfsNN16162NN16162NN16162NN161624  F H ?  # 8B+q!9#%66+ +r7cNtj|j|||SrMrQrs r5rtzkappa4_gen._cdfr]r7c>tj|dk7|dk7tj|dk(|dk7tj|dk7|dk(tj|dk(|dk(g}d}d}d}d}t|||||g|||gtjS)NrcXd|z tj| d||zz d|z zzzS)zVcdf = (1.0 - h*(1.0 - k*x)**(1.0/k))**(1.0/h) logcdf = ... rrrs r5rzkappa4_gen._logcdf..f0s4E288QBac SU';$;<< .f1s1Q3Y#a%(( (r7chd|z tj| tj| zzS)zLcdf = (1.0 - h*np.exp(-x))**(1.0/h) logcdf = ... r)rvrrOrrs r5rzkappa4_gen._logcdf..f2s,E288QBrvvqbzM22 2r7c0tj|  S)zBcdf = np.exp(-np.exp(-x)) logcdf = ... rwrs r5rzkappa4_gen._logcdf..f3sFFA2J; r7rrrs r5rzkappa4_gen._logcdfsNN16162NN16162NN16162NN161624  =  )  3   8B+q!9#%66+ +r7c>tj|dk7|dk7tj|dk(|dk7tj|dk7|dk(tj|dk(|dk(g}d}d}d}d}t|||||g|||gtjS)Nrc0d|z dd||zz |z |zz zSrrr|rrs r5rzkappa4_gen._ppf..f0s(q5##A,!1A 556 6r7cFd|z dtj| |zz zSrr1rs r5rzkappa4_gen._ppf..f1s$q5#"&&)a/0 0r7cbtj||z  tj|zS)z,ppf = -np.log((1.0 - (q**h))/h) rrs r5rzkappa4_gen._ppf..f2 s)HHq!tW%%q 1 1r7cVtjtj|  SrMr1rs r5rzkappa4_gen._ppf..f3sFFBFF1I:&& &r7rr) rDr|rrrrrrrs r5r}zkappa4_gen._ppfsNN16162NN16162NN16162NN161624  7 1 2  '8B+q!9#%66+ +r7cvtj|dk|dk\|dkg}d}d}t|||g||gdS)Nrc8d|z |zjtSrDastyperrs r5rz&kappa4_gen._get_stats_info..f0sF1H$$S) )r7c2d|z jtSrDrrs r5rz&kappa4_gen._get_stats_info..f1 sF??3' 'r7rHr)rOrr)rDrrrrrs r5_get_stats_infozkappa4_gen._get_stats_infosK NN1q5!q& ) E   * (8b"X1vqAAr7c|j||}tddDcgc],}tj||krdntj.}}|ddScc}wNrrH)rrrOrr)rDrrmaxrroutputss r5rzkappa4_gen._stats%sU##Aq)AFq!MA266!d(+47MMqzNs1Ac|j|d|d}||k\rtjStj|j dd|f|zdSNrrrL)rrOrrr _mom_integ1)rDr@rFrs r5_mom1_sczkappa4_gen._mom1_sc*sR##DGT!W5 966M~~d..1A49EaHHr7N)rrrrrbrjrrqrrtrr}rrrrr7r5rr"sEWp/ 'R- $+L-!+F+2 B Ir7rkappa4cLeZdZdZdZdZdZfdZdZdZ dZ d Z xZ S) kappa3_gena*Kappa 3 parameter distribution. %(before_notes)s Notes ----- The probability density function for `kappa3` is: .. math:: f(x, a) = a (a + x^a)^{-(a + 1)/a} for :math:`x > 0` and :math:`a > 0`. `kappa3` takes ``a`` as a shape parameter for :math:`a`. References ---------- P.W. Mielke and E.S. Johnson, "Three-Parameter Kappa Distribution Maximum Likelihood and Likelihood Ratio Tests", Methods in Weather Research, 701-707, (September, 1973), :doi:`10.1175/1520-0493(1973)101<0701:TKDMLE>2.3.CO;2` B. Kumphon, "Maximum Entropy and Maximum Likelihood Estimation for the Three-Parameter Kappa Distribution", Open Journal of Statistics, vol 2, 415-419 (2012), :doi:`10.4236/ojs.2012.24050` %(after_notes)s %(example)s c@tdddtjfdgSrrgris r5rjzkappa3_gen._shape_infoUr r7c*||||zzd|z dz zzSr@rr s r5rqzkappa3_gen._pdfXs"!ad(d1fQh'''r7c$||||zzd|z zzSrDrr s r5rtzkappa3_gen._cdf\s!ad(d1f%%%r7c tj||\}}t| ||}d}||k}t j t j d||z |||||| zz }||kD}|||||<|||<|S)Ng{Gz?rA)rOrr@rxrvrrv) rDrprsfcutoffrsf2i2rs r5rxzkappa3_gen._sf_s""1a(1 W[A   Kxx 4!A$;!qtadU{0BCDD 6\Q%)B1 r7c&||| zdz z d|z zSrrrs r5r}zkappa3_gen._ppfos1qb53;3q5))r7crtj| | }tj|}||z d|z zSrrE)rDr|rlgrs r5rzkappa3_gen._isfrs6 ZZQB  E S1W%%r7ctddDcgc],}tj||krdntj.}}|ddScc}wr)rrOrr)rDrrrs r5rzkappa3_gen._statswsB>CAqkJ266!a%=4bff4JJqzKs1Actj||dk\rtjStj|j dd|f|zdSr)rOrrrrr)rDr@rFs r5rzkappa3_gen._mom1_sc{sE 66!tAw, 66M~~d..1A49EaHHr7) rrrrrjrqrtrxr}rrrrrs@r5rr4s3@E(& *& Ir7rkappa3cBeZdZdZdZd dZdZdZdZdZ d Z d Z y) moyal_genaA 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 cgSrMrris r5rjzmoyal_gen._shape_inforr7Nc`tjdd||}tj| S)NrrT)rr.rr)rrrOr)rDrrrs r5rzmoyal_gen._rvss. YYAD$02r {r7ctjd|tj| zztjdtjzz SNr(rT)rOrrrrs r5rqzmoyal_gen._pdfs:vvda"&&!*n-.2551AAAr7ctjtjd|ztjdz Sr)rvrrOrrrs r5rtzmoyal_gen._cdfs+wwrvvdQh'"''!*455r7ctjtjd|ztjdz Sr)rvr$rOrrrs r5rxz moyal_gen._sfs+vvbffTAX&344r7c`tjdtj|dzz Sr)rOrrverfcinvrs r5r}zmoyal_gen._ppfs&q2::a=!++,,,r7ctjdtjz}tjdzdz }dtjdzt j dztjdzz }d}||||fS)NrTrrO)rOr euler_gammarrrvrrAs r5rzmoyal_gen._statssg VVAY 'eeQhl "''!*_rwwqz )BEE1H 4 3Br7c|dk(r&tjdtjzS|dk(r@tjdzdz tjdtjzdzzS|dk(rdtjdzztjdtjzz}tjdtjzdz}dt j dz}||z|zS|dk(rd t j dztjdtjzz}dtjdzztjdtjzdzz}tjdtjzd z}d tjd zzd z }||z|z|zS|j |S) NrrTrrIrrrrO8r#r)rOrrrrvrr)rDratmp1rtmp3tmp4s r5rzmoyal_gen._munpsn 866!9r~~- - #X55!8a<266!9r~~#="AA A #X>RVVAYr~~%=>DFF1Ibnn,q0D ?D$;% % #XBGGAJ&"&&)bnn*DEDruuax<266!9r~~#="AADFF1I.2Druuax= 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 |dkDSr3r)rDnus r5rbznakagami_gen._argcheckrr7c@tdddtjfdgS)NrFrr rgris r5rjznakagami_gen._shape_inforr7cLtj|j||SrMrrDrprs r5rqznakagami_gen._pdf rr7ctjdtj||ztj|z tjd|zdz |z||dzzz Sr)rOrrvrwrrs r5rznakagami_gen._logpdf s\q BHHR,,rzz"~=21%&(*1a40 1r7c:tj|||z|zSrMrrs r5rtznakagami_gen._cdfs{{2r!tAv&&r7c`tjd|z tj||zSrr)rDr|rs r5r}znakagami_gen._ppfs%wws2vbnnR3344r7c:tj|||z|zSrMrrs r5rxznakagami_gen._sfs||B1Q''r7c`tjd|z tj||zSr]r)rDrrs r5rznakagami_gen._isfs%wwqtboob!4455r7c(tj|dtj|z }d||zz }|dd|z|zz zdz |z tj|dz }d|dzz|zd|zd z |d zzzd |zz dz}|||dzzz}||||fS) Nrrrr#rrr-rT)rvrrOrr)rDrrBrCrDrEs r5rznakagami_gen._statss WWR bggbk )"R%i 1qtCx< 3 & +bhhsC.@ @ AXb[AbDFBE> )!B$ . 2 bck3Br7ctj|}tj|}tj|}||dz tj |zz }dtj |ztj dz }||z|z}tjj}|dkD}|||zdd||zz z ||<|j|dS)Nrr(rTgj@rrr) rOrrrvrrrrrrrS) rDrrrqrrrGr norm_entropyrs r5rznakagami_gen._entropy&s  ]]2  JJrN "s(bjjn, , 266": q ) EAIzz**,  Htl"Q2a5\1!yy##r7NcTtj|j|||z Sr5)rOrr*)rDrrrs r5rznakagami_gen._rvs7s&ww|222D2ABFGGr7ct|tr|j}|d|jz}t j |}t j t j||z dzt|z }|||fzS)N)rrT) r>r)rnumargsrOrrrr)rDrErFr-r.s r5rznakagami_gen._fitstart;sq dL )>>#D <DLL(DffTls Q/#d);<sEl""r7rrM)rrrrrbrjrqrrtr}rxrrrrrrr7r5rrsE>F+1 '5(6$"H #r7rnakagamicJ|dz dz }tj|tj|}}tj|dz ||z d||z dzzz }tj|||zdz }t j |dkD||fdtj S)NrrrrTrc2|tj|zSrMr1)rr s r5rz_ncx2_log_pdf..WsQ]r7r)rOrrvrwiverrrh)rprrVdf2rnsrcorrs r5 _ncx2_log_pdfr Ks S&3,C WWQZB ((3s7AbD !Cb1 $4 4C 66#r"u  #D ?? q d "FF7  r7cNeZdZdZdZdZd dZdZdZdZ d Z d Z d Z d Z y)ncx2_gena A non-central chi-squared continuous random variable. %(before_notes)s Notes ----- The probability density function for `ncx2` is: .. math:: f(x, k, \lambda) = \frac{1}{2} \exp(-(\lambda+x)/2) (x/\lambda)^{(k-2)/4} I_{(k-2)/2}(\sqrt{\lambda x}) for :math:`x >= 0`, :math:`k > 0` and :math:`\lambda \ge 0`. :math:`k` specifies the degrees of freedom (denoted ``df`` in the implementation) and :math:`\lambda` is the non-centrality parameter (denoted ``nc`` in the implementation). :math:`I_\nu` denotes the modified Bessel function of first order of degree :math:`\nu` (`scipy.special.iv`). `ncx2` takes ``df`` and ``nc`` as shape parameters. This distribution uses routines from the Boost Math C++ library for the computation of the ``pdf``, ``cdf``, ``ppf``, ``sf`` and ``isf`` methods. [1]_ %(after_notes)s References ---------- .. [1] The Boost Developers. "Boost C++ Libraries". https://www.boost.org/. %(example)s cD|dkDtj|z|dk\zSr3rrDrrVs r5rbzncx2_gen._argchecks"Q"++b/)R1W55r7ctdddtjfd}tdddtjfd}||gS)NrFrr rVrfrgrDidfincs r5rjzncx2_gen._shape_infos<uq"&&k>Buq"&&k=ASzr7Nc(|j|||SrM)noncentral_chisquare)rDrrVrrs r5rz ncx2_gen._rvss00R>>r7cHtj|dk7|||ftdS)Nrc.tj||SrM)rrrpr_s r5rz"ncx2_gen._logpdf..s Q0Cr7)rrr rDrprrVs r5rzncx2_gen._logpdfs(rQwB ]CE Er7ctjd5tj|dk7|||ftj dcdddS#1swYyxYw)Nr8rprc.tj||SrM)rrqr s r5rzncx2_gen._pdf..DIIa4Dr7)rOr;rrrm _ncx2_pdfr s r5rqz ncx2_gen._pdfK [[h ' F??27QBK#DF F F F -AActjd5tj|dk7|||ftj dcdddS#1swYyxYw)Nr8rprc.tj||SrM)rrtr s r5rzncx2_gen._cdf..r r7)rOr;rrrm _ncx2_cdfr s r5rtz ncx2_gen._cdfr" r# ctjd5tj|dk7|||ftj dcdddS#1swYyxYw)Nr8rprc.tj||SrM)rr}r s r5rzncx2_gen._ppf..r r7)rOr;rrrm _ncx2_ppfrDr|rrVs r5r}z ncx2_gen._ppfr" r# ctjd5tj|dk7|||ftj dcdddS#1swYyxYw)Nr8rprc.tj||SrM)rrxr s r5rzncx2_gen._sf..sDHHQOr7)rOr;rrrm_ncx2_sfr s r5rxz ncx2_gen._sfsK [[h ' E??27QBK#CE E E Er# ctjd5tj|dk7|||ftj dcdddS#1swYyxYw)Nr8rprc.tj||SrM)rrr s r5rzncx2_gen._isf..r r7)rOr;rrrm _ncx2_isfr s r5rz ncx2_gen._isfr" r# c||z}d}d|||dz}tjd|||dztj|||ddzz }d|||dz|||ddzz }||||fS)Nc|||zzSrMr)rrr s r5 k_plus_clz"ncx2_gen._stats..k_plus_clsqs7Nr7rr rrrOrTr)rDrrV _ncx2_meanr3 _ncx2_variance_ncx2_skewness_ncx2_kurtosis_excesss r5rzncx2_gen._statss"W   "b# 66''#,2r1)=='')BC"8!";<=!% "b#(>!>!*2r3!7!:";    !   r7r)rrrrrbrjrrrqrtr}rxrrrr7r5r r [s@"F6 ?EF F F E F  r7r ncx2cJeZdZdZdZdZd dZdZdZdZ d Z d Z d d Z y)ncf_gena2A 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$|dkD|dkDz|dk\zSr3r)rDrrrVs r5rbzncf_gen._argchecksaC!G$a00r7ctdddtjfd}tdddtjfd}tdddtjfd}|||gS)NrFrr rrVrfrg)rDidf1idf2r s r5rjzncf_gen._shape_infosW%BFF ^D%BFF ^Duq"&&k=AdC  r7Nc*|j||||SrM) noncentral_f)rDrrrVrrs r5rz ncf_gen._rvss((c2t< 0`. :math:`\Gamma` is the gamma function (`scipy.special.gamma`). %(after_notes)s %(example)s c@tdddtjfdgSrrgris r5rjzt_gen._shape_info=rr7Nc(|j||Sr5) standard_trs r5rz t_gen._rvs@s&&r&55r7cbtj|tjk(||fdfdS)Nc,tj|SrM)rrqrprs r5rzt_gen._pdf..Fs$))A,r7cNtjj||SrMr)rprrDs r5rzt_gen._pdf..Gs"&&a!45r7rrs` r5rqz t_gen._pdfCs+ "&&L1b' & 57 7r7cdd}d}tj|tjk(||f||S)Nctjtjd|zddtj|tjtjzzz |dzdz tj ||z|z zz SrN)rOrrvrrrr[ s r5t_logpdfzt_gen._logpdf..t_logpdfKsnFF27738S12RVVBZ"&&-789Avqj!a%(!334 5r7c,tj|SrM)rrr[ s r5 norm_logpdfz"t_gen._logpdf..norm_logpdfPs<<? "r7r)rDrprr_ ra s r5rz t_gen._logpdfIs/ 5  #rRVV|aWk8LLr7c.tj||SrMrvstdtrrs r5rtz t_gen._cdfUrr7c0tj|| SrMrc rs r5rxz t_gen._sfXsxxQBr7c.tj||SrMrvstdtritrs r5r}z t_gen._ppf[szz"a  r7c0tj|| SrMrg rs r5rz t_gen._isf^s 2q!!!r7ctj|}tj|dkDdtj}|dkD|dkz|dkDtj|z|f}dddf}t |||ftj }tj|dkDdtj }|dkD|dkz|dkDtj|z|f}d d d f}t |||ftj }||||fS) NrrrTc^tjtj|jSrMrO broadcast_torhrrs r5rzt_gen._stats..j!Br7c||dz z Sr=rrs r5rzt_gen._stats..ksr#vr7cBtjd|jSr]rOrm rrs r5rzt_gen._stats..lBHH!=r7rr#c^tjtj|jSrMrl rs r5rzt_gen._stats..trn r7cd|dz z S)NrrOrrs r5rzt_gen._stats..us3r7cBtjd|jSr3rq rs r5rzt_gen._stats..vrr r7)rOisposinfrTrhrrr) rDr infinite_dfrBr choicelistrCrDrEs r5rz t_gen._statsaskk"o XXb1fc266 *!Va(!Vr{{2.!C.=? (Jrvv> XXb1fc266 *!Va(!Vr{{2.!C/=? :ubff =3Br7c|tjk(rtjSd}d}t j |dk\|||S)Nc|dz }|dzdz }|tj|tj|z ztjtj|tj |dzzSrI)rvrrOrrrm)rhalfhalf1s r5rzt_gen._entropy..regularsea4D!VQJE2::e,rzz$/??@ffRWWR[s);;<= >r7ctjd|z z|dzdz z|dzdz z |dzdz z d|d zzz|d zdz z}|S) Nrrr#rrrr-g333333?rr)rr)rrs r5rtz"t_gen._entropy..asymptoticsg1R4'2s7A+5S! CGQ;!%r3w035s7A+>AHr7d)rOrhrrrr)rDrrrts r5rzt_gen._entropy{s> <==? " >  rSy"j'BBr7rrrr7r5rU rU s<<F67 M !"4Cr7rU rcJeZdZdZdZdZd dZdZdZdZ d Z d Z d d Z y)nct_genaA 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|dkD||k(zSr3rr s r5rbznct_gen._argchecksQ28$$r7ctdddtjfd}tddtj tjfd}||gS)NrFrr rVrgr s r5rjznct_gen._shape_infosCuq"&&k>Buw&7HSzr7Nctj|||}tj|||}|tj|ztj|z S)Nrr)rrrrOr)rDrrVrrrars r5rz nct_gen._rvssI HH$\H B XXbt,X ?2772;,,r7c0tj|||SrM)rm_nct_pdfr s r5rqz nct_gen._pdfs||Ar2&&r7c0tj|||SrM)rvnctdtrr s r5rtz nct_gen._cdfsyyR##r7c0tj|||SrM)rvnctdtritr* s r5r}z nct_gen._ppfs{{2r1%%r7ctjd5tjtj|||ddcdddS#1swYyxYw)Nr8rprr)rOr;cliprm_nct_sfr s r5rxz nct_gen._sfs@ [[h ' 9773;;q"b11a8 9 9 9s ,A  Actjd5tj|||cdddS#1swYyxYwro)rOr;rm_nct_isfr s r5rz nct_gen._isfs3 [[h ' +<<2r* + + +rtctj||}tj||}d|vrtj||nd}d|vrtj||nd}||||fS)Nrr)rm _nct_mean _nct_variance _nct_skewness_nct_kurtosis_excess)rDrrVrrBrCrDrEs r5rznct_gen._statssf ]]2r "B'*-.S  r2 &d14S % %b" -T3Br7rrrR rr7r5r r s5@% - '$&9+r7r nctcteZdZdZdZdZdZdZdZdZ d dZ d Z e e efd ZxZS) pareto_genaLA 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@tdddtjfdgSrrgris r5rjzpareto_gen._shape_infor r7c||| dz zzSr]rrs r5rqzpareto_gen._pdfs1r!t9}r7cd|| zz Sr]rrs r5rtzpareto_gen._cdfs1r7{r7c&td|z d|z S)NrrAr8rs r5r}zpareto_gen._ppfs1Q3Qr7c|| zSrMrrs r5rxzpareto_gen._sf s A2wr7c4tj|d|z SrDrrs r5rzpareto_gen._isf sxx4!8$$r7cd\}}}}d|vrp|dkD}tj||}tjtj|tj}tj ||||dz z d|vry|dkD}tj||}tjtj|tj}tj ||||dz z |dz dzz d |vr|d kD}tj||}tjtj|tj }d|dzztj|dz z|d z tj|zz } tj ||| d |vr|d kD}tj||}tjtj|tj }dtjgd|ztjgd|z } tj ||| ||||fS)Nrr@rrrrrTrrrrIrr#r)rrr r)rgrr) rOextractrrrhplacerrrL) rDrrrBrCrDrEmaskbtrs r5rzpareto_gen._stats s0CR '>q5DD!$B!8B HHRrRV} - '>q5DD!$B''"((1+"&&9C HHS$bf C! ; < '>q5DD!$B!8BS>BGGBH$55"s(bggbk9QRD HHRt $ '>q5DD!$B!8B #5r::JJ5r:;D HHRt $3Br7c>dd|z ztj|z Srr1rDrs r5rzpareto_gen._entropy! 3q5y266!9$$r7ct|||}|\}}|;tj|z |xsdkrtddtjj dfd||cxur9nn5fdfdfdfd }t |jd d}|d z |d z} } || | sE| dkDs| tjkr-| d z} | d z} || | s| dkDr| tjkr-t| | g } | jr| j} tj| z } xs | | }| | ztjks.tj| z } tj| d} || | fSt|4fi|S|tj|z } n|} |xstj| z } xs | | }|| | fS) Nrparetorrcftjtj|z |z z SrMrU)r.locationrEndatas r5 get_shapez!pareto_gen.fit..get_shape1 s+266"&&$/U)B"CDD Dr7c|z|z SrMr)rr.r s r5 dL_dScalez!pareto_gen.fit..dL_dScale< su}u,,r7cF|dztjd|z z zSr]r!)rr rEs r5 dL_dLocationz$pareto_gen.fit..dL_dLocationA s& RVVA,A%BBBr7cttj|z }xs ||}||||z SrM)rOr)r.r rr r rErRr s r5r$z$pareto_gen.fit..fun_to_solveF sA66$<%/<)E8"<#E84y7NNNr7crtj|tj|k7SrMrNrQrRr$s r5rSz.pareto_gen.fit..interval_contains_rootM s/ V 45 V 4567r7r.rTr%)rKrOrrJrhrrTr<r*r^rLr]r@rB)rDrErFr4r_rrrSrrQrRrr.r-rr r rRr$r r rs ` @@@@@@r5rBzpareto_gen.fit$ s1tT4H %/"fdF  t t 3v{ Cxq? ? 1  E 6 ! !  -  C  O O 7 ! 45K(1_kAoFF.ff= frvvo! ! .ff= frvvolVV4DEC}}ffTlU*7)E3"7 rvvd|3FF4L3.ELL2Ec5((w{40400 \&&,'CC,"&&,,/)E3/c5  r7r)rrrrrjrqrtr}rxrrrrJr rrBrrs@r5r r sT*E %6%M*R!+R!r7r r cLeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z y ) lomax_genaA 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@tdddtjfdgSr rgris r5rjzlomax_gen._shape_info r r7c$|dzd|z|dzzz Srrrs r5rqzlomax_gen._pdf suc!equ%%%r7cdtj||dztj|zz Sr]rrs r5rzlomax_gen._logpdf s&vvayAaC!,,,r7c\tj| tj|z SrMrrs r5rtzlomax_gen._cdf s"!BHHQK(((r7cZtj| tj|zSrM)rOrrvrrs r5rxz lomax_gen._sf svvqb!n%%r7c4| tj|zSrMrrs r5rzlomax_gen._logsf sr"((1+~r7c\tjtj|  |z SrMrrs r5r}zlomax_gen._ppf s!xx1" a((r7c|d|z zdz Sr@rrs r5rzlomax_gen._isf s4!8}q  r7cHtj|dd\}}}}||||fS)NrAr)r-r)r rrs r5rzlomax_gen._stats s, ,,qdF,CCR3Br7c>dd|z ztj|z Srr1rs r5rzlomax_gen._entropy sQwrvvay  r7N)rrrrrjrqrrtrxrr}rrrrr7r5r r ~ s:.E&-)&)!!r7r lomaxceZdZdZdZdZdZdZdZdZ dZ d Z dd Z d Z eeed fdZxZS) pearson3_genaA 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). cd}d}d}tjd||\}}}|j}tj||k}|}d|||zz } || zdz} || | z z } | ||| z z} ||| ||| | | fS)Nrrg>rrT)rOrrr) rDrprEr-r.norm2pearson_transitionansr invmaskrmrrtransxs r5 _preprocesszpearson3_gen._preprocess s  #+**348 Qhhj{{4 #::%d7me+,!UT\!7d*+AvtWdE4??r7c,tj|SrMr)rDrEs r5rbzpearson3_gen._argcheck!s {{4  r7c^tddtj tjfdgS)NrEFr rgris r5rjzpearson3_gen._shape_info !s%65BFF7BFF*;^LMMr7c*d}d}|}d|dzz}||||fS)NrrrrTr)rDrEr@rrrs r5rzpearson3_gen._stats!s,    aK!Qzr7ctj|j||}|jdk(rtj|ry|Sd|tj|<|S)Nrr)rOrrr0r)rDrprEr s r5rqzpearson3_gen._pdf!sR ffT\\!T*+ 88q=xx}J BHHSM r7c|j||\}}}}}}}} tjt||||<tjt |t j ||z||<|SrM)r rOrrrrr) rDrprEr r r r rmrr s r5rzpearson3_gen._logpdf"!ss   Q % 6QgtUAFF9QtW-.D vvc$i(5<<+FFG  r7c|j||\}}}}}}}}t||||<tj||j}tj ||dkD} ||dkD} t j|| || || <tj ||dk} ||dk} t j|| || || <|Sr3) r rrOrm rrrrr rDrprEr r r r r r invmask1a invmask1b invmask2a invmask2bs r5rtzpearson3_gen._cdf1!s   Q % 3Qgq%ag&D tW]]3NN7D1H5 MA% 6)#4eI6FGI NN7D1H5 MA% &"3U95EFI r7c|j||\}}}}}}}}t||||<tj||j}tj ||dkD} ||dkD} t j|| || || <tj ||dk} ||dk} t j|| || || <|Sr3) r rrOrm rrrrrr s r5rxzpearson3_gen._sfI!s   Q % 3Qgq%QtW%D tW]]3NN7D1H5 MA% &"3U95EFINN7D1H5 MA% 6)#4eI6FGI r7ctj||}|jdg|\}}}}}}} } |j} |j| z } |j | ||<|j | | |z | z||<|dk(r|d}|S)Nrr)rOrm r rrrr*) rDrErrr r r r rmrrnsmallnbigs r5rzpearson3_gen._rvsZ!stT*   aS$ ' 4Q4$tyy6! 008D #225$?DtKG 2:a&C r7c|j||\}}}}}}}} t||||<||}d||dkz ||dk<tj|||z | z||<|Sr)r rrvr) rDr|rEr r r r rmrrs r5r}zpearson3_gen._ppfh!s~   Q % 4Q4$tag&D gJ!D1H+o$( ~~eQ/4t;G  r7ze Note that method of moments (`method='MM'`) is not available for this distribution. rc||jdddk(r tdtt|||g|i|S)Nr0MMzhFit `method='MM'` is not available for the Pearson3 distribution. Please try the default `method='MLE'`.)r<NotImplementedErrorr@rArBrTs r5rBzpearson3_gen.fitq!sO 88Hd #t +%'DE EdT.tCdCdC Cr7r)rrrrr rbrjrrqrrtrxrr}rJr rrBrrs@r5r r sg,Z@8!N  0" }501D1Dr7r pearson3ceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z fd Zeeed fdZxZS) powerlaw_genaA 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@tdddtjfdgSrrgris r5rjzpowerlaw_gen._shape_info!r r7c|||dz zzSrrr s r5rqzpowerlaw_gen._pdf!sQsU|r7c`tj|tj|dz |zSr])rOrrvrwr s r5rzpowerlaw_gen._logpdf!s$vvay288AE1---r7c||dzzSrrr s r5rtzpowerlaw_gen._cdf!s1S5zr7c2|tj|zSrMr1r s r5rzpowerlaw_gen._logcdf!r2r7c t|d|z Srr8rs r5r}zpowerlaw_gen._ppf!s1c!e}r7c0tj|| SrM)rvr)rDrrs r5rxzpowerlaw_gen._sf!sAr7c|||zz SrMrr5s r5rzpowerlaw_gen._munp!sAE{r7c||dzz ||dzz |dzdzz d|dz |dzz ztj|dz|z zdtjgd|z||dzz|dzzz fS) NrrrTrrIr)rrr rTr#)rOrrLrs r5rzpowerlaw_gen._stats!sQW QW SQ.SQW-.!c'Q1GGBJJ~q11Q!c']a!e5LMO Or7c>dd|z z tj|z Srr1rs r5rzpowerlaw_gen._entropy!r r7c<t||||dk7|dk\zzSr)r@r)rDrprrs r5rzpowerlaw_gen._support_mask!s,%a+FqAv&( )r7a: 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. rcR|jddrt|g|i|Stt j dk(rt|g|i|St |||\}}|jfg}|j|id}|Ej|kDs tddd|#j||zks tddd|5|dkr td|t jkr d}t|dd || ||||fS|t jjtj } xs | |} || | |f} t jj|z tj} xs | |} || | |f}| |kr| | |fS| | |fS||}xs ||}|||fSfd }d d fd fdfd} dkr|S dkDr|S|}|j!|} |}|j!|}| |kr |ddkr|S| |kDr |ddkDr|St|g|i|S)Nr?FrpowerlawrzKNegative or zero `fscale` is outside the range allowed by the distribution.z0`fscale` must be greater than the range of data.ct|}| tjtj||z |tj|zz z SrM)rrOrr)rEr-r.rs r5r z#powerlaw_gen.fit..get_shape "sAD A3"&&s !34qFG Gr7c(|j|z SrM)r)rEr-s r5 get_scalez#powerlaw_gen.fit..get_scale"s88:# #r7ctjjtj }tj|tj |j jkr?tj|tj |j jz}tj|tj}xs ||}|||fSrM) rOr]rrhrr'r r(rP)r-r.rrErRr r s r5fit_loc_scale_w_shape_lt_1z4powerlaw_gen.fit..fit_loc_scale_w_shape_lt_1;"s,,txxzBFF73Cvvc{RXXcii0555ggclRXXcii%8%=%==LL4!5rvv>E9ic59E#u$ $r7c.|jd |z|z Sr3)r)rErr.s r5r z#powerlaw_gen.fit..dL_dScaleJ"sJJqM>E)E1 1r7cD|dz tjd||z z zSr]r!)rErr-s r5r z&powerlaw_gen.fit..dL_dLocationO"s%AIS4Z(8!99 9r7ctj|tj }xs ||}||SrMrOr]rh)r-r.rr rErRr r s r5dL_dLocation_starz+powerlaw_gen.fit..dL_dLocation_starT"sDLL4!5w?E9ic59EeS1 1r7ctj|tj }xs ||}||||z SrMr ) r-r.rr r rErRr r s r5r$z&powerlaw_gen.fit..fun_to_solve["sWLL4!5w?E9ic59EdE51"445 6r7ctj jtj } j|z } |dkDr$ j|z }|dz} |dkDr$ fd}|dz }d}|||sJ|tj k7r6 j|z }|dz}|||s|tj k7r6t j ||f}tj|j tj }tj |tj} xs  ||}|||fS)NrrTcrtj|tj|k7SrMrNr s r5rSzTpowerlaw_gen.fit..fit_loc_scale_w_shape_gt_1..interval_contains_rooto"s/ V 4577<#789:r7rrr%)rOr]rrhr r*rL)rRr)rSrQrrLr-r.rr rErRr$r r s r5fit_loc_scale_w_shape_gt_1z4powerlaw_gen.fit..fit_loc_scale_w_shape_gt_1c"s7\\$((*rvvg6FXXZ&(E#F+a/e+ $F+a/ : aZF A-ff="&&(((*q.Q.ff="&&('' vv>NOD,,tyy266'2CLL4!5rvv>E9ic59E#u$ $r7)r2r@rBrrOuniquerKr _reduce_funcrrJrrptpr]rhrY)rDrErFr4rrpenalized_nllf_argspenalized_nllfrXloc_lt1 shape_lt1ll_lt1loc_gt1 shape_gt1ll_gt1r.rr r fit_shape_lt1 fit_shape_gt1r r r rRr$r r rs ` @@@@@@@r5rBzpowerlaw_gen.fit!s P 88J &7;t3d3d3 3 ryy 1 $7;t3d3d3 3%@tAEt&M"fdF#dnnT&:%<=**+>CAF  88:$":q!44!$((*v *E":q!44  { "FGG%H o% H $  $"2T40$> >  ll488:w7GB)D'6"BI#Y$@$GFll488:#6?GB)D'6"BI#Y$@$GF '611 '611  dD)E:idE:E$% %  % 2  :  2 2 6 6! %! %H  &A+-/ /  FQJ-/ /34 =$/24 =$/ V  a 0A 5 f_q!1A!5 7;t3d3d3 3r7)rrrrrjrqrrtrr}rxrrrrrJr rrBrrs@r5r r !sl@E.O %)}5 H4 H4r7r r cXeZdZdZej ZdZdZdZ dZ dZ dZ dZ d Zy ) powerlognorm_genaA 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 ctdddtjfd}tdddtjfd}||gS)Nr Frr rrg)rDr'rs r5rjzpowerlognorm_gen._shape_info"rr7cNtj|j|||SrMrrDrpr rs r5rqzpowerlognorm_gen._pdf"r]r7ctj|tj|z tj|z ttj||z zttj| |z |dz zzSrrOrrrr s r5rzpowerlognorm_gen._logpdf"siq BFF1I%q 1RVVAY]+,bffQiZ!^,B78 9r7cPtj|j||| SrMrer s r5rtzpowerlognorm_gen._cdf"rfr7c.|jd|z ||Sr])rrDr|r rs r5r}zpowerlognorm_gen._ppf"syyQ1%%r7cNtj|j|||SrMr;r s r5rxzpowerlognorm_gen._sf"r<r7cLttj| |z |zSrMrr s r5rzpowerlognorm_gen._logsf"s RVVAYJN+a//r7cRtjt|d|z z |zSr]rBr s r5rzpowerlognorm_gen._isf"s&vvyQqS**Q.//r7N)rrrrrrrrjrqrrtr}rxrrrr7r5r r "s<."44M -9 /&,00r7r powerlognormc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) powernorm_genahA 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@tdddtjfdgSr rgris r5rjzpowernorm_gen._shape_info"r r7cD|t|zt| |dz zzSrrrrs r5rqzpowernorm_gen._pdf"s$1~A23!788r7cjtj|t|z|dz t| zzSr]r rs r5rzpowernorm_gen._logpdf"s.vvay<?*ac<3C-CCCr7cNtj|j|| SrMrers r5rtzpowernorm_gen._cdf"sQ*+++r7c:ttd|z d|z  Sr)rrrs r5r}zpowernorm_gen._ppf#s#cAgsQw/000r7cLtj|j||SrMr;rs r5rxzpowernorm_gen._sf#r6r7c |t| zSrMrrs r5rzpowernorm_gen._logsf#s<###r7clttjtj||z  SrM)rrOrrrs r5rzpowernorm_gen._isf #s%"&&Q/000r7N) rrrrrjrqrrtr}rxrrrr7r5r r "s16E9D,1)$1r7r powernormcBeZdZdZdZdZdZdZdZdZ d d Z d Z y) rdist_gena/An R-distributed (symmetric beta) continuous random variable. %(before_notes)s Notes ----- The probability density function for `rdist` is: .. math:: f(x, c) = \frac{(1-x^2)^{c/2-1}}{B(1/2, c/2)} for :math:`-1 \le x \le 1`, :math:`c > 0`. `rdist` is also called the symmetric beta distribution: if B has a `beta` distribution with parameters (c/2, c/2), then X = 2*B - 1 follows a R-distribution with parameter c. `rdist` takes ``c`` as a shape parameter for :math:`c`. This distribution includes the following distribution kernels as special cases:: c = 2: uniform c = 3: `semicircular` c = 4: Epanechnikov (parabolic) c = 6: quartic (biweight) c = 8: triweight %(after_notes)s %(example)s c@tdddtjfdgSr rgris r5rjzrdist_gen._shape_info3#r r7cLtj|j||SrMrrs r5rqzrdist_gen._pdf7#rr7cvtjd tj|dzdz |dz |dz zSr)rOrrmrrs r5rzrdist_gen._logpdf:#s4q zDLL!a%AaC1===r7cHtj|dzdz |dz |dz Sr0rrs r5rtzrdist_gen._cdf=#s%yy!a%AaC1--r7cHtj|dzdz |dz |dz Sr0rrs r5rxz rdist_gen._sf@#s%xxQ 1Q3!,,r7cHdtj||dz |dz zdz Sr)rmr}rs r5r}zrdist_gen._ppfC#s'1ac1Q3''!++r7Nc@d|j|dz |dz |zdz Srrlrs r5rzrdist_gen._rvsF#s)<$$QqS!A#t44q88r7cd|dzz tj|dzdz |dz z}|tjd|dz z S)NrrTrrrrY)rDrar  numerators r5rzrdist_gen._munpI#sE!a%[BGGQWM1s7$CC 27761r6222r7r) rrrrrjrqrrtrxr}rrrr7r5r r #s1 BE*>.-,93r7r rArdistceZdZdZej ZdZddZdZ dZ dZ dZ dZ d Zd Zd Zd Zeeed fdZxZS) rayleigh_gena7A 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 cgSrMrris r5rjzrayleigh_gen._shape_infoi#rr7c2tjd||S)NrTrrwrs r5rzrayleigh_gen._rvsl#swwqt,w??r7cJtj|j|SrMrrDrs r5rqzrayleigh_gen._pdfo#rr7c>tj|d|z|zz Srr1r0 s r5rzrayleigh_gen._logpdfs#svvay37Q;&&r7c:tjd|dzz Srr{r0 s r5rtzrayleigh_gen._cdfv#s1%%%r7cZtjdtj| zSNr)rOrrvrrs r5r}zrayleigh_gen._ppfy#s wwrBHHaRL())r7cJtj|j|SrMr;r0 s r5rxzrayleigh_gen._sf|#svvdkk!n%%r7cd|z|zS)Nr(rr0 s r5rzrayleigh_gen._logsf#sax!|r7cXtjdtj|zSr4 )rOrrrs r5rzrayleigh_gen._isf#swwrBFF1I~&&r7c8dtjz }tjtjdz |dz dtjdz ztjtjz|dzz dtjz|z d|dzz z fS)Nr#rTrrrr+rrs r5rzrayleigh_gen._stats#sy"%%ia A2557 BGGBEEN*383"%% BsAvI%' 'r7cLtdz dzdtjdzz S)NrrrrTr<ris r5rzrayleigh_gen._entropy#s!czA~BFF1I --r7a 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. rc|jddrt|g|i|St|||\}}fd}fd}|ffd }|At j |z dkrt ddtj |||fS|jd } | |jd} ||n|} t jt jtj } t| | } tj| | | f } | jst!| j"| j$}|xs||}||fS) Nr?Fc^tj|z dzdtzz dzSr)rOrr)r-rEs r5 scale_mlez#rayleigh_gen.fit..scale_mle#s/FFD3J1,-SY?BF Fr7c|z }|j}|dzj}d|z j}||dtzz |zz Sr)rr)r-r'r[ras3rEs r5loc_mlez!rayleigh_gen.fit..loc_mle#sTBBa%BB$BAc$iK(++ +r7cb|z }|j|dzd|z jzz Sr)r)r-r.r'rEs r5loc_mle_scale_fixedz-rayleigh_gen.fit..loc_mle_scale_fixed#s2B668eQh!B$55 5r7rrayleighrrr-r%)r2r@rBrKrOrrJrhr<rr]rrYr r*r^rVflagrL)rDrErFr4rrr< r? rA loc0rHrRrQrr-r.rs ` r5rBzrayleigh_gen.fit#sF 88J &7;t3d3d3 38t9=tEdF G  ,,2 6  vvdTkQ&'":QbffEEYt_,,xx <>>$'*Dg-@bffTlRVVG4"3/""30@A}} * *hh()C.Ezr7r)rrrrrrrrjrrqrrtr}rxrrrrrJr rBrrs@r5r, r, Q#su*"44M@''&*&''.}5.////r7r, rB ceZdZdZdZdZfdZdZdZdZ dZ d Z d Z d Z d Zeee fdZxZS)reciprocal_gena,A loguniform or reciprocal continuous random variable. %(before_notes)s Notes ----- The probability density function for this class is: .. math:: f(x, a, b) = \frac{1}{x \log(b/a)} for :math:`a \le x \le b`, :math:`b > a > 0`. This class takes :math:`a` and :math:`b` as shape parameters. %(after_notes)s %(example)s This doesn't show the equal probability of ``0.01``, ``0.1`` and ``1``. This is best when the x-axis is log-scaled: >>> import numpy as np >>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots(1, 1) >>> ax.hist(np.log10(r)) >>> ax.set_ylabel("Frequency") >>> ax.set_xlabel("Value of random variable") >>> ax.xaxis.set_major_locator(plt.FixedLocator([-2, -1, 0])) >>> ticks = ["$10^{{ {} }}$".format(i) for i in [-2, -1, 0]] >>> ax.set_xticklabels(ticks) # doctest: +SKIP >>> plt.show() This random variable will be log-uniform regardless of the base chosen for ``a`` and ``b``. Let's specify with base ``2`` instead: >>> rvs = %(name)s(2**-2, 2**0).rvs(size=1000) Values of ``1/4``, ``1/2`` and ``1`` are equally likely with this random variable. Here's the histogram: >>> fig, ax = plt.subplots(1, 1) >>> ax.hist(np.log2(rvs)) >>> ax.set_ylabel("Frequency") >>> ax.set_xlabel("Value of random variable") >>> ax.xaxis.set_major_locator(plt.FixedLocator([-2, -1, 0])) >>> ticks = ["$2^{{ {} }}$".format(i) for i in [-2, -1, 0]] >>> ax.set_xticklabels(ticks) # doctest: +SKIP >>> plt.show() c|dkD||kDzSr3rrs r5rbzreciprocal_gen._argcheck$A!a%  r7ctdddtjfd}tdddtjfd}||gSrfrgrgs r5rjzreciprocal_gen._shape_info$rjr7ct|tr|j}t||t j |t j|fSNrLr>r)rr@rrOrrrXs r5rzreciprocal_gen._fitstart $sC dL )>>#Dw RVVD\266$<,H IIr7c ||fSrMrrs r5rzreciprocal_gen._get_support$rZr7cNtj|j|||SrMrrss r5rqzreciprocal_gen._pdf$rr7ctj| tjtj|tj|z z SrMr1rss r5rzreciprocal_gen._logpdf$s5q zBFF266!9rvvay#8999r7ctj|tj|z tj|tj|z z SrMr1rss r5rtzreciprocal_gen._cdf$s7q "&&)#q BFF1I(=>>r7ctjtj||tj|tj|z zzSrMrOrrrs r5r}zreciprocal_gen._ppf$s8vvbffQi!RVVAY%:";;<$>v>>>r7)rrrrrbrjrrrqrrtr}rrfit_noter rrBrrs@r5rF rF #s`2f! J -:?=KLH}H=?>?r7rF loguniform reciprocalc<eZdZdZdZdZd dZdZdZdZ d Z y) rice_genaA 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 |dk\Sr3rr s r5rbzrice_gen._argcheckZ$rr7c@tdddtjfdgS)NrFrrfrgris r5rjzrice_gen._shape_info]$rr7Nc|tjdz |jd|zz}tj||zjdS)NrT)rTrrr)rOrrr)rDrrrrs r5rz rice_gen._rvs`$sH bggajL<77TD[7I Iww!yyay())r7c|tjtj|dtj|Sr)rvchndtrrOr&rs r5rtz rice_gen._cdfe$s%yy1q"))A,77r7c |tjtj|dtj|Sr)rOrrvchndtrixr&rs r5r}z rice_gen._ppfh$s&wwr{{1a1677r7c~|tj||z ||z zdz ztj||zzSr=)rOrrvi0ers r5rqz rice_gen._pdfk$s<266AaC&!A#,s*++bffQqSk99r7c|dz }d|z}||zdz }d|ztj| ztj|ztj|d|zSr)rOrrvrhyp1f1)rDrarnd2n1rs r5rzrice_gen._munpt$s^e W qSWc RVVRC[(288B<7 "a$% &r7r) rrrrrbrjrrtr}rqrrr7r5r[ r[ =$s+8D* 88:&r7r[ ricecxeZdZdZeeddZdZdZdZ dZ e d Z d Z d Zd ZddZdZy ) irwinhall_gena\ An Irwin-Hall (Uniform Sum) continuous random variable. An `Irwin-Hall `_ 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 `_, 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`. rcd}t|)NzThe generic `fit` implementation is unreliable for this distribution, and no custom implementation is available. Consider using `scipy.stats.fit`.)r )rDrErFr4 fit_notess r5rBzirwinhall_gen.fit$s 9 "),,r7cP|dkDt|ztj|zSr3)rrO isrealobjr`s r5rbzirwinhall_gen._argcheck$s"AQ'",,q/99r7c d|fSr3rr`s r5rzirwinhall_gen._get_support$rZr7c@tdddtjfdgSrergris r5rjzirwinhall_gen._shape_info$rkr7cbd}tj|tjg||S)Nctj|tj}tj||z|dtj ||z|dz S)Nr T)exact)rOrint64rv stirling2r)r_ras r5vmunpz"irwinhall_gen._munp..vmunp$sH 1BHH-ALL5!48ggagq56 7r7rr)rDr_rarw s r5rzirwinhall_gen._munp$s) 7 8r||E2::,7qAAr7c\tj|dz}tj|Sr])rOrRr basis_element)rars r5 _cardbsplzirwinhall_gen._cardbspl$s$ IIacN$$Q''r7chfd}tj|tjg||S)Nc2j||SrM)rz rprarDs r5vpdfz irwinhall_gen._pdf..vpdf$s$4>>!$Q' 'r7rr)rDrprar~ s` r5rqzirwinhall_gen._pdf$s( (6r||D"**6q!<.vcdf$s"54>>!$335a8 8r7rr)rDrprar s` r5rtzirwinhall_gen._cdf$s( 96r||D"**6q!<.vsf$s&54>>!$335ac: :r7rr)rDrprar s` r5rxzirwinhall_gen._sf$s( ;5r||C 5a;;r7Nc2tdd}||||S)Nctj|jt}||fn|g|}|j |j dS)Nrrr)rOrrrrr)rarrusizes r5_rvs1z!irwinhall_gen._rvs.._rvs1$sO ""3'A LQDqj4jE''U'377Q7? ?r7rr)r)rDrarrrFr s r5rzirwinhall_gen._rvs$s' # @ $ @QT ==r7c&|dz |dz ddd|zz fS)NrTrrr rHrr`s r5rzirwinhall_gen._stats$s#sAbD!R1X%%r7r)rrrrr rrBrbrrjrrrz rqrtrxrrrr7r5rk rk ~$sm5n 6?@- @- :C B((= = < > &r7rk irwinhall)rrac6eZdZdZdZdZdZdZdZd dZ y) recipinvgauss_genaA 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@tdddtjfdgSrrgris r5rjzrecipinvgauss_gen._shape_info%rr7cLtj|j||SrMrrs r5rqzrecipinvgauss_gen._pdf%svvdll1b)**r7c^tj|dkD||fdtj S)Nrcd||zz dz d|z|dzzz dtjdtjz|zzz S)NrrrTrr)rprBs r5rz+recipinvgauss_gen._logpdf..$%sHQAXO+qs2s7{; "%% !223r7rrrs r5rzrecipinvgauss_gen._logpdf!%s. EAr7 4w   r7cd|z |z }d|z |z}dtj|z }t| |ztjd|z t| |zzz SNrrrOrrrrDrprBtrm1trm2isqxs r5rtzrecipinvgauss_gen._cdf(%s_2vz2vz2771:~$t$rvvc"f~id 6K'KKKr7cd|z |z }d|z |z}dtj|z }t||ztjd|z t| |zzzSr r r s r5rxzrecipinvgauss_gen._sf.%s]2vz2vz2771:~d#bffSVnYuTz5J&JJJr7Nc0d|j|d|z Srrrs r5rzrecipinvgauss_gen._rvs4%s<$$R4$888r7r) rrrrrjrqrrtrxrrr7r5r r %s(,F+  L K 9r7r recipinvgausscBeZdZdZdZdZdZdZdZd dZ d Z d Z y) semicircular_genaA 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 cgSrMrris r5rjzsemicircular_gen._shape_infoZ%rr7c`dtjz tjd||zz zSrrrs r5rqzsemicircular_gen._pdf]%s%255y1Q3''r7ctjdtjz dtj| |zzzSrrrs r5rzsemicircular_gen._logpdf`%s0vvagRXXqbd^!333r7cddtjz |tjd||zz ztj|zzzS)Nrrr)rOrrr)rs r5rtzsemicircular_gen._cdfc%s<3ruu9a!A#.1=>>>r7c.tj|dSNr)r* r}rs r5r}zsemicircular_gen._ppff%szz!Qr7Nctj|j|}tjtj|j|z}||zSr5)rOrrr r)rDrrrrs r5rzsemicircular_gen._rvsi%sN GGL((d(3 4 FF255<//T/:: ;1u r7cy)N)rrrrArris r5rzsemicircular_gen._statsp%ror7cy)NgzCϑ?rris r5rzsemicircular_gen._entropys%s%r7r) rrrrrjrqrrtr}rrrrr7r5r r ;%s/<(4?  &r7r semicircularc<eZdZdZdZdZdZdZdZd dZ dZ y ) skewcauchy_genaA 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 c2tj|dkSr])rOrrs r5rbzskewcauchy_gen._argcheck%svvay1}r7c tddddgS)NrF)rArr rris r5rjzskewcauchy_gen._shape_info%s3{NCDDr7cxdtj|dz|tj|zdzdzz dzzz Sr0)rOrrPr s r5rqzskewcauchy_gen._pdf%s:BEEQTQ^a%7!$;;a?@AAr7c tj|dkd|z dz d|z tjz tj|d|z z zzd|z dz d|ztjz tj|d|zz zzSNrrrT)rOrTrrr s r5rtzskewcauchy_gen._cdf%sxxQQ! q1uo !q1u+8N&NNQ! q1uo !q1u+8N&NNP Pr7c >||jd|k}tj|tjtjd|z z |d|z dz z zd|z ztjtjd|zz |d|z dz z zd|zzSr )rtrOrTrr)rDrprrs r5r}zskewcauchy_gen._ppf%s  !Q xxruuA!q1uk/BCq1uMruuA!q1uk/BCq1uMO Or7c~tjtjtjtjfSrMr)rDrrs r5rzskewcauchy_gen._stats%rr7ct|tr|j}tj|gd\}}}d|||z dz fS)NrrrTr)rDrErrrs r5rzskewcauchy_gen._fitstart%sE dL )>>#D dL9 S#C#)Q&&r7Nr) rrrrrbrjrqrtr}rrrr7r5r r z%s/ BEBP O .'r7r skewcauchyceZdZdZdZdZdZdZfdZdZ dZ d Z dd Z dd Z ed Zd ZeedfdZxZS) skewnorm_genaAA 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,tj|SrMrrs r5rbzskewnorm_gen._argcheck%rr7c^tddtj tjfdgS)NrFr rgris r5rjzskewnorm_gen._shape_info%rr7c@tj|dk(||fddS)Nrct|SrMrrprs r5rz#skewnorm_gen._pdf..%s 1r7c<dt|zt||zzSr=r r s r5rz#skewnorm_gen._pdf..%sIaL1Q37r7rr s r5rqzskewnorm_gen._pdf%s& FQF % 79 9r7c@tj|dk(||fddS)Nrct|SrMrr s r5rz&skewnorm_gen._logpdf..%s ar7cbtjdt|zt||zzSrr r s r5rz&skewnorm_gen._logpdf..%s%<?2<!3DDr7rr s r5rzskewnorm_gen._logpdf%s( FQF ( DF Fr7ctj|}tj|dd|}tj||j }|dk|dkDz}t |||||||<tj|ddS)Nrrgư>rr) rOrrm _skewnorm_cdfrm rr@rtr )rDrprr i_small_cdfrs r5rtzskewnorm_gen._cdf%s} MM! 3Q/ OOAsyy )Tza!e,  7<++GKwwsAq!!r7c2tj|dd|SNrr)rm _skewnorm_ppfr s r5r}zskewnorm_gen._ppf%  Ca00r7c*|j| | SrMrr s r5rxzskewnorm_gen._sf%syy!aR  r7c2tj|dd|Sr )rm _skewnorm_isfr s r5rzskewnorm_gen._isf&r r7c|j|}|j|}|tjd|dzzz }||z|tjd|dzz zz}tj|dk\|| S)NrrrTr)r6rOrrT)rDrrru0rrrs r5rzskewnorm_gen._rvs&s  d +   T  * bgga!Q$h  rTAbgga!Q$h'' 'xxabS))r7cgd}tjdtjz |ztjd|dzzz }d|vr||d<d|vr d|dzz |d<d|vr;dtjz dz |tjd|dzz z d zz|d<d |vr+dtjd z z|dzd|dzz dzz z|d <|S) NrrTrr@rrrr#rrr[)rDrrr2consts r5rzskewnorm_gen._stats &s)"%% 1$RWWQAX%66 '>F1I '>E1H F1I '>bee)Q5UAX1F+F*JJF1I '>BEEAI5!8Q\A4E+EFF1I r7c tdgtddgtgdtgdtgdtgdtgdtgd tgd tgd d }|S) Nrrr)rir)ii?i)iiinir )(iSi6QiiiO)iiBi/iioir )iԷiiYei{Hxiii!) i! iׅi쇀 iiViX'i lir ) is_'il.skew_dh&s]beeGQ;1rwwq255y'9#9A"=%&1a4"%%%73$?#@A Ar7ctj|dz}tj|tjtjdz |z|dtjz dz dzzz zS)NrrTr#)rOrrPrr)rEs_23s r5d_skewz skewnorm_gen.fit..d_skewl&s^66$<#&D774=277a$$1ruu9a-3)?"?@$ r7r;rFr-r.gGzgGz?rr8r9rTrJ)r2r@rBr>r)r?rrKr<r=rrrErOr r;rr:rPrrr)rDrErFr4rrrr0r r rr-r.rs_maxrrr@rs r5rBzskewnorm_gen.fitK&s 88J &7;t3d3d3 3 dL )  "a'~~'w{47$7$77"=T4=A4"Ib$(E*002 A  T>,MAsEt9Q$A((5$'CHHWd+E :!) 4 AGGAud+q GGAvu-q AH- BGGBIIadQq!tV56rwwqzA B Bn!ABGGA1H%%A >emt AGGAQq!tVBEE\!123E  E c5= 7;tQECuEE E/ B Bs A JJrr)rrrrrbrjrqrrtr}rxrrrrr rr rrBrrs@r5r r %sz:K9 F "1! 1* *$$*E(} 5 GF GFr7r skewnormc:eZdZdZdZdZdZdZdZdZ dZ y ) trapezoid_genaA 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<|dk\|dkz|dk\z|dkz||k\zSrrrDr rs r5rbztrapezoid_gen._argcheck&s0Q16"a1f-a8AFCCr7cBtdddd}tdddd}||gS)Nr FrrTTrr r&s r5rjztrapezoid_gen._shape_info&s+ UHl ; UHl ;Bxr7cjd||z dzz }t||k||k||kz||kDgdddg||||fS)NrTrc||z|z SrMrrpr rrs r5rz$trapezoid_gen._pdf..&sq1uqyr7c|SrMrr s r5rz$trapezoid_gen._pdf..&sqr7c|d|z zd|z z Sr]rr s r5rz$trapezoid_gen._pdf..&sqAaCyAaC/@r7r)rDrpr rrs r5rqztrapezoid_gen._pdf&s` 1QKAE!VQ/E#90@Bq!Q< ) )r7cRt||k||k||kz||kDgdddg|||fS)Nc$|dz|z ||z dzz Srrrpr rs r5rz$trapezoid_gen._cdf..&sAqD1H!A,>r7c*|d||z zz||z dzz Srrr s r5rz$trapezoid_gen._cdf..&sQac]qs1u,Er7c6dd|z dz||z dzz d|z z z Sr0rr s r5rz$trapezoid_gen._cdf..&s3A!z23A#a%09<=aC0A-Br7rr8s r5rtztrapezoid_gen._cdf&sPAE!VQ/E#?EBCq!9& &r7cR|j||||j|||}}||k||k||kDg}tj||zd|z|z zd|zd|z|z zd|zzdtjd|z ||z dzzd|z zz g}tj||Sr')rtrOrselect)rDr|r rqcqdrrx s r5r}ztrapezoid_gen._ppf&s1a#TYYq!Q%7BFAGQV,gga!eq1uqy12AgQ+cAg5"''1q5QUQY"71q5"ABBD yy:..r7c|dzz}t|dk(d|k|dkz|dk(gdfdfdg|g}dd|z|z z ||z zdzdzzz }|S) Nrrrcyrrr s r5rz%trapezoid_gen._munp..&sr7cltjdztj|z|dz z Sr)rOrrrras r5rz%trapezoid_gen._munp..&s*rxx1q 12ae<r7cdzSrrr s r5rz%trapezoid_gen._munp..&s qsr7rrTr)rDrar rab_termdc_termr|s ` r5rztrapezoid_gen._munp&sac( #XaAG,a3h 7  <  C  SU1Wo7!23!!}E r7chdd|z |zzd|z|z z tjdd|z|z zzSrr1r s r5rztrapezoid_gen._entropy's=c!eAg#a%'*RVVC3q57O-DDDr7N) rrrrrbrjrqrtr}rrrr7r5r r &s- BD )&/2Er7r trapezoidcBeZdZdZd dZdZdZdZdZdZ d Z d Z y) triang_gena5A 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*|jd|d|Sr) triangularrs r5rztriang_gen._rvs''s&&q!Q55r7c|dk\|dkzSrrrs r5rbztriang_gen._argcheck*'sQ16""r7c tddddgS)Nr Fr r r ris r5rjztriang_gen._shape_info-'s3x>??r7c`t|dk(||k||k\|dk7z|dk(gddddg||f}|S)Nrrcdd|zz Srrrs r5rz!triang_gen._pdf..:'sa!a%ir7cd|z|z Srrrs r5rz!triang_gen._pdf..;'a!eair7cdd|z zd|z z Srrrs r5rz!triang_gen._pdf..<'sa1q5kQU&;r7c d|zSrrrs r5rz!triang_gen._pdf..=' a!er7rrDrpr rs r5rqztriang_gen._pdf0'sZ aQq&Q!V,a!0/;+-A r7c`t|dk(||k||k\|dk7z|dk(gddddg||f}|S)Nrrcd|z||zz Srrrs r5rz!triang_gen._cdf..F'sacAaCir7c||z|z SrMrrs r5rz!triang_gen._cdf..G'r r7c*||zd|zz |z|dz z Srrrs r5rz!triang_gen._cdf..H'sqsQqSy1}1&=r7c ||zSrMrrs r5rz!triang_gen._cdf..I'r r7rr s r5rtztriang_gen._cdfA'sX aQq&Q!V,a!0/=+-A r7c tj||ktj||zdtjd|z d|z zz Sr])rOrTrrs r5r}ztriang_gen._ppfM's?xxArwwq1u~q!A#!A#1G/GHHr7c |dzdz d|z ||zzdz tjdd|zdz z|dzz|dz zdtjd|z ||zzdzz dfS) NrrIrTrrHrg333333)rOrrrs r5rztriang_gen._statsP'sx3 QqsB AaCE"AaC(!A#.!BHHc!eAaCi#4N2NO r7c2dtjdz Srr1rs r5rztriang_gen._entropyV's266!9}r7r) rrrrrrbrjrqrtr}rrrr7r5r r 's1*6#@" I r7r triangcXeZdZdZdZdZdZdZdZdZ dZ d Z fd Z d Z xZS) truncexpon_genadA 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@tdddtjfdgSrrgris r5rjztruncexpon_gen._shape_infos'r r7c|j|fSrMr9r s r5rztruncexpon_gen._get_supportv'vvqyr7c^tj| tj|  z SrMrrs r5rqztruncexpon_gen._pdfy's#vvqbzBHHaRL=))r7c^| tjtj|  z SrMrrs r5rztruncexpon_gen._logpdf}'s$rBFFBHHaRL=)))r7c\tj| tj| z SrMr{rs r5rtztruncexpon_gen._cdf's!xx|BHHaRL((r7c\tj|tj| z SrM)rvrrrs r5r}ztruncexpon_gen._ppf's"288QB<(((r7ctj| tj| z tj| z SrMrrs r5rxztruncexpon_gen._sf's0r RVVQBZ'1"55r7ctjtj| |tj| zz  SrM)rOrrrvrrs r5rztruncexpon_gen._isf's2rvvqbzA! $44555r7c2|dk(r7d|dztj| zz tj|  z S|dk(rFddd||zd|zzdzztj| zz ztj|  z St|||SrM)rOrrvrr@r)rDrarrs r5rztruncexpon_gen._munp's 6qsBFFA2J&&"((A2,7 7 !VaQqS1WQYr 223bhhrl]C C7=A& &r7ctj|}tj|dz d||dz zzd|z z zSrrR )rDreBs r5rztruncexpon_gen._entropy's; VVAYvvbd|Qr1S5z\CF333r7)rrrrrjrrqrrtr}rxrrrrrs@r5r r ]'s;*E**))66 '4r7r truncexpon)rrc4tj||gdS)Nrr)rvrFlog_plog_qs r5_log_sumr+ 's <<Q //r7c\tj||tjdzzgdS)N?rr)rvrFrOrr( s r5rT rT 's$ <<beeBh/a 88r7ctj||\}}|dk}|dkD}||z}dfd}d}tj|tjtj}||j r||||||<||j r|||||||<||j r|||||||<tj |S)z3Log of Gaussian probability mass within an intervalrc>tt|t|SrM)rT rrs r5mass_case_leftz'_log_gauss_mass..mass_case_left'sa,q/::r7c| | SrMr)rrr0 s r5mass_case_rightz(_log_gauss_mass..mass_case_right'sqb1"%%r7cZtjt| t| z SrM)rvrrrs r5mass_case_centralz*_log_gauss_mass..mass_case_central's$xx1 1" 566r7)rr )rOrrr complex128rr) rr case_left case_right case_centralr2 r4 rr0 s @r5_log_gauss_massr9 's  q! $DAqQIQJ+,L;& 7 ,,qRVV2== AC|') a lCI})!J-:GJ-a oqOL 773<r7cxeZdZdZdZdZfdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZddZxZS) truncnorm_genaw A truncated normal continuous random variable. %(before_notes)s Notes ----- This distribution is the normal distribution centered on ``loc`` (default 0), with standard deviation ``scale`` (default 1), and truncated at ``a`` and ``b`` *standard deviations* from ``loc``. For arbitrary ``loc`` and ``scale``, ``a`` and ``b`` are *not* the abscissae at which the shifted and scaled distribution is truncated. .. note:: If ``a_trunc`` and ``b_trunc`` are the abscissae at which we wish to truncate the distribution (as opposed to the number of standard deviations from ``loc``), then we can calculate the distribution parameters ``a`` and ``b`` as follows:: a, b = (a_trunc - loc) / scale, (b_trunc - loc) / scale This is a common point of confusion. For additional clarification, please see the example below. %(example)s In the examples above, ``loc=0`` and ``scale=1``, so the plot is truncated at ``a`` on the left and ``b`` on the right. However, suppose we were to produce the same histogram with ``loc = 1`` and ``scale=0.5``. >>> loc, scale = 1, 0.5 >>> rv = truncnorm(a, b, loc=loc, scale=scale) >>> x = np.linspace(truncnorm.ppf(0.01, a, b), ... truncnorm.ppf(0.99, a, b), 100) >>> r = rv.rvs(size=1000) >>> fig, ax = plt.subplots(1, 1) >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf') >>> ax.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2) >>> ax.set_xlim(a, b) >>> ax.legend(loc='best', frameon=False) >>> plt.show() Note that the distribution is no longer appears to be truncated at abscissae ``a`` and ``b``. That is because the *standard* normal distribution is first truncated at ``a`` and ``b``, *then* the resulting distribution is scaled by ``scale`` and shifted by ``loc``. If we instead want the shifted and scaled distribution to be truncated at ``a`` and ``b``, we need to transform these values before passing them as the distribution parameters. >>> a_transformed, b_transformed = (a - loc) / scale, (b - loc) / scale >>> rv = truncnorm(a_transformed, b_transformed, loc=loc, scale=scale) >>> x = np.linspace(truncnorm.ppf(0.01, a, b), ... truncnorm.ppf(0.99, a, b), 100) >>> r = rv.rvs(size=10000) >>> fig, ax = plt.subplots(1, 1) >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf') >>> ax.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2) >>> ax.set_xlim(a-0.1, b+0.1) >>> ax.legend(loc='best', frameon=False) >>> plt.show() c ||kSrMrrs r5rbztruncnorm_gen._argcheck(s 1u r7ctddtj tjfd}tddtj tjfd}||gS)NrFrfr)FTrgrgs r5rjztruncnorm_gen._shape_info(sI UbffWbff$5} E UbffWbff$5} EBxr7ct|tr|j}t||t j |t j|fSrK rL rXs r5rztruncnorm_gen._fitstart(sC dL )>>#Dw RVVD\266$<,H IIr7c ||fSrMrrs r5rztruncnorm_gen._get_support!(rZr7cNtj|j|||SrMrrss r5rqztruncnorm_gen._pdf$(r]r7c2t|t||z SrM)rr9 rss r5rztruncnorm_gen._logpdf'(sAA!666r7cNtj|j|||SrMrQrss r5rtztruncnorm_gen._cdf*(r]r7c Ttj|||\}}}tjt||t||z }|dkD}tj|rFtj tj |j|||||| ||<|SNg)rOrrr9 rrrr)rDrprrlogcdfrs r5rztruncnorm_gen._logcdf-(s%%aA.1aOAq1OAq4IIJ TM 66!9"&&QqT1Q41)F"G!GHF1I r7cNtj|j|||SrMr;rss r5rxztruncnorm_gen._sf5(r<r7c Ttj|||\}}}tjt||t||z }|dkD}tj|rFtj tj |j|||||| ||<|SrD )rOrrr9 rrrr)rDrprrlogsfrs r5rztruncnorm_gen._logsf8(s%%aA.1a ?1a0?1a3HHI DL 66!9xx QqT1Q41(F!G GHE!H r7c&t|}t|}||z }tjtjdtjztj z|z}|t |z|t |zz d|zz }||z}|Sr)rrOrrrrpr) rDrrrqrrr8rGDrs r5rztruncnorm_gen._entropy@(s} aL aL E FF2771ruu9rtt+,q0 1 1 IaL 0 0QU ; Er7ctj|||\}}}|dk}|}d}d}tj|}||} ||} | jr|| ||||||<| jr|| ||||||<|S)Nrctt|tj|t ||z}t j |SrM)r+ rrOrr9 rv ndtri_expr|rr log_Phi_xs r5ppf_leftz$truncnorm_gen._ppf..ppf_leftO(s9 a!#_Q-B!BDI<< * *r7ctt| tj| t ||z}t j | SrM)r+ rrOrr9 rvrM rN s r5 ppf_rightz%truncnorm_gen._ppf..ppf_rightT(sA qb!1!#1"10E!EGILL++ +r7rOr empty_liker) rDr|rrr6 r7 rP rR rq_leftq_rights r5r}ztruncnorm_gen._ppfI(s%%aA.1aE Z  +  , mmA9J- ;;%fa lAiLIC N <<':* NC O r7ctj|||\}}}|dk}|}d}d}tj|}||} ||} | jr|| ||||||<| jr|| ||||||<|S)Nrctt|tj|t ||z}t j tj|SrM)rT rrOrr9 rvrM rrN s r5isf_leftz$truncnorm_gen._isf..isf_leftl(sB!,q/"$&&)oa.C"CEI<< 23 3r7ctt| tj| t ||z}t j tj| SrM)rT rrOrr9 rvrM rrN s r5 isf_rightz%truncnorm_gen._isf..isf_rightq(sJ!,r"2"$((A2,A1F"FHILL!344 4r7rS ) rDr|rrr6 r7 rY r[ rrU rV s r5rztruncnorm_gen._isfe(s%%aA.1aE Z  4  5 mmA9J- ;;%fa lAiLIC N <<':* NC O r7cfd}tj|dk\||k(z||k(z|||ftj|tjgtj S)Nct tj||g} j|||\}}tj|| g}|dk7}ddg}td|dzD]R t j |||f fdd} tj |  dz |dzz} |j| T|dS)z Returns n-th moment. Defined only if n >= 0. Function cannot broadcast due to the loop over n rrc||dz zzSr]r)rprrs r5rz:truncnorm_gen._munp..n_th_moment..(sAAaCLr7rrr)rOrrqrrrrr) rarrabpApBprobscondrrmkrrDs @r5 n_th_momentz(truncnorm_gen._munp..n_th_moment(s QF#BYYr1a(FBJJRCy)EA:D!fG1ac] # teR['@235VVD\QqSGBK$77r" #2; r7rrrrY)rDrarrre s` r5rztruncnorm_gen._munp(sV ,Q162a1f=1ay!||K M*,&&2 2r7c|jtj||g||\}}d}tj|}|||||S)Nctj||g}||z }|}tj|| g}|dk7}tj|||fdd} dtj| z} tj||||z fdd} dtj| z} tj|||fdd} d|ztj| z} tj|||fdd} d | ztj| z} | |d | zd|dzzzzz}|tj | d z }| |d | zd |zd| z|dzz zzzz}|| dzz d z }|| ||fS) Nrc ||zSrMrrs r5rzGtruncnorm_gen._stats.._truncnorm_stats_scalar..(s 1Q3r7rrc ||zSrMrrs r5rzGtruncnorm_gen._stats.._truncnorm_stats_scalar..(s !r7c||dzzSrrrs r5rzGtruncnorm_gen._stats.._truncnorm_stats_scalar..(1QT6r7rTc||dzzSr rrs r5rzGtruncnorm_gen._stats.._truncnorm_stats_scalar..(rk r7rrrr)rOrrrrr)rrr` ra r_ rBrBrb rc rrCrCrDm4mu3rDmu4rEs r5_truncnorm_stats_scalarz5truncnorm_gen._stats.._truncnorm_stats_scalar(sQF#BbBBJJRCy)EA:D??4%6F./1DRVVD\!B??4%b)9;K./1DbffTl"C??4%6I./1D2t $B??4%6I./1D2t $BrRUQr1uW_--CrxxS))Br2b51R42A#6677CsAv!BsB? "r7)pdfrOrr)rDrrrr` ra rp _truncnorm_statss r5rztruncnorm_gen._stats(sM"((Aq6*Aq1B #8<<(?@1b"--r7r)rrrrrbrjrrrqrrtrrxrrr}rrrrrs@r5r; r; 'sU>@ J -7-,8:26 .r7r; truncnorm)rrceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZeeefdZxZS)truncpareto_genacAn 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 ctdddtjfd}tdddtjfd}||gS)NrFrr r rrg)rDrir's r5rjztruncpareto_gen._shape_info(s; US"&&M> B US"&&M> BBxr7c|dkD|dkDzSr rrDrr s r5rbztruncpareto_gen._argcheck(sB1r6""r7c|j|fSrMr9rx s r5rztruncpareto_gen._get_support(r r7c2|||dz zzdd||zz z z Sr]rrDrprr s r5rqztruncpareto_gen._pdf(s'1!f9}AadF ++r7c tj|tjtj| tj|z z |dztj|zz Sr])rOrrr{ s r5rztruncpareto_gen._logpdf(sMvvay266288QBrvvayL#9"9::ac266!9_LLr7c,d|| zz dd||zz z z Sr]rr{ s r5rtztruncpareto_gen._cdf(s#ArE a!AqD&j))r7cntj|| z tjd||zz z Sr@r>r{ s r5rztruncpareto_gen._logcdf)s/xxQB"((2ad7"333r7c>tddd||zz z |zz d|z SNrrr8rDr|rr s r5r}ztruncpareto_gen._ppf)s(1AadF A~%r!t,,r7c8|| zd||zz z dd||zz z z Sr]rr{ s r5rxztruncpareto_gen._sf)s+A2!Q$1qAv:..r7c~tj|| zd||zz z tjd||zz z Sr rr{ s r5rztruncpareto_gen._logsf )s9vva!ea1fn%AqD(999r7cJtd||zz dd||zz z |zzd|z Sr r8r s r5rztruncpareto_gen._isf)s01QT6Q1a4ZN*BqD11r7ctj|dd||zz z z |dztj|||zdz z d|z z zz Sr]r1rx s r5rztruncpareto_gen._entropy)sW1qAv:'aC"&&)QTAX.14567 7r7c||k(jr$|tj|zdd||zz z z S|||z z ||z||zz z||zdz z Sr])rrOr)rDrarr s r5rztruncpareto_gen._munp)s^ F<<>RVVAY;!a1f*- -!91q!t ,1q9 9r7ct|tr|j}tj |\}}}t ||z |z }||||fSrM)r>r)rr rBr)rDrErr-r.r s r5rztruncpareto_gen._fitstart)sM dL )>>#D 4( 3 Y_e #!S%r7c  !"#$%|jddrt&g|i|Sd#d""#fd%fd $%fd}$fd!d !"fd }d }&fd }t||}|\} } } } j j c$%t j$t j } | | | | td | | | |  !"fd }t j$t j } | }d}|dz }|t j kDr[||||zdk\rG|dz }|t jd|z }|t j kDr||||zdk\rG|t j kDs |g|i|St|||f}|js |g|i|S|jdz }|dz }d}|t j kDr[||||zdk\rG|dz }|t jd|z }|t j kDr||||zdk\rG|t j kDs |g|i|St|||f}|js |g|i|S|j}!|} ||}|||}|z |z }t d#|z d"|dz z }||ks|g|i|S| }| dz }d}|t j kDrN||| ||| zdk\r8|dz }|d|zz }|t j kDr||| ||| zdk\r8|t j kDs |g|i|St|| f||f}|js |g|i|S|j}!|} ||}| }n| | n|| | }| xs!|}| xs  ||}| $j | z dkrtdd|| r2| 0| r.j | | z| zkDrtdd ||| |z |z }#|}t j|}d|z|ks |g|i|Sd|z d||z z z}t jd|z d} t|||f||f}|js |g|i|S|j}n| }||z$ksF| r&t j|t j }n!|}t j|d}||z|z%kDs- ||}t j|t j}t j j#||r|dkDs |g|i|S||||f}| 9| 7|g|i|}j%|}j%|}||kr|S|S#t$r|}Y wxYw)Nr?FcRtjtj|SrM)rOrrrs r5log_meanz%truncpareto_gen.fit..log_mean()s77266!9% %r7c8dtjd|z z Sr])rOrrs r5 harm_meanz&truncpareto_gen.fit..harm_mean+)sRWWQqS\> !r7c|z |z }|} |}|dz |z }d|dz |dd|z z |ztj|z z z z |z Sr]r1) r r-r.rharm_mlog_mquotrEr r s r5get_bz"truncpareto_gen.fit..get_b.)sic5 Aq\FQKE1He#DaDA!GV+;BFF1I+E$EFFM Mr7c|z |z SrMr)r-r.mxs r5get_cz"truncpareto_gen.fit..get_c5)sHe# #r7c<|r|z }|S|r|zz |dz z }|Syr]r)rMrr-rr s r5get_locz$truncpareto_gen.fit..get_loc8)s76k "urzBF+ r7c|z SrMr)r-rs r5r z&truncpareto_gen.fit..get_scale@)s 8Or7c |}||}| |||n|} |z |z }dd|dz ||dzz|z z zdd|dzz z z|zz Sr]r) r-rr.r rr rEr r r r s r5rWz$truncpareto_gen.fit..dL_dLocF)s|cNEc5!A(* ae$As E12FQUQ1X\22q1ac7{CfLL Lr7cP|tj||zd||zz z |z z Sr]r>)rlogclogms r5dL_dBz"truncpareto_gen.fit..dL_dBO)s.rxx$!af* 56== =r7c2tt |g|i|SrM)r@ru rB)rErFkwargsrrDs r5fallbackz%truncpareto_gen.fit..fallbackU)s$3DJ4J6J Jr7z2All parameters fixed.There is nothing to optimize.c|}||}|z |z }dd|dz z ztj|z|z dz Sr]r1)r-r.r r rEr r r s r5cond_bz#truncpareto_gen.fit..cond_bf)sT%cNEc5)A&s E'9:F1Q3K266!94v=AAr7rrrr%gMbP?rT truncparetorrM)r2r@rBrKrrrOr]rhrrr*r^rLrJrrrbrY)'rDrErFr4r rWr r r_rrMrrmn_infr rRrrQrr-r.r rstd_data up_bound_br r params_override params_super nllf_override nllf_superr r r r r rr rs'`` @@@@@@@r5rBztruncpareto_gen.fit")s 88J &7;t3d3d3 3 & " N $    M M >  K1tT4H %/"b"dFTXXZBb266'* NN$&=> > ZDLV^zBb266'2!"&&("6N6&>9Q>FA#bhhr1o5F"&&("6N6&>9Q>'#D848488!&662BC}}#D848488D!"&&(#FOGFO;q@FA#bhhr1o5F"&&(#FOGFO;q@'#D848488!'FF3CD}}#D848488hh!##u%!S%( 3J- 8H#5!5!"Ih$7$9!:< J#D848488 !'#FB/%fb12567FA#ad]F '#FB/%fb12567'#D848488!'B5+16*:<}}#D848488hh!##u%*$F0CC,inE'eC'A DHHJ$5$9"=CC t'V88:6 D 00&}A-23->@@z 3J-)vvay$ #D8484884!TD[/1afa0%edD\/5v.>@C=='.&*s #r7rr)rDr rs r5rztukeylambda_gen._get_support$*s/ OOC!GS-')vv /r1u r7c tjtj||}||dz ztjd|z |dz zz}tjd5dtj|z }tj |dkt |dtj|z kz|dcdddS#1swYyxYw)Nrrr8r9rr)rOrrvtklmbdar;rTr)rDrpr Fxr_s r5rqztukeylambda_gen._pdf**s ZZ 1c* + #c']bjj2.#c': : [[ ) RRZZ^#B88SAX#a&3rzz#3F*FGSQ R R Rs 'ACCc.tj||SrM)rvr )rDrpr s r5rtztukeylambda_gen._cdf1*szz!S!!r7c^tj||tj| |z SrM)rvrr)rDr|r s r5r}ztukeylambda_gen._ppf4*s%yyC 2;;r3#777r7c2dt|dt|fSr3)_tlvar_tlkurtr s r5rztukeylambda_gen._stats7*s&+q'#,..r7cBfd}tj|dddS)Ncntjt|dz td|z dz zSr])rOrr)rr s r5integz'tukeylambda_gen._entropy..integ;*s/66#aQ-AaCQ78 8r7rr)rr)rDr r s ` r5rztukeylambda_gen._entropy:*s  9~~eQ*1--r7N)rrrrrrrrbrjrrqrtr}rrrr7r5r r *s>,"44M M R"8/.r7r tukeylambdaceZdZdZy)FitUniformFixedScaleDataErrorc d|d|d|_y)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 = r1rL)rDr rs r5rOz&FitUniformFixedScaleDataError.__init__D*s$ ::=?xq " r7N)rrrrOrr7r5r r C*s r7r cLeZdZdZdZd dZdZdZdZdZ d Z e d Z y) uniform_gena A uniform continuous random variable. In the standard form, the distribution is uniform on ``[0, 1]``. Using the parameters ``loc`` and ``scale``, one obtains the uniform distribution on ``[loc, loc + scale]``. %(before_notes)s %(example)s cgSrMrris r5rjzuniform_gen._shape_infoY*rr7Nc(|jdd|Sr )rrs r5rzuniform_gen._rvs\*s##Cd33r7cd||k(zSrrrs r5rqzuniform_gen._pdf_*sAF|r7c|SrMrrs r5rtzuniform_gen._cdfb*r7c|SrMrrs r5r}zuniform_gen._ppfe*r r7cy)N)rgUUUUUU?rg333333rris r5rzuniform_gen._statsh*s#r7cyrSrris r5rzuniform_gen._entropyk*rr7ct|dkDr td|jdd}|jdd}t|| | t dt j |}t j|js t d|a|&|j}t j|}n{|}|j|z }|j|krStd|||z t j|}||kDr t|| |jd ||z zz }|}t|t|fS) 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()]``. rrrNrrrrr)r rr)rr3r2r6rrOrrrrr rrJr rT) rDrErFr4rrr-r.r s r5rBzuniform_gen.fitn*sFV t9q=12 2xx%(D)$T*   2)* *zz${{4 $$&CD D> >|hhjt  S(88:#&y3;OO&&,CV|3FKK((*sFSL11CESz5<''r7r) rrrrrjrrqrtr}rrrJrBrr7r5r r M*s@ 4$R(R(r7r rceZdZdZdZdZddZeefdZ dZ dZ dZ d Z d Zeed  dfd Zeeed fdZxZS) vonmises_genaU A Von Mises continuous random variable. %(before_notes)s See Also -------- scipy.stats.vonmises_fisher : Von-Mises Fisher distribution on a hypersphere Notes ----- The probability density function for `vonmises` and `vonmises_line` is: .. math:: f(x, \kappa) = \frac{ \exp(\kappa \cos(x)) }{ 2 \pi I_0(\kappa) } for :math:`-\pi \le x \le \pi`, :math:`\kappa \ge 0`. :math:`I_0` is the modified Bessel function of order zero (`scipy.special.i0`). `vonmises` is a circular distribution which does not restrict the distribution to a fixed interval. Currently, there is no circular distribution framework in SciPy. The ``cdf`` is implemented such that ``cdf(x + 2*np.pi) == cdf(x) + 1``. `vonmises_line` is the same distribution, defined on :math:`[-\pi, \pi]` on the real line. This is a regular (i.e. non-circular) distribution. Note about distribution parameters: `vonmises` and `vonmises_line` take ``kappa`` as a shape parameter (concentration) and ``loc`` as the location (circular mean). A ``scale`` parameter is accepted but does not have any effect. Examples -------- Import the necessary modules. >>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.stats import vonmises Define distribution parameters. >>> loc = 0.5 * np.pi # circular mean >>> kappa = 1 # concentration Compute the probability density at ``x=0`` via the ``pdf`` method. >>> vonmises.pdf(0, loc=loc, kappa=kappa) 0.12570826359722018 Verify that the percentile function ``ppf`` inverts the cumulative distribution function ``cdf`` up to floating point accuracy. >>> x = 1 >>> cdf_value = vonmises.cdf(x, loc=loc, kappa=kappa) >>> ppf_value = vonmises.ppf(cdf_value, loc=loc, kappa=kappa) >>> x, cdf_value, ppf_value (1, 0.31489339900904967, 1.0000000000000004) Draw 1000 random variates by calling the ``rvs`` method. >>> sample_size = 1000 >>> sample = vonmises(loc=loc, kappa=kappa).rvs(sample_size) Plot the von Mises density on a Cartesian and polar grid to emphasize that it is a circular distribution. >>> fig = plt.figure(figsize=(12, 6)) >>> left = plt.subplot(121) >>> right = plt.subplot(122, projection='polar') >>> x = np.linspace(-np.pi, np.pi, 500) >>> vonmises_pdf = vonmises.pdf(x, loc=loc, kappa=kappa) >>> ticks = [0, 0.15, 0.3] The left image contains the Cartesian plot. >>> left.plot(x, vonmises_pdf) >>> left.set_yticks(ticks) >>> number_of_bins = int(np.sqrt(sample_size)) >>> left.hist(sample, density=True, bins=number_of_bins) >>> left.set_title("Cartesian plot") >>> left.set_xlim(-np.pi, np.pi) >>> left.grid(True) The right image contains the polar plot. >>> right.plot(x, vonmises_pdf, label="PDF") >>> right.set_yticks(ticks) >>> right.hist(sample, density=True, bins=number_of_bins, ... label="Histogram") >>> right.set_title("Polar plot") >>> right.legend(bbox_to_anchor=(0.15, 1.06)) c@tdddtjfdgS)NrFrrfrgris r5rjzvonmises_gen._shape_infog+s7EArvv; FGGr7c |dk\Sr3rrs r5rbzvonmises_gen._argcheckj+s zr7c*|jd||S)Nrr)vonmises)rDrrrs r5rzvonmises_gen._rvsm+s$$S%d$;;r7ct||i|}tj|tjzdtjztjz Srr@rrOmodrrDrFr4rrs r5rzvonmises_gen.rvsp+s@gk4(4(vvcBEEk1RUU7+bee33r7ctj|tj|zdtjztj |zz Sr)rOrrvcosm1rrd rs r5rqzvonmises_gen._pdfu+s: vveBHHQK'(AbeeGBFF5M,ABBr7c|tj|ztjdtjzz tjtj |z Sr)rvr rOrrrd rs r5rzvonmises_gen._logpdf|+s@rxx{"RVVAbeeG_4rvvbffUm7LLLr7c.tj||SrM)r von_mises_cdfrs r5rtzvonmises_gen._cdf+s##E1--r7cyrnrrs r5 _stats_skipzvonmises_gen._stats_skip+ror7c| tj|ztj|z tjdtj ztj|zz|zSr)rvi1erd rOrrrs r5rzvonmises_gen._entropy+sV&6q255y266%=01249: ;r7z The default limits of integration are endpoints of the interval of width ``2*pi`` centered at `loc` (e.g. ``[-pi, pi]`` when ``loc=0``). rc tj tj} } ||| z}||| z}t | |||||||fi|SrM)rOrr@expect) rDr]rFr-r.lbub conditionalr4rrrs r5r zvonmises_gen.expect+s_ %%B :rB :rBw~dD##R[B<@B Br7a 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|jddrt ||g|i|St||||\}}}}|jt j k(rt ||g|i|St j|dt j z}d}d}||n||} ||n||| } t j| t j zdt j zt j z } | | dfS)Nr?FrTc,tj|SrM)rcircmean)rEs r5find_muz!vonmises_gen.fit..find_mu+s>>$' 'r7cjtjtj||z t|z dk(rydkDrNfd}dz z dzz }d|z}||dk\r|S||dkr|St |d||f}|j Stj tjS)Nrg7yACrc`tj|tj|z z SrM)rvr rd )rrs r5solve_for_kappaz=vonmises_gen.fit..find_kappa..solve_for_kappa+s#66%=6::r7rTrA)r0rI) rOrr rr*rLr'rTr()rEr-r lower_bound upper_boundroot_resrs @r5 find_kappaz$vonmises_gen.fit..find_kappa+srvvcDj)*3t94AAvQ; 1gqsm  m #;/14&&$[1Q6&&*?84?3M OH#==(xx+++r7r)r2r@rBrKrrOrr ) rDrErFr4rRrrr r r-rrs r5rBzvonmises_gen.fit+s 88J &7;t3d3d3 3%@tAEt&M"fdF 66beeV 7;t3d3d3 3vvdAI& (6 ,r&dGDM ,*T32GffS255[!bee),ruu4c1}r7r)NrrrNNF)rrrrrjrbrr rrrqrrtr rr r rJrBrrs@r5r r +s^~H<M*4+4CM.  ;}5FJ  B  B}5/0 N 0 Nr7r r vonmises_linecreZdZdZej ZdZddZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZy)raXA 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 cgSrMrris r5rjzwald_gen._shape_info,rr7Nc*|jdd|Srrrs r5rz wald_gen._rvs,s  c 55r7c.tj|dSr)rrqrs r5rqz wald_gen._pdf,s}}Q$$r7c.tj|dSr)rrtrs r5rtz wald_gen._cdf,}}Q$$r7c.tj|dSr)rrxrs r5rxz wald_gen._sf!,s||As##r7c.tj|dSr)rr}rs r5r}z wald_gen._ppf$,r r7c.tj|dSr)rrrs r5rz wald_gen._isf',r r7c.tj|dSr)rrrs r5rzwald_gen._logpdf*,3''r7c.tj|dSr)rrrs r5rzwald_gen._logcdf-,r r7c.tj|dSr)rrrs r5rzwald_gen._logsf0,sq#&&r7cy)N)rrrIrrris r5rzwald_gen._stats3,s"r7c,tjdSr)rrris r5rzwald_gen._entropy6,s  %%r7r)rrrrrrrrjrrqrtrxr}rrrrrrrr7r5rr+sP("44M6%%$%%(('#&r7rrcbeZdZdZdZdZdZdZdZdZ dZ e e fd Z xZS) wrapcauchy_genaA 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|dkD|dkzSrrrs r5rbzwrapcauchy_gen._argcheckS,rH r7c tddddgS)Nr F)rrr r ris r5rjzwrapcauchy_gen._shape_infoV,s3v~>??r7cd||zz dtjzd||zzd|ztj|zz zz Srrrs r5rqzwrapcauchy_gen._pdfY,s?AaC!BEE'1QqS51RVVAY#6788r7czd}d}d|zd|z z }tj|tjk||f||S)Ncdtjz tj|tj|dz zzSr0rOrrrrpcrs r5rzwrapcauchy_gen._cdf..f1_,s.RUU7RYYr"&&1+~66 6r7c ddtjz tj|tjdtjz|z dz zzz Sr0r r s r5rzwrapcauchy_gen._cdf..f2c,sAqw2bffagk1_.E+E!FFF Fr7r)rrrOr)rDrpr rrr s r5rtzwrapcauchy_gen._cdf],sA 7 G!ea!e_q255y1b'2r::r7c vd|z d|zz }dtj|tjtj|zzz}dtjzdtj|tjtjd|z zzzz }tj|dk||S)NrrTrr)rOrrrrT)rDr|r r|rcqrcmqs r5r}zwrapcauchy_gen._ppfj,s1us1uo #bffRUU1Wo-..wq3rvvbeeQqSk':#:;;;xxE 3--r7c`tjdtjzd||zz zSrrrs r5rzwrapcauchy_gen._entropyp,s%vvagq1uo&&r7ct|tr|j}dtj|tj |dtj zz fSr)r>r)rrOrr r)rDrEs r5rzwrapcauchy_gen._fitstarts,sD dL )>>#DBFF4L"&&,"%%"888r7cpt||i|}tj|dtjzSrr r s r5rzwrapcauchy_gen.rvs{,s/gk4(4(vvc1RUU7##r7)rrrrrbrjrqrtr}rrr rrrrs@r5r r =,sE*!@9 ;. '9M*$+$r7r wrapcauchycTeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z dd Zy ) gennorm_gena0A 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@tdddtjfdgSNrmFrr rgris r5rjzgennorm_gen._shape_info,651bff+~FGGr7cLtj|j||SrMrrDrprms r5rqzgennorm_gen._pdf,svvdll1d+,,r7ctjd|ztjd|z z t ||zz Sr)rOrrvrrr s r5rzgennorm_gen._logpdf,s4vvc$h"**SX"66QEEr7cdtj|z}d|z|tjd|z t ||zzz Sr)rOrPrvrrrDrprmr s r5rtzgennorm_gen._cdf,s? "''!* a1r||CHc!fdlCCCCr7ctj|dz }|tjd|z d|zd|z|zz d|z zzS)Nrrr)rOrPrvrr s r5r}zgennorm_gen._ppf,sH GGAG 2??3t8cAgQq-@ACHMMMr7c(|j| |SrMrr s r5rxzgennorm_gen._sf,syy!T""r7c(|j|| SrMrr s r5rzgennorm_gen._isf,s !T"""r7c|dk(ry|dzdk(r;tjd|z |dz|z g\}}tj||z Sy)NrrrTrrvrrOr)rDrarmc1cns r5rzgennorm_gen._munp,sO 6 q5A:ZZTAGT> :;FB66"r'? "r7ctjd|z d|z d|z g\}}}dtj||z dtj||zd|zz dz fS)NrrIr rrr )rDrmr c3c5s r5rzgennorm_gen._stats,s_ZZT3t8SX >? B266"r'?BrBwR/?(@2(EEEr7cpd|z tjd|zz tjd|z zSrrrDrms r5rzgennorm_gen._entropy,s0Dy266"t),,rzz"t)/DDDr7Nc|jd|z |}|d|z z}tj|}|j|jdk}|| ||<|S)Nrrr)rrOrrandomr)rDrmrrr+rr s r5rzgennorm_gen._rvs,sg   qvD  1 !D&M JJqM"""036T7($r7r)rrrrrjrqrrtr}rxrrrrrrr7r5r r ,sE)TH-FD N ##FE r7r gennormc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) halfgennorm_genaThe 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@tdddtjfdgSr rgris r5rjzhalfgennorm_gen._shape_info -r r7cLtj|j||SrMrr s r5rqzhalfgennorm_gen._pdf -svvdll1d+,,r7cjtj|tjd|z z ||zz Srrr s r5rzhalfgennorm_gen._logpdf-s+vvd|bjjT22QW<r7r+ halfgennormcReZdZdZdZdZfdZdZdZdZ dZ d Z d Z xZ S) crystalball_gena Crystalball distribution %(before_notes)s Notes ----- The probability density function for `crystalball` is: .. math:: f(x, \beta, m) = \begin{cases} N \exp(-x^2 / 2), &\text{for } x > -\beta\\ N A (B - x)^{-m} &\text{for } x \le -\beta \end{cases} where :math:`A = (m / |\beta|)^m \exp(-\beta^2 / 2)`, :math:`B = m/|\beta| - |\beta|` and :math:`N` is a normalisation constant. `crystalball` takes :math:`\beta > 0` and :math:`m > 1` as shape parameters. :math:`\beta` defines the point where the pdf changes from a power-law to a Gaussian distribution. :math:`m` is the power of the power-law tail. %(after_notes)s .. versionadded:: 0.19.0 References ---------- .. [1] "Crystal Ball Function", https://en.wikipedia.org/wiki/Crystal_Ball_function %(example)s c|dkD|dkDzS)z@ Shape parameter bounds are m > 1 and beta > 0. rrr)rDrmr@s r5rbzcrystalball_gen._argcheckM-sA$(##r7ctdddtjfd}tdddtjfd}||gS)NrmFrr r@rrg)rDibetaims r5rjzcrystalball_gen._shape_infoS-s<651bff+~F UQK @r{r7c&t||dS)N)rrrLrWrXs r5rzcrystalball_gen._fitstartX-sw H 55r7cd||z |dz z tj|dz dz ztt|zzz }d}d}|t j || kD|||f||zS)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 -- rrrTrc:tj|dz dz Srrwrprmr@s r5rhsz!crystalball_gen._pdf..rhsi-s661a4%!)$ $r7cl||z |ztj|dz dz z||z |z |z | zzSrrwr> s r5lhsz!crystalball_gen._pdf..lhsl-sFtVaK"&&$'C"88tVd]Q&1"-. /r7rOrrrrrrDrprmr@rr? rA s r5rqzcrystalball_gen._pdf\-sw 1T6QqS>BFFD!G8c>$::401 2 % /3??1u9q$lCEEEr7cd||z |dz z tj|dz dz ztt|zzz }d}d}tj|t j || kD|||f||zS)zH Return the log of the PDF of the crystalball function. rrrTrc|dz dz Srrr> s r5r? z$crystalball_gen._logpdf..rhsy-sqD57Nr7c|tj||z z|dzdz z |tj||z |z |z zz Srr1r> s r5rA z$crystalball_gen._logpdf..lhs|-sFRVVAdF^#dAgai/!BFF1T6D=1;L4M2MM Mr7)rOrrrrrrrC s r5rzcrystalball_gen._logpdfr-s 1T6QqS>BFFD!G8c>$::401 2  Nvvay3??1u9q$lCMMMr7cd||z |dz z tj|dz dz ztt|zzz }d}d}|t j || kD|||f||zS)z8 Return CDF of the crystalball function rrrTrc||z tj|dz dz z|dz z tt|t| z zzSNrTrrrOrrrr> s r5r? z!crystalball_gen._cdf..rhs-sNtVrvvtQwhn551=9Q<)TE2B#BCD Er7c~||z |ztj|dz dz z||z |z |z | dzzz|dz z SrI rwr> s r5rA z!crystalball_gen._cdf..lhs-sVtVaK"&&$'C"88tVd]Q&1"Q$/034Q38 9r7rB rC s r5rtzcrystalball_gen._cdf-sx 1T6QqS>BFFD!G8c>$::401 2 E 93??1u9q$lCEEEr7cRd}fd}tj|| kD|||f||S)zD Survival function of the crystalball distribution. c||z |dz z tj|dz dz ztt|zz}tt |z|z Sr0)rOrrrr)rprmr@Ms r5r? z crystalball_gen._sf..rhs-sM$ArvvtQwhqj11K $4OOAx{*1, ,r7c0dj|||z Sr]r)rprmr@rDs r5rA z crystalball_gen._sf..lhs-styyD!,, ,r7r)rDrprmr@r? rA s` r5rxzcrystalball_gen._sf-s0  -  -qD5y1dA,SAAr7cd||z |dz z tj|dz dz ztt|zzz }|||z ztj|dz dz z|dz z }d}d}t j ||k|||f||S)NrrrTrctj|dz dz }||z |z|dz z }d|tt|zzz }||z |z |dz ||z | zz|z |z|z dd|z z zz SrrJ rrmr@eb2rGrs r5ppf_lessz&crystalball_gen._ppf..ppf_less-s&&$'!$C43!A#&A1{Yt_445AdFTM!eaf^+C/1!3q!A#w?@ Ar7ctj|dz dz }||z |z|dz z }d|tt|zzz }t t| dtz ||z |z zzSr)rOrrrrrR s r5 ppf_greaterz)crystalball_gen._ppf..ppf_greater-sp&&$'!$C43!A#&A1{Yt_445AYu-;1q0IIJ Jr7rB )rDrrmr@rpbetarT rV s r5r}zcrystalball_gen._ppf-s 1T6QqS>BFFD!G8c>$::401 2QtV rvvtQwhqj11QU; A K q5y1dA,+NNr7c 2d||z |dz z tj|dz dz ztt|zzz }d}|t j |dz|k|||ftj |tjgtjzS)zR Returns the n-th non-central moment of the crystalball function. rrrTrc ||z |ztj|dz dz z}||z |z }d|dz dz ztj|dzdz zdd|ztj|dzdz |dzdz zzz}tj |j }tt|dzD]C}|tj|||||z zzd|zz||z dz z ||z | |zdzzzz }E||z|zS)z Returns n-th moment. Defined only if n+1 < m Function cannot broadcast due to the loop over n rTrrrr) rOrrvrrrrrrbinom)rarmr@rqrrr? rA rs r5re z*crystalball_gen._munp..n_th_moment-s! 4! bffdAgX^44A$ A!Sy>BHHac1W$552'BKK1aq1$EEEGC((399%C3q6A:& 0AQqS1R!G;q1uqyI4A26A:./0 0s7S= r7rr) rOrrrrrrrrh)rDrarmr@rre s r5rzcrystalball_gen._munp-s 1T6QqS>BFFD!G8c>$::401 2 !3??1q519q$l#%<< RZZL#Q.0ff66 6r7)rrrrrbrjrrqrrtrxr}rrrs@r5r6 r6 )-s;"F$  6F, NF"B O(6r7r6 crystalballzA Crystalball Function)rlongnamec@tjd|dzdz dz 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. rrTr)rs r5 _argus_phir^ -s" ;;sCF1H % ))r7cDeZdZdZdZdZdZdZdZd dZ d d Z d Z y) argus_gena Argus distribution %(before_notes)s Notes ----- The probability density function for `argus` is: .. math:: f(x, \chi) = \frac{\chi^3}{\sqrt{2\pi} \Psi(\chi)} x \sqrt{1-x^2} \exp(-\chi^2 (1 - x^2)/2) for :math:`0 < x < 1` and :math:`\chi > 0`, where .. math:: \Psi(\chi) = \Phi(\chi) - \chi \phi(\chi) - 1/2 with :math:`\Phi` and :math:`\phi` being the CDF and PDF of a standard normal distribution, respectively. `argus` takes :math:`\chi` as shape a parameter. Details about sampling from the ARGUS distribution can be found in [2]_. %(after_notes)s References ---------- .. [1] "ARGUS distribution", https://en.wikipedia.org/wiki/ARGUS_distribution .. [2] Christoph Baumgarten "Random variate generation by fast numerical inversion in the varying parameter case." Research in Statistics, vol. 1, 2023, doi:10.1080/27684520.2023.2279060. .. versionadded:: 0.19.0 %(example)s c@tdddtjfdgS)NrFrr rgris r5rjzargus_gen._shape_info .5%!RVVnEFFr7chtjd5d||zz }dtj|ztz tjt |z }|tj|zdtj | |zzz|dz|zdz z cdddS#1swYyxYw)Nr8r9rrrrT)rOr;rrr^ r)rDrprrrqs r5rzargus_gen._logpdf.s [[ ) Gac A"&&+ . 31HHArvvay=3rxx1~#55Q QF G G Gs BB((B1cLtj|j||SrMrrDrprs r5rqzargus_gen._pdf.svvdll1c*++r7c,d|j||z Srr%re s r5rtzargus_gen._cdf.sTXXa%%%r7cnt|tjd|z d|zzzt|z Sr])r^ rOrre s r5rxz argus_gen._sf.s0#QQ 889JsOKKr7NcZ tj|}|jdk(r|j|||}nt |j |\} t tj|}tj|}tj|gdgdgg jsqt fdtt| dD}|j d||}|j|||< j jsq|dk(r|d}|S) Nr)rrrrrc3\K|]#}|sj|n td%ywrMrrs r5rz!argus_gen._rvs..+.rrrr)rOrrrrrrrrrrrrrrSr) rDrrrrrrrrrrs @@r5rzargus_gen._rvs.sjjo 88q=""340<#>C#399d3GCRWWS\*J((4.CC5"/&0\N4Bkk;%*CI:q%9;;$$RUz2>%@99S>C kk 2:b'C r7cttj|}ttj|}tj |}d}||z}|dkr| dz } ||kr||z } |j | } |j | } | dz} tj| | | zk}tj|}|dkDr(tjd| |z }|||||z||z }||krn8|dkrtj| dz }||kr||z } |j | } |j | } dtj|d| z z| zz|z } | dz| zdk}tj|}|dkDr(tjd| |z}|||||z||z }||krns||krP||z } |jd| }||dz k}tj|}|dkDr||||||z||z }||krPtjdd|z|z z }tj||S) NrrrTrrrg?r) rrOrrrrrrrrrr*rS)rDrrrrrrprrrrrrr+rrrechirs r5rzargus_gen._rvs_scalar6.sqhr}}Z01   HHQK Sy #: Aa- M ((a(0 ((a(0H&&)q1u,VVF^ >''!ai-0C''!ai-0C<=fIAiZ!79+Ia-AEDL()Azz!V$$r7ctj|t}t|}tjtj dz |zt jd|dzdz z|z }tj|}|dkD}||}dd|dzz z |t|z||z z||<||}gd}tj||||<|||dzz ddfS) Nr r-rrTr#g?r) g_1g־rgWBargp|RH?rgE'卡?rg?) rOrrTr^ rrrvr rT rrL)rDrrr@rCr r coefs r5rzargus_gen._stats.sjjE*o GGBEE!G s "RVVAsAvax%8 83 >mmC Sy IAqDL1y|#3c$i#??D JKZZa(TE #1*dD((r7r) rrrrrjrrqrtrxrrrrr7r5r` r` -s5'PGG,&L0c%J)r7r` arguszAn Argus Function)rr\ rrcheZdZdZej Zddfd ZdZdZdZ dZ d Z fd Z xZ S) rv_histograma3 Generates a distribution given by a histogram. This is useful to generate a template distribution from a binned datasample. As a subclass of the `rv_continuous` class, `rv_histogram` inherits from it a collection of generic methods (see `rv_continuous` for the full list), and implements them based on the properties of the provided binned datasample. Parameters ---------- histogram : tuple of array_like Tuple containing two array_like objects. The first containing the content of n bins, the second containing the (n+1) bin boundaries. In particular, the return value of `numpy.histogram` is accepted. density : bool, optional If False, assumes the histogram is proportional to counts per bin; otherwise, assumes it is proportional to a density. For constant bin widths, these are equivalent, but the distinction is important when bin widths vary (see Notes). If None (default), sets ``density=True`` for backwards compatibility, but warns if the bin widths are variable. Set `density` explicitly to silence the warning. .. versionadded:: 1.10.0 Notes ----- When a histogram has unequal bin widths, there is a distinction between histograms that are proportional to counts per bin and histograms that are proportional to probability density over a bin. If `numpy.histogram` is called with its default ``density=False``, the resulting histogram is the number of counts per bin, so ``density=False`` should be passed to `rv_histogram`. If `numpy.histogram` is called with ``density=True``, the resulting histogram is in terms of probability density, so ``density=True`` should be passed to `rv_histogram`. To avoid warnings, always pass ``density`` explicitly when the input histogram has unequal bin widths. There are no additional shape parameters except for the loc and scale. The pdf is defined as a stepwise function from the provided histogram. The cdf is a linear interpolation of the pdf. .. versionadded:: 0.19.0 Examples -------- Create a scipy.stats distribution from a numpy histogram >>> import scipy.stats >>> import numpy as np >>> data = scipy.stats.norm.rvs(size=100000, loc=0, scale=1.5, ... random_state=123) >>> hist = np.histogram(data, bins=100) >>> hist_dist = scipy.stats.rv_histogram(hist, density=False) Behaves like an ordinary scipy rv_continuous distribution >>> hist_dist.pdf(1.0) 0.20538577847618705 >>> hist_dist.cdf(2.0) 0.90818568543056499 PDF is zero above (below) the highest (lowest) bin of the histogram, defined by the max (min) of the original dataset >>> hist_dist.pdf(np.max(data)) 0.0 >>> hist_dist.cdf(np.max(data)) 1.0 >>> hist_dist.pdf(np.min(data)) 7.7591907244498314e-05 >>> hist_dist.cdf(np.min(data)) 0.0 PDF and CDF follow the histogram >>> import matplotlib.pyplot as plt >>> X = np.linspace(-5.0, 5.0, 100) >>> fig, ax = plt.subplots() >>> ax.set_title("PDF from Template") >>> ax.hist(data, density=True, bins=100) >>> ax.plot(X, hist_dist.pdf(X), label='PDF') >>> ax.plot(X, hist_dist.cdf(X), label='CDF') >>> ax.legend() >>> fig.show() N)densityct||_||_t|dk7r tdt j |d|_t j |d|_t|j dzt|jk7r td|jdd|jddz |_t j|j|jd }|#|r!d}tj|td d }n |s|j |jz |_|j tt j|j |jzz |_t j|j |jz|_t j"d |j d g|_t j"d |j g|_|jdx|d <|_|jdx|d <|_t)|T|i|y)a5 Create a new distribution using the given histogram Parameters ---------- histogram : tuple of array_like Tuple containing two array_like objects. The first containing the content of n bins, the second containing the (n+1) bin boundaries. In particular, the return value of np.histogram is accepted. density : bool, optional If False, assumes the histogram is proportional to counts per bin; otherwise, assumes it is proportional to a density. For constant bin widths, these are equivalent. If None (default), sets ``density=True`` for backward compatibility, but warns if the bin widths are variable. Set `density` explicitly to silence the warning. rTz)Expected length 2 for parameter histogramrrzbNumber of elements in histogram content and histogram boundaries do not match, expected n and n+1.NrzjBin widths are not constant. Assuming `density=True`.Specify `density` explicitly to silence this warning.rJTrrr) _histogram_densityrrrOr_hpdf_hbins _hbin_widthsallcloserLrMrNrTrcumsum_hcdfhstackrrr@rO)rD histogramrq rFr bins_varyrPrs r5rOzrv_histogram.__init__ /s&$ y>Q HI IZZ ! - jj1. tzz?Q #dkk"2 234 4!KKOdkk#2.>> D$5$5t7H7H7KLL ?yOG MM'>a @Gd&7&77DJZZ%tzzD YYTZZ56 YYTZZ01 #{{1~-s df#{{2.s df $)&)r7c`|jtj|j|dS)z& PDF of the histogram r+)side)ru rO searchsortedrv rs r5rqzrv_histogram._pdf=/s$zz"//$++qwGHHr7cXtj||j|jS)z3 CDF calculated from the histogram )rOinterprv rz rs r5rtzrv_histogram._cdfC/syyDKK44r7cXtj||j|jS)zC Percentile function calculated from the histogram )rOr rz rv rs r5r}zrv_histogram._ppfI/syyDJJ 44r7c|jdd|dzz|jdd|dzzz |dzz }tj|jdd|zS)z$Compute the n-th non-central moment.rNr)rv rOrru )rDra integralss r5rzrv_histogram._munpO/s[[[_qs+dkk#2.>1.EE!A#N vvdjj2&233r7c|jdd}tj|dkD|tjd}tj ||z|j z S)zCompute entropy of distributionrrrr)ru rrrOrrrw )rDhpdfrs r5rzrv_histogram._entropyT/sOzz!BoodSj$3GtczD$5$55666r7c`t|}|j|d<|j|d<|S)zF Set the histogram as additional constructor argument r| rq )r@_updated_ctor_paramrs rt )rDdctrs r5r z rv_histogram._updated_ctor_paramZ/s2g)+??KI r7)rrrrrrrOrqrtr}rrr rrs@r5rp rp .sDZv"//M15.*`I 5 5 4 7 r7rp c@eZdZdZdZdZfdZdZdZdZ xZ S)studentized_range_genuOA 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|dkD|dkDzSrr)rDrrs r5rbzstudentized_range_gen._argcheck/sA"q&!!r7ctdddtjfd}tdddtjfd}||gS)NrFrr rrrg)rDrr s r5rjz!studentized_range_gen._shape_info/s< UQK @uq"&&k>BCyr7c&t||dS)N)rTrrLrWrXs r5rzstudentized_range_gen._fitstart/sw F 33r7cd|j\fd}tj|dd}tj||||tjdS)N_studentized_range_momentctj||}||||g}tj|tj j t j}tjt |}tj tjfdtjf fg}tdd}tj|||dS)Nrr-q=rrrangesopts)r_studentized_range_pdf_logconstrOrrTrrrr rrhdictrnquad) rrr log_constargusr_datarr r rr cython_symbols r5_single_momentz3studentized_range_gen._munp.._single_moment/s>>q"EIaY'CxxU+22::6??KH"..v}hOCw'!RVVr2h?FuU3D??3vDA!D Dr7rrr r)rrO frompyfuncrr) rDrrrr ufuncrrr s @@@r5rzstudentized_range_gen._munp/sV3 ""$B E na3zz%1b/._single_pdf/sF{ 8 "BB1bI !R+88C/66>>vOFF7BFF+a[9!D !f88C/66>>vOFF7BFF+,"..v}hOCuU3D??3vDA!D Dr7rrr r)rOr rr)rDrprrr r s r5rqzstudentized_range_gen._pdf/s> E( k1a0zz%1b/._single_cdf 0s F{ 8 "BB1bI !R+88C/66>>vOFF7BFF+a[9!D !f88C/66>>vOFF7BFF+,"..v}hOCuU3D??3vDA!D Dr7rrr rr)rOr r rr)rDrprrr r s r5rtzstudentized_range_gen._cdf 0sM E, k1a0wwrzz%1b/DRH!QOOr7) rrrrrbrjrrrqrtrrs@r5r r d/s+hT" 4A*A2Pr7r studentized_range)rrrc\eZdZdZdZdZdZdZdZdZ e e fdZ xZ S) rel_breitwigner_genaA 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 |dkDSr3rrDrhos r5rbzrel_breitwigner_gen._argchecki0s Qwr7c@tdddtjfdgS)Nr Frr rgris r5rjzrel_breitwigner_gen._shape_infol0rb r7c 6tjddd|dzz zzdtjdd|dzz zzz dztjz }tjd5|||z ||zz|z dzdzz cdddS#1swYyxYw)NrTrr8rp)rOrrr;)rDrpr rGs r5rqzrel_breitwigner_gen._pdfo0s GG QsAvX !bgga!CF(l&;"; <   [[h ' :!c'AG,S014q89 : : :s .BBc tjddtjdd|dzz zzz tjz }tjdd|z ztj|tj| |dzzz z}|dztj|z}tj |ddS)NrTrrr- )rOrrrimagr )rDrpr rGr s r5rtzrel_breitwigner_gen._cdfw0s GGAq2771qax<001 2255 8 GGBCK ii"''3$b/223 4 Q(wwvtQ''r7c R|dk(ry|dk(rtjddd|dzz zzdtjdd|dzz zzz tjz |z}|tjdz tj|zzS|dk(rtjdd|dzz zddtjdd|dzz zzzz |z}d|dzz tjdd|z z z }d|ztj|zStj S)NrrrrTr- r)rOrrrrrh)rDrar rGr s r5rzrel_breitwigner_gen._munp0s 6 6Q36\"a"''!aQh,*?&?@Aa"))C.01 1 6QsAvX!q2771qax<+@'@"ABA#(lbggb2c6k&::Fq52776?* *66Mr7cFddtjtjfSrMrr s r5rzrel_breitwigner_gen._stats0sT266266))r7ct||||\}}}}t|t}|r!|jdk(r|j}d}||rt ||g|i|S|8tj||z gd\}} } | |z } | | z } |s| g}d|vr(| |d<n"tj||z } | |z } |s| g}t ||g|i|S)NrF)rrg?r.) rKr>r)r?rCr@rBrOquantiler)rDrErFr4r rrrGrrrscale_0rho_0M_0rs r5rBzrel_breitwigner_gen.fit0s!< $d! avdL1   "a'''  <87;t3d3d3 3 >KKt 5FGMCcCiG'MEwd" 'W ))D4K(C&LEww{4/$/$//r7)rrrrrbrjrqrtrrr rrBrrs@r5r r +0sA<zG: (&* M* 0+ 0r7r rel_breitwignerrM(LrLcollections.abcr functoolsrrrrnumpyrOnumpy.polynomialrscipy.interpolaterscipy._lib.doccerr r r scipy._lib._ccallbackr scipyr r scipy.specialspecialrvscipy.special._ufuncsrrmscipy._lib._utilrscipy._lib.array_api_extra_libarray_api_extrarrTr_tukeylambda_statsrr rr _distn_infrastructurerrrrrrrrr_ksstatsrrr _constantsr!r"r#r$r%r&r'r(_censored_datar)scipy.optimizer*scipy.stats._warnings_errorsr+ scipy.statsrr6rJrYr[rrrrrrrrrrrrrrrrrrrrrrrr3r5rHrrJrVr^rbrdrmrrr r!r#r^r`rrrtrrrrrrrrr rr$r&rVrXrqrsrrrrrrrrrrrrrrrr*r,r[rQrq_supportrsrrrrrrrrrr$r&rrHrUrWrvrxrrrrrrrrrr rrr.rLrNr^rcrorqrzr|rrrrrrr4r6rDrFr[r]rhrjryr{rrrrrrKrrrrrrrrr!r0r4r6r[rerrrtrrrrrrrrrrr r r r8 r: rS rU rr r r r r r r r r r r r r r r r* r, rB rF rX rY r[ ri rk r r r r r r r r r r r r r r r& r+ rT r9 r; rs ru r r r r r rr r r rrr r r r) r+ r4 r6 r[ r^ r` rn rp r rhr r r listglobalsritemspairs _distn_names_distn_gen_names__all__rr7r5r s $, '%773##(((BJJJ21HHH(&17&*.W! W!t C3W-Z) Z)| !sc85M5p Ck 2 bggag  $+(m}m`V3' 3'l Cg&((V ruufQh"%%' 9*'-*'Z s 3  :   X  z }z z#6*lMl^ Ck 2 4#=4#n #: 6wE}wEt#F#T2T2n c )OxOd#F#I"I"X  "NRmNRb% UD}UDp#F#4#4#n ruufH 5J6J6Z  "D-DN&0ABE=EP Z (j( j(Z Cg&K!MK!\ { + &&E4ME4P Ck 2 23=23j #J /JmJZ-8 -.]-.`c 5 k@Mk@\ Cc;=;| #J /^Fm^FB-8 h!=h!V(-?@&D4mD4N-8 R0mR0j=1 rMrj Ck 2 =;==;@ #J /h"]h"V . )dO Od Cg&4040n c )]F=]F@ #J //%-/%d&2CDb bJ"7 ->=->` #J /*~=~B Z (K=K\ Z (W]Wtc 5 {}{| #N; P=Pf #J /+M+\ { + 5]5pcS| < W=Wt #J /T!=T!n #J /ymyx -8 P2}P2f ^4 @2]@2Fal 3 a Ma H { + 56M56p C3[ 9 ZMZz { + VVr  "E-EP 9 %])]])@,1EF.*bb.}b.J#F#b.b.J c )q7=q7h Z (r@=r@j Z (^]^@c 5 C!-C!L ) ,:-:-z c )>0->0B ) ,;P;P| c )LILI^  "JIJIZ c )Y$ Y$x wa#=a#H #J /  Z }Z z#F#]m]@% oCMoCd sODmDN5[![!| c )6! 6!r Cg&AD=ADH Z (W4=W4t #: 640}40n #N; 31M31l { + :3 :3z DCg.v=vr #J /c?]c?T .  .   <&}<&~#F#}&M}&@ { +  39 39l"Co> 9&}9&x $#NC @']@'F . ^F=^FB Z (gEMgET C3[ 9 FFR cSx 0<4]<4~c 5  0 9%Pk.Mk.\ {A 6  zmzz -8 ! 8.m8.v=1  L t(-t(n s 3o=od Z (v_E :&|:&z#F#A$]A$FcQruuW< @ ]-]@ 9 %=>m=>@ 6 e6me6P=;ST  *G) G)T w)<sKr=rj@PM@PF*/Ba,.FF4Q0-Q0h&2CD WY^^  # # %&!7}!M  ) )^,< <r7