403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/stats/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/stats/__pycache__/_discrete_distns.cpython-311.pyc
�

d�c������ddlmZddlZddlmZddlmZmZmZm	Z
mZddlm
Z
mZddlmZddlmZmZmZmZmZmZmZmZmZmZddlZdd	lmZmZm Z m!Z!ddl"m#cm$Z$dd
l%m&Z&m'Z'm(Z(d�Z)Gd�d
e��Z*e*d���Z+Gd�de*��Z,e,dd���Z-Gd�de��Z.e.d���Z/Gd�de��Z0e0d���Z1Gd�de��Z2e2ddd���Z3Gd�d e��Z4e4d!���Z5Gd"�d#e��Z6e6d$���Z7Gd%�d&e��Z8e8dd'd(���Z9Gd)�d*e��Z:e:d+d,�-��Z;Gd.�d/e��Z<e<dd0d1���Z=Gd2�d3e��Z>e>d4dd5�6��Z?Gd7�d8e��Z@e@d9d:�-��ZAGd;�d<e��ZBeBdd=d>���ZCd?�ZDd@�ZEdA�ZFGdB�dCe��ZGeGddDdE���ZHGdF�dGe��ZIeIejJdHdI���ZKGdJ�dKe��ZLeLejJdLdM���ZMGdN�dOe��ZNeNdPd�Q��ZOdR�ZPGdS�dTe��ZQGdU�dVeQ��ZReRdWdX�-��ZSGdY�dZeQ��ZTeTd[d\�-��ZUeVeW���X���Y����ZZeeZe��\Z[Z\e[e\zZ]dS)]�)�partialN)�special)�entr�	logsumexp�betaln�gammaln�zeta)�
_lazywhere�rng_integers)�interp1d)
�floor�ceil�log�exp�sqrt�log1p�expm1�tanh�cosh�sinh�)�rv_discrete�get_distribution_names�_check_shape�
_ShapeInfo)�_PyFishersNCHypergeometric�_PyWalleniusNCHypergeometric�_PyStochasticLib3c�2�|tj|��kS�N)�np�round��xs �>/usr/lib/python3/dist-packages/scipy/stats/_discrete_distns.py�_isintegralr&s����������c�^�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
dd�Zd�ZdS)�	binom_genaA binomial discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `binom` is:

    .. math::

       f(k) = \binom{n}{k} p^k (1-p)^{n-k}

    for :math:`k \in \{0, 1, \dots, n\}`, :math:`0 \leq p \leq 1`

    `binom` takes :math:`n` and :math:`p` as shape parameters,
    where :math:`p` is the probability of a single success
    and :math:`1-p` is the probability of a single failure.

    %(after_notes)s

    %(example)s

    See Also
    --------
    hypergeom, nbinom, nhypergeom

    c�b�tdddtjfd��tdddd��gS�	N�nTr�TF�pF�rr�TT�rr!�inf��selfs r%�_shape_infozbinom_gen._shape_info9�4���3��q�"�&�k�=�A�A��3��v�|�<�<�>�	>r'Nc�0�|�|||��Sr )�binomial�r4r,r.�size�random_states     r%�_rvszbinom_gen._rvs=s���$�$�Q��4�0�0�0r'c�J�|dkt|��z|dkz|dkzS�Nrr�r&�r4r,r.s   r%�	_argcheckzbinom_gen._argcheck@s)���Q��+�a�.�.�(�A��F�3�q�A�v�>�>r'c��|j|fSr ��ar@s   r%�_get_supportzbinom_gen._get_supportCs���v�q�y�r'c��t|��}t|dz��t|dz��t||z
dz��zz
}|tj||��ztj||z
|��zS�Nr)r
�gamlnr�xlogy�xlog1py)r4r$r,r.�k�combilns      r%�_logpmfzbinom_gen._logpmfFsl���!�H�H����1��:�:��q��s���e�A�a�C��E�l�l�!:�;�����q�!�,�,�,�w��q��s�Q�B�/G�/G�G�Gr'c�.�tj|||��Sr )�_boost�
_binom_pdf�r4r$r,r.s    r%�_pmfzbinom_gen._pmfKs��� ��A�q�)�)�)r'c�L�t|��}tj|||��Sr )r
rO�
_binom_cdf�r4r$r,r.rKs     r%�_cdfzbinom_gen._cdfO�"���!�H�H��� ��A�q�)�)�)r'c�L�t|��}tj|||��Sr )r
rO�	_binom_sfrUs     r%�_sfz
binom_gen._sfSs"���!�H�H�����1�a�(�(�(r'c�.�tj|||��Sr )rO�
_binom_isfrQs    r%�_isfzbinom_gen._isfW���� ��A�q�)�)�)r'c�.�tj|||��Sr )rO�
_binom_ppf)r4�qr,r.s    r%�_ppfzbinom_gen._ppfZr^r'�mvc���tj||��}tj||��}d\}}d|vrtj||��}d|vrtj||��}||||fS)N�NN�srK)rO�_binom_mean�_binom_variance�_binom_skewness�_binom_kurtosis_excess)r4r,r.�moments�mu�var�g1�g2s        r%�_statszbinom_gen._stats]ss��
�
��1�
%�
%���$�Q��*�*�����B��'�>�>��'��1�-�-�B��'�>�>��.�q�!�4�4�B��3��B��r'c��tjd|dz�}|�|||��}tjt	|��d���S)Nrr��axis)r!�r_rR�sumr)r4r,r.rK�valss     r%�_entropyzbinom_gen._entropygsE���E�!�A��E�'�N���y�y��A�q�!�!���v�d�4�j�j�q�)�)�)�)r're�rc��__name__�
__module__�__qualname__�__doc__r5r<rArErMrRrVrZr]rbrprw�r'r%r)r)s���������6>�>�>�1�1�1�1�?�?�?����H�H�H�
*�*�*�*�*�*�)�)�)�*�*�*�*�*�*�����*�*�*�*�*r'r)�binom)�namec�\�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZdS)�
bernoulli_genaA Bernoulli discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `bernoulli` is:

    .. math::

       f(k) = \begin{cases}1-p  &\text{if } k = 0\\
                           p    &\text{if } k = 1\end{cases}

    for :math:`k` in :math:`\{0, 1\}`, :math:`0 \leq p \leq 1`

    `bernoulli` takes :math:`p` as shape parameter,
    where :math:`p` is the probability of a single success
    and :math:`1-p` is the probability of a single failure.

    %(after_notes)s

    %(example)s

    c�(�tdddd��gS�Nr.Fr/r0�rr3s r%r5zbernoulli_gen._shape_info�����3��v�|�<�<�=�=r'Nc�@�t�|d|||���S)Nr�r:r;)r)r<�r4r.r:r;s    r%r<zbernoulli_gen._rvs�s���~�~�d�A�q�t�,�~�O�O�Or'c��|dk|dkzSr>r~�r4r.s  r%rAzbernoulli_gen._argcheck�s���Q��1��6�"�"r'c��|j|jfSr )rD�br�s  r%rEzbernoulli_gen._get_support�s���v�t�v�~�r'c�:�t�|d|��SrG)rrM�r4r$r.s   r%rMzbernoulli_gen._logpmf�s���}�}�Q��1�%�%�%r'c�:�t�|d|��SrG)rrRr�s   r%rRzbernoulli_gen._pmf�s���z�z�!�Q��"�"�"r'c�:�t�|d|��SrG)rrVr�s   r%rVzbernoulli_gen._cdf�����z�z�!�Q��"�"�"r'c�:�t�|d|��SrG)rrZr�s   r%rZzbernoulli_gen._sf�s���y�y��A�q�!�!�!r'c�:�t�|d|��SrG)rr]r�s   r%r]zbernoulli_gen._isf�r�r'c�:�t�|d|��SrG)rrb)r4rar.s   r%rbzbernoulli_gen._ppf�r�r'c�8�t�d|��SrG)rrpr�s  r%rpzbernoulli_gen._stats�s���|�|�A�q�!�!�!r'c�F�t|��td|z
��zSrG)rr�s  r%rwzbernoulli_gen._entropy�s���A�w�w��a��c���"�"r'reryr~r'r%r�r�ps���������0>�>�>�P�P�P�P�#�#�#����&�&�&�#�#�#�
#�#�#�"�"�"�#�#�#�#�#�#�"�"�"�#�#�#�#�#r'r��	bernoulli)r�r�c�@�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	dd
�Z
dS)
�
betabinom_genaA beta-binomial discrete random variable.

    %(before_notes)s

    Notes
    -----
    The beta-binomial distribution is a binomial distribution with a
    probability of success `p` that follows a beta distribution.

    The probability mass function for `betabinom` is:

    .. math::

       f(k) = \binom{n}{k} \frac{B(k + a, n - k + b)}{B(a, b)}

    for :math:`k \in \{0, 1, \dots, n\}`, :math:`n \geq 0`, :math:`a > 0`,
    :math:`b > 0`, where :math:`B(a, b)` is the beta function.

    `betabinom` takes :math:`n`, :math:`a`, and :math:`b` as shape parameters.

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Beta-binomial_distribution

    %(after_notes)s

    .. versionadded:: 1.4.0

    See Also
    --------
    beta, binom

    %(example)s

    c��tdddtjfd��tdddtjfd��tdddtjfd��gS)	Nr,Trr-rDF�FFr�r1r3s r%r5zbetabinom_gen._shape_info�sS���3��q�"�&�k�=�A�A��3���2�6�{�N�C�C��3���2�6�{�N�C�C�E�	Er'Nc�^�|�|||��}|�|||��Sr )�betar8)r4r,rDr�r:r;r.s       r%r<zbetabinom_gen._rvs�s1�����a��D�)�)���$�$�Q��4�0�0�0r'c�
�d|fS�Nrr~�r4r,rDr�s    r%rEzbetabinom_gen._get_support�����!�t�r'c�J�|dkt|��z|dkz|dkzSr�r?r�s    r%rAzbetabinom_gen._argcheck�s)���Q��+�a�.�.�(�A��E�2�a�!�e�<�<r'c���t|��}t|dz��t||z
dz|dz��z
}|t||z||z
|z��zt||��z
SrG)r
rr)r4r$r,rDr�rKrLs       r%rMzbetabinom_gen._logpmf�sg���!�H�H���q�1�u�:�:�+��q�1�u�q�y�!�a�%� 8� 8�8�����A��q�1�u�q�y�1�1�1�F�1�a�L�L�@�@r'c�L�t|�||||����Sr �rrM)r4r$r,rDr�s     r%rRzbetabinom_gen._pmf�s"���4�<�<��1�a��+�+�,�,�,r'rcc��|||zz}d|z
}||z}|||z|zz|z|z||zdzz}d\}	}
d|vr7dt|��z}	|	||zd|zz||z
zz}	|	||zdz||zzz}	d|vr�||z}
|
||zdz
d|zzz}
|
d|z|z|dz
zz
}
|
d|dzzz
}
|
d|z|z|zd|z
zz}
|
d	|z|z|dzzz}
|
||zdzd|z|zzz}
|
||z|z||zdzz||zdzz||z|zzz}
|
dz}
|||	|
fS)
Nrrerf��?�rK����r)r4r,rDr�rk�e_p�e_qrlrmrnros           r%rpzbetabinom_gen._stats�s����1�q�5�k���#�g��
��W���1�q�5�1�9�o��#�c�)�Q��U�Q�Y�7�����B��'�>�>��t�C�y�y��B��1�q�5�1�q�5�=�Q��U�+�+�B��1�q�5�1�9��Q��'�'�B��'�>�>��Q��B��1�q�5�1�9�q�1�u�$�%�B��!�a�%�!�)�q�1�u�%�%�B��!�a�1�f�*��B��!�c�'�A�+��/�Q��U�+�+�B��"�s�(�S�.�1��6�)�)�B��1�q�5�Q�,�!�a�%�!�)�,�,�B��1�q�5�1�9��A���	�*�a�!�e�a�i�8�A��E�A�I�F�G�B��!�G�B��3��B��r'rerx)rzr{r|r}r5r<rErArMrRrpr~r'r%r�r��s�������"�"�FE�E�E�
1�1�1�1����=�=�=�A�A�A�
-�-�-������r'r��	betabinomc�V�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�ZdS)�
nbinom_gena�A negative binomial discrete random variable.

    %(before_notes)s

    Notes
    -----
    Negative binomial distribution describes a sequence of i.i.d. Bernoulli
    trials, repeated until a predefined, non-random number of successes occurs.

    The probability mass function of the number of failures for `nbinom` is:

    .. math::

       f(k) = \binom{k+n-1}{n-1} p^n (1-p)^k

    for :math:`k \ge 0`, :math:`0 < p \leq 1`

    `nbinom` takes :math:`n` and :math:`p` as shape parameters where :math:`n`
    is the number of successes, :math:`p` is the probability of a single
    success, and :math:`1-p` is the probability of a single failure.

    Another common parameterization of the negative binomial distribution is
    in terms of the mean number of failures :math:`\mu` to achieve :math:`n`
    successes. The mean :math:`\mu` is related to the probability of success
    as

    .. math::

       p = \frac{n}{n + \mu}

    The number of successes :math:`n` may also be specified in terms of a
    "dispersion", "heterogeneity", or "aggregation" parameter :math:`\alpha`,
    which relates the mean :math:`\mu` to the variance :math:`\sigma^2`,
    e.g. :math:`\sigma^2 = \mu + \alpha \mu^2`. Regardless of the convention
    used for :math:`\alpha`,

    .. math::

       p &= \frac{\mu}{\sigma^2} \\
       n &= \frac{\mu^2}{\sigma^2 - \mu}

    %(after_notes)s

    %(example)s

    See Also
    --------
    hypergeom, binom, nhypergeom

    c�b�tdddtjfd��tdddd��gSr+r1r3s r%r5znbinom_gen._shape_info<r6r'Nc�0�|�|||��Sr )�negative_binomialr9s     r%r<znbinom_gen._rvs@s���-�-�a��D�9�9�9r'c�*�|dk|dkz|dkzSr>r~r@s   r%rAznbinom_gen._argcheckCs���A��!�a�%� �A��F�+�+r'c�.�tj|||��Sr )rO�_nbinom_pdfrQs    r%rRznbinom_gen._pmfFs���!�!�Q��*�*�*r'c���t||z��t|dz��z
t|��z
}||t|��zztj||��zSrG)rHrrrJ)r4r$r,r.�coeffs     r%rMznbinom_gen._logpmfJsS���a��c�
�
�U�1�Q�3�Z�Z�'�%��(�(�2���q��Q���x��'�/�!�a�R�"8�"8�8�8r'c�L�t|��}tj|||��Sr )r
rO�_nbinom_cdfrUs     r%rVznbinom_gen._cdfNs"���!�H�H���!�!�Q��*�*�*r'c�D�t|��}|�|||��}|dk}d�}|}tjd���5|||||||��||<tj||��||<ddd��n#1swxYwY|S)N��?c�`�tjtj|dz|d|z
����SrG)r!rr�betainc)rKr,r.s   r%�f1znbinom_gen._logcdf.<locals>.f1Ws+���8�W�_�Q��U�A�q�1�u�=�=�=�>�>�>r'�ignore)�divide)r
rVr!�errstater)	r4r$r,r.rK�cdf�condr��logcdfs	         r%�_logcdfznbinom_gen._logcdfRs����!�H�H���i�i��1�a� � ���S�y��	?�	?�	?���
�[��
)�
)�
)�	/�	/��2�a��g�q��w��$��8�8�F�4�L��F�3��u�:�.�.�F�D�5�M�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/��
s�AB�B�Bc�L�t|��}tj|||��Sr )r
rO�
_nbinom_sfrUs     r%rZznbinom_gen._sfarWr'c��tj��5d}tjd|���tj|||��cddd��S#1swxYwYdS)Nz#overflow encountered in _nbinom_isfr���message)�warnings�catch_warnings�filterwarningsrO�_nbinom_isf)r4r$r,r.r�s     r%r]znbinom_gen._isfes���
�
$�
&�
&�	/�	/�;�G��#�H�g�>�>�>�>��%�a��A�.�.�		/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/��.A�A�Ac��tj��5d}tjd|���tj|||��cddd��S#1swxYwYdS)Nz#overflow encountered in _nbinom_ppfr�r�)r�r�r�rO�_nbinom_ppf)r4rar,r.r�s     r%rbznbinom_gen._ppfls���
�
$�
&�
&�	/�	/�;�G��#�H�g�>�>�>�>��%�a��A�.�.�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/�	/����	/�	/�	/�	/�	/�	/r�c��tj||��tj||��tj||��tj||��fSr )rO�_nbinom_mean�_nbinom_variance�_nbinom_skewness�_nbinom_kurtosis_excessr@s   r%rpznbinom_gen._statsrsL�����1�%�%��#�A�q�)�)��#�A�q�)�)��*�1�a�0�0�	
�	
r're)rzr{r|r}r5r<rArRrMrVr�rZr]rbrpr~r'r%r�r�	s�������1�1�d>�>�>�:�:�:�:�,�,�,�+�+�+�9�9�9�+�+�+�
�
�
�*�*�*�/�/�/�/�/�/�
�
�
�
�
r'r��nbinomc�P�eZdZdZd�Zd
d�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
dS)�geom_gena�A geometric discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `geom` is:

    .. math::

        f(k) = (1-p)^{k-1} p

    for :math:`k \ge 1`, :math:`0 < p \leq 1`

    `geom` takes :math:`p` as shape parameter,
    where :math:`p` is the probability of a single success
    and :math:`1-p` is the probability of a single failure.

    %(after_notes)s

    See Also
    --------
    planck

    %(example)s

    c�(�tdddd��gSr�r�r3s r%r5zgeom_gen._shape_info�r�r'Nc�0�|�||���S�N�r:)�	geometricr�s    r%r<z
geom_gen._rvs�s���%�%�a�d�%�3�3�3r'c��|dk|dkzS�Nrrr~r�s  r%rAzgeom_gen._argcheck�s���Q��1�q�5�!�!r'c�>�tjd|z
|dz
��|zSrG)r!�power�r4rKr.s   r%rRz
geom_gen._pmf�s!���x��!��Q�q�S�!�!�A�%�%r'c�T�tj|dz
|��t|��zSrG)rrJrr�s   r%rMzgeom_gen._logpmf�s%����q�1�u�q�b�)�)�C��F�F�2�2r'c�b�t|��}tt|��|z��Sr )r
rr�r4r$r.rKs    r%rVz
geom_gen._cdf�s*���!�H�H���e�Q�B�i�i��k�"�"�"�"r'c�R�tj|�||����Sr )r!r�_logsfr�s   r%rZzgeom_gen._sf�s ���v�d�k�k�!�Q�'�'�(�(�(r'c�F�t|��}|t|��zSr )r
rr�s    r%r�zgeom_gen._logsf�s���!�H�H�����r���{�r'c���tt|��t|��z��}|�|dz
|��}tj||k|dkz|dz
|��Sr�)rrrVr!�where)r4rar.rv�temps     r%rbz
geom_gen._ppf�s`���E�1�"�I�I��q�b�	�	�)�*�*���y�y��a���#�#���x����t�a�x�0�$�q�&�$�?�?�?r'c��d|z}d|z
}||z|z}d|z
t|��z}tjgd�|��d|z
z}||||fS)Nr��@)ri����r�)rr!�polyval)r4r.rl�qrrmrnros       r%rpzgeom_gen._stats�sa��
��U��
��U���1�f�q�j���!�e�t�B�x�x�
��
�Z�
�
�
�A�
&�
&��A��
.���3��B��r're)rzr{r|r}r5r<rArRrMrVrZr�rbrpr~r'r%r�r�~s���������8>�>�>�4�4�4�4�"�"�"�&�&�&�3�3�3�#�#�#�)�)�)����@�@�@�
����r'r��geomzA geometric)rDr��longnamec�\�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZdS)�
hypergeom_genaA hypergeometric discrete random variable.

    The hypergeometric distribution models drawing objects from a bin.
    `M` is the total number of objects, `n` is total number of Type I objects.
    The random variate represents the number of Type I objects in `N` drawn
    without replacement from the total population.

    %(before_notes)s

    Notes
    -----
    The symbols used to denote the shape parameters (`M`, `n`, and `N`) are not
    universally accepted.  See the Examples for a clarification of the
    definitions used here.

    The probability mass function is defined as,

    .. math:: p(k, M, n, N) = \frac{\binom{n}{k} \binom{M - n}{N - k}}
                                   {\binom{M}{N}}

    for :math:`k \in [\max(0, N - M + n), \min(n, N)]`, where the binomial
    coefficients are defined as,

    .. math:: \binom{n}{k} \equiv \frac{n!}{k! (n - k)!}.

    %(after_notes)s

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.stats import hypergeom
    >>> import matplotlib.pyplot as plt

    Suppose we have a collection of 20 animals, of which 7 are dogs.  Then if
    we want to know the probability of finding a given number of dogs if we
    choose at random 12 of the 20 animals, we can initialize a frozen
    distribution and plot the probability mass function:

    >>> [M, n, N] = [20, 7, 12]
    >>> rv = hypergeom(M, n, N)
    >>> x = np.arange(0, n+1)
    >>> pmf_dogs = rv.pmf(x)

    >>> fig = plt.figure()
    >>> ax = fig.add_subplot(111)
    >>> ax.plot(x, pmf_dogs, 'bo')
    >>> ax.vlines(x, 0, pmf_dogs, lw=2)
    >>> ax.set_xlabel('# of dogs in our group of chosen animals')
    >>> ax.set_ylabel('hypergeom PMF')
    >>> plt.show()

    Instead of using a frozen distribution we can also use `hypergeom`
    methods directly.  To for example obtain the cumulative distribution
    function, use:

    >>> prb = hypergeom.cdf(x, M, n, N)

    And to generate random numbers:

    >>> R = hypergeom.rvs(M, n, N, size=10)

    See Also
    --------
    nhypergeom, binom, nbinom

    c��tdddtjfd��tdddtjfd��tdddtjfd��gS)N�MTrr-r,�Nr1r3s r%r5zhypergeom_gen._shape_info	�S���3��q�"�&�k�=�A�A��3��q�"�&�k�=�A�A��3��q�"�&�k�=�A�A�C�	Cr'Nc�:�|�|||z
||���Sr�)�hypergeometric)r4r�r,r�r:r;s      r%r<zhypergeom_gen._rvss#���*�*�1�a��c�1�4�*�@�@�@r'c�b�tj|||z
z
d��tj||��fSr��r!�maximum�minimum)r4r�r,r�s    r%rEzhypergeom_gen._get_supports-���z�!�Q�q�S�'�1�%�%�r�z�!�Q�'7�'7�7�7r'c��|dk|dkz|dkz}|||k||kzz}|t|��t|��zt|��zz}|Sr�r?)r4r�r,r�r�s     r%rAzhypergeom_gen._argchecks_���A��!�q�&�!�Q�!�V�,����a��A��F�#�#����A����Q���/�+�a�.�.�@�@���r'c�6�||}}||z
}t|dzd��t|dzd��zt||z
dz|dz��zt|dz||z
dz��z
t||z
dz||z
|zdz��z
t|dzd��z
}|SrG�r)	r4rKr�r,r��tot�good�bad�results	         r%rMzhypergeom_gen._logpmfs����q�T���D�j����a���#�#�f�S��U�A�&6�&6�6���A��a���1��9M�9M�M���1��d�1�f�Q�h�'�'�(�*0��1��Q���A��a���	�*B�*B�C���Q���"�"�#���
r'c�0�tj||||��Sr )rO�_hypergeom_pdf�r4rKr�r,r�s     r%rRzhypergeom_gen._pmf"����$�Q��1�a�0�0�0r'c�0�tj||||��Sr )rO�_hypergeom_cdfrs     r%rVzhypergeom_gen._cdf%rr'c�x�d|zd|zd|z}}}||z
}||dzzd|z||z
zz
d|z|zz
}||dz
|z|zz}|d|z|z||z
z|zd|zdz
zz
}|||z||z
z|z|dz
z|dz
zz}tj|||��tj|||��tj|||��|fS)Nr�rg@g@r�r��@)rO�_hypergeom_mean�_hypergeom_variance�_hypergeom_skewness)r4r�r,r��mros      r%rpzhypergeom_gen._stats(s���q�&�"�q�&�"�q�&�a�1��
��E���!�a�%�[�2��6�Q��U�+�
+�b�1�f�q�j�
8��
�q�1�u��k�A�o���
�b�1�f�q�j�A��E�"�Q�&�"�q�&�1�*�5�5��
�a�!�e�q�1�u�o��!�Q��V�,��B��7�7���"�1�a��+�+��&�q�!�Q�/�/��&�q�!�Q�/�/��	
�	
r'c���tj|||z
z
t||��dz�}|�||||��}tjt|��d���S)Nrrrr)r!rt�min�pmfrur)r4r�r,r�rKrvs      r%rwzhypergeom_gen._entropy9sY���E�!�q�1�u�+�c�!�Q�i�i�!�m�+�,���x�x��1�a��#�#���v�d�4�j�j�q�)�)�)�)r'c�0�tj||||��Sr )rO�
_hypergeom_sfrs     r%rZzhypergeom_gen._sf>s���#�A�q�!�Q�/�/�/r'c
���g}ttj||||���D]�\}}}}	|dz|dzz|dz
|	dz
zkrG|�t	t|�||||	���������ftj|dz|	dz��}
|�t|�	|
|||	��������tj
|��S)Nr�r)�zipr!�broadcast_arrays�appendrrr��arangerrM�asarray�r4rKr�r,r��res�quantrr�draw�k2s           r%r�zhypergeom_gen._logsfAs�����&)�2�+>�q�!�Q��+J�+J�&K�	I�	I�"�E�3��d�����c�	�*�d�S�j�T�C�Z�-H�H�H��
�
�5�#�d�k�k�%��d�D�&I�&I�"J�"J�!J�K�K�L�L�L�L��Y�u�q�y�$��(�3�3���
�
�9�T�\�\�"�c�4��%F�%F�G�G�H�H�H�H��z�#���r'c
���g}ttj||||���D]�\}}}}	|dz|dzz|dz
|	dz
zkrG|�t	t|�||||	���������ftjd|dz��}
|�t|�	|
|||	��������tj
|��S)Nr�rr)rr!rrrr�logsfrrrMrr s           r%r�zhypergeom_gen._logcdfMs�����&)�2�+>�q�!�Q��+J�+J�&K�	I�	I�"�E�3��d�����c�	�*�d�S�j�T�C�Z�-H�H�H��
�
�5�#�d�j�j���T�4�&H�&H�"I�"I�!I�J�J�K�K�K�K��Y�q�%�!�)�,�,���
�
�9�T�\�\�"�c�4��%F�%F�G�G�H�H�H�H��z�#���r're)rzr{r|r}r5r<rErArMrRrVrprwrZr�r�r~r'r%r�r��s�������A�A�DC�C�C�
A�A�A�A�8�8�8�������1�1�1�1�1�1�
�
�
�"*�*�*�
0�0�0�
�
�
�
�
�
�
�
r'r��	hypergeomc�>�eZdZdZd�Zd�Zd�Zd
d�Zd�Zd�Z	d	�Z
dS)�nhypergeom_genab
A negative hypergeometric discrete random variable.

    Consider a box containing :math:`M` balls:, :math:`n` red and
    :math:`M-n` blue. We randomly sample balls from the box, one
    at a time and *without* replacement, until we have picked :math:`r`
    blue balls. `nhypergeom` is the distribution of the number of
    red balls :math:`k` we have picked.

    %(before_notes)s

    Notes
    -----
    The symbols used to denote the shape parameters (`M`, `n`, and `r`) are not
    universally accepted. See the Examples for a clarification of the
    definitions used here.

    The probability mass function is defined as,

    .. math:: f(k; M, n, r) = \frac{{{k+r-1}\choose{k}}{{M-r-k}\choose{n-k}}}
                                   {{M \choose n}}

    for :math:`k \in [0, n]`, :math:`n \in [0, M]`, :math:`r \in [0, M-n]`,
    and the binomial coefficient is:

    .. math:: \binom{n}{k} \equiv \frac{n!}{k! (n - k)!}.

    It is equivalent to observing :math:`k` successes in :math:`k+r-1`
    samples with :math:`k+r`'th sample being a failure. The former
    can be modelled as a hypergeometric distribution. The probability
    of the latter is simply the number of failures remaining
    :math:`M-n-(r-1)` divided by the size of the remaining population
    :math:`M-(k+r-1)`. This relationship can be shown as:

    .. math:: NHG(k;M,n,r) = HG(k;M,n,k+r-1)\frac{(M-n-(r-1))}{(M-(k+r-1))}

    where :math:`NHG` is probability mass function (PMF) of the
    negative hypergeometric distribution and :math:`HG` is the
    PMF of the hypergeometric distribution.

    %(after_notes)s

    Examples
    --------
    >>> import numpy as np
    >>> from scipy.stats import nhypergeom
    >>> import matplotlib.pyplot as plt

    Suppose we have a collection of 20 animals, of which 7 are dogs.
    Then if we want to know the probability of finding a given number
    of dogs (successes) in a sample with exactly 12 animals that
    aren't dogs (failures), we can initialize a frozen distribution
    and plot the probability mass function:

    >>> M, n, r = [20, 7, 12]
    >>> rv = nhypergeom(M, n, r)
    >>> x = np.arange(0, n+2)
    >>> pmf_dogs = rv.pmf(x)

    >>> fig = plt.figure()
    >>> ax = fig.add_subplot(111)
    >>> ax.plot(x, pmf_dogs, 'bo')
    >>> ax.vlines(x, 0, pmf_dogs, lw=2)
    >>> ax.set_xlabel('# of dogs in our group with given 12 failures')
    >>> ax.set_ylabel('nhypergeom PMF')
    >>> plt.show()

    Instead of using a frozen distribution we can also use `nhypergeom`
    methods directly.  To for example obtain the probability mass
    function, use:

    >>> prb = nhypergeom.pmf(x, M, n, r)

    And to generate random numbers:

    >>> R = nhypergeom.rvs(M, n, r, size=10)

    To verify the relationship between `hypergeom` and `nhypergeom`, use:

    >>> from scipy.stats import hypergeom, nhypergeom
    >>> M, n, r = 45, 13, 8
    >>> k = 6
    >>> nhypergeom.pmf(k, M, n, r)
    0.06180776620271643
    >>> hypergeom.pmf(k, M, n, k+r-1) * (M - n - (r-1)) / (M - (k+r-1))
    0.06180776620271644

    See Also
    --------
    hypergeom, binom, nbinom

    References
    ----------
    .. [1] Negative Hypergeometric Distribution on Wikipedia
           https://en.wikipedia.org/wiki/Negative_hypergeometric_distribution

    .. [2] Negative Hypergeometric Distribution from
           http://www.math.wm.edu/~leemis/chart/UDR/PDFs/Negativehypergeometric.pdf

    c��tdddtjfd��tdddtjfd��tdddtjfd��gS)Nr�Trr-r,�rr1r3s r%r5znhypergeom_gen._shape_info�r�r'c�
�d|fSr�r~)r4r�r,r+s    r%rEznhypergeom_gen._get_support�r�r'c��|dk||kz|dkz|||z
kz}|t|��t|��zt|��zz}|Sr�r?)r4r�r,r+r�s     r%rAznhypergeom_gen._argcheck�sU���Q��1��6�"�a�1�f�-��a��c��:����A����Q���/�+�a�.�.�@�@���r'Nc�H��t�fd���}||||||���S)Nc�\����|||��\}}tj||dz��}��||||��}t	||dd���}	|	|�|������t��}
|�|
���S|
S)Nr�next�extrapolate)�kind�
fill_valuer�)	�supportr!rr�r�uniform�astype�int�item)r�r,r+r:r;rDr��ksr��ppf�rvsr4s           �r%�_rvs1z"nhypergeom_gen._rvs.<locals>._rvs1�s�����<�<��1�a�(�(�D�A�q���1�a��c�"�"�B��(�(�2�q�!�Q�'�'�C��3���M�J�J�J�C��#�l�*�*��*�5�5�6�6�=�=�c�B�B�C��|��x�x�z�z�!��Jr'r���_vectorize_rvs_over_shapes)r4r�r,r+r:r;r<s`      r%r<znhypergeom_gen._rvs�sD���	#�		�		�		�		�
$�	#�		��u�Q��1�4�l�C�C�C�Cr'c�R�|dk|dkz}t|||||fd�d���}|S)Nrc�"�t|dz|��t||zd��zt||z
dz||z
|z
dz��z
t||z
|z
dzd��zt|dz||z
dz��zt|dzd��z
SrGr)rKr�r,r+s    r%�<lambda>z(nhypergeom_gen._logpmf.<locals>.<lambda>�s���"(��1��a�.�.��6�!�A�#�q�>�>�!A�!'��!��A��q��s�1�u�Q�w�!7�!7�"8�:@��1��Q��q��!�:L�:L�"M�!'��!��Q�q�S��U�!3�!3�"4�6<�Q�q�S�!�n�n�"E�r'�)�	fillvalue)r
)r4rKr�r,r+r�rs       r%rMznhypergeom_gen._logpmf�sN���a��A��F�#���T�E�A�q�!�Q�<�F�F�'*�+�+�+���
r'c�L�t|�||||����Sr r�)r4rKr�r,r+s     r%rRznhypergeom_gen._pmf�s$���4�<�<��1�a��+�+�,�,�,r'c��d|zd|zd|z}}}||z||z
dzz}||dzz|z||z
dz||z
dzzzd|||z
dzzz
z}d\}}||||fS)Nr�rr�rer~)r4r�r,r+rlrmrnros        r%rpznhypergeom_gen._stats�s����Q�$��1��b��d�a�1��
�q�S�A�a�C��E�]����1��g�a�i�A�a�C��E�A�a�C��E�?�+�q�1��!��A��;��?�����B��3��B��r're)rzr{r|r}r5rErAr<rMrRrpr~r'r%r)r)]s�������b�b�HC�C�C�
������
D�D�D�D� ���-�-�-�
����r'r)�
nhypergeomc�2�eZdZdZd�Zdd�Zd�Zd�Zd�ZdS)	�
logser_gena�A Logarithmic (Log-Series, Series) discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `logser` is:

    .. math::

        f(k) = - \frac{p^k}{k \log(1-p)}

    for :math:`k \ge 1`, :math:`0 < p < 1`

    `logser` takes :math:`p` as shape parameter,
    where :math:`p` is the probability of a single success
    and :math:`1-p` is the probability of a single failure.

    %(after_notes)s

    %(example)s

    c�(�tdddd��gSr�r�r3s r%r5zlogser_gen._shape_infor�r'Nc�0�|�||���Sr�)�	logseriesr�s    r%r<zlogser_gen._rvss���%�%�a�d�%�3�3�3r'c��|dk|dkzSr>r~r�s  r%rAzlogser_gen._argcheck!s���A��!�a�%� � r'c�f�tj||��dz|ztj|��zS�Nr�)r!r�rrr�s   r%rRzlogser_gen._pmf$s/�����A�����$�q�(�7�=�!��+<�+<�<�<r'c��tj|��}||dz
z|z}||z|dz
dzz}|||zz
}||zd|zzd|z
dzz}|d|z|zz
d|dzzz}|tj|d��z}||zd|dz
dzzd|z|dz
dzzz
d|z|z|dz
dzzzz}	|	d|z|zz
d|z|z|zzd|dzzz
}
|
|dzzdz
}||||fS)	Nr�r�r���?rr��r)rrr!r�)r4r.r+rl�mu2prm�mu3p�mu3rn�mu4p�mu4ros            r%rpzlogser_gen._stats(s@���M�1�"����
�!�c�'�]�Q�
���r�A�v��S��1��$���R��U�l���r�A�v��Q���3��7�Q�,�.���Q�r�T�$�Y���2�q�5��(��
�2�8�C��%�%�
%���r�A�v��1�Q�3��(�N�Q�q�S�A��E�A�:�-�-��!��A���1��q��0@�@�B���Q�t�V�B�Y���4����2��-��"�a�%��7��
�3��6�\�C�
���3��B��r're)	rzr{r|r}r5r<rArRrpr~r'r%rHrHsn��������0>�>�>�4�4�4�4�
!�!�!�=�=�=�
�
�
�
�
r'rH�logserz
A logarithmicc�J�eZdZdZd�Zd�Zdd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
�poisson_gena�A Poisson discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `poisson` is:

    .. math::

        f(k) = \exp(-\mu) \frac{\mu^k}{k!}

    for :math:`k \ge 0`.

    `poisson` takes :math:`\mu \geq 0` as shape parameter.
    When :math:`\mu = 0`, the ``pmf`` method
    returns ``1.0`` at quantile :math:`k = 0`.

    %(after_notes)s

    %(example)s

    c�@�tdddtjfd��gS)NrlFrr-r1r3s r%r5zpoisson_gen._shape_infoTs���4���B�F��]�C�C�D�Dr'c��|dkSr�r~)r4rls  r%rAzpoisson_gen._argcheckXs���Q�w�r'Nc�.�|�||��Sr ��poisson)r4rlr:r;s    r%r<zpoisson_gen._rvs[s���#�#�B��-�-�-r'c�\�tj||��t|dz��z
|z
}|SrG)rrIrH)r4rKrl�Pks    r%rMzpoisson_gen._logpmf^s,��
�]�1�b�
!�
!�E�!�a�%�L�L�
0�2�
5���	r'c�H�t|�||����Sr r�)r4rKrls   r%rRzpoisson_gen._pmfbs���4�<�<��2�&�&�'�'�'r'c�J�t|��}tj||��Sr )r
r�pdtr�r4r$rlrKs    r%rVzpoisson_gen._cdffs���!�H�H���|�A�r�"�"�"r'c�J�t|��}tj||��Sr )r
r�pdtrcrds    r%rZzpoisson_gen._sfjs���!�H�H���}�Q��#�#�#r'c���ttj||����}tj|dz
d��}tj||��}tj||k||��Sr�)rr�pdtrikr!rrcr�)r4rarlrv�vals1r�s      r%rbzpoisson_gen._ppfnsY���G�N�1�b�)�)�*�*���
�4�!�8�Q�'�'���|�E�2�&�&���x���	�5�$�/�/�/r'c��|}tj|��}|dk}t||fd�tj��}t||fd�tj��}||||fS)Nrc�&�td|z��SrNr�r#s r%rAz$poisson_gen._stats.<locals>.<lambda>xs��d�3�q�5�k�k�r'c��d|zSrNr~r#s r%rAz$poisson_gen._stats.<locals>.<lambda>ys
��c�!�e�r')r!rr
r2)r4rlrm�tmp�
mu_nonzerornros       r%rpzpoisson_gen._statsts_�����j��n�n���1�W�
�
�
�S�F�,A�,A�2�6�
J�
J��
�
�S�F�O�O�R�V�
D�
D���3��B��r're)
rzr{r|r}r5rAr<rMrRrVrZrbrpr~r'r%rYrY;s���������0E�E�E����.�.�.�.����(�(�(�#�#�#�$�$�$�0�0�0�����r'rYr^z	A Poisson)r�r�c�P�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d
d
�Zd�Zd�Z
d	S)�
planck_genaA Planck discrete exponential random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `planck` is:

    .. math::

        f(k) = (1-\exp(-\lambda)) \exp(-\lambda k)

    for :math:`k \ge 0` and :math:`\lambda > 0`.

    `planck` takes :math:`\lambda` as shape parameter. The Planck distribution
    can be written as a geometric distribution (`geom`) with
    :math:`p = 1 - \exp(-\lambda)` shifted by ``loc = -1``.

    %(after_notes)s

    See Also
    --------
    geom

    %(example)s

    c�@�tdddtjfd��gS)N�lambdaFrr�r1r3s r%r5zplanck_gen._shape_info�s���8�U�Q���K��H�H�I�Ir'c��|dkSr�r~)r4�lambda_s  r%rAzplanck_gen._argcheck�s����{�r'c�L�t|��t||z��zSr )rr)r4rKrts   r%rRzplanck_gen._pmf�s$���w�h�����W�H�Q�J���/�/r'c�N�t|��}t||dzz��SrG)r
r�r4r$rtrKs    r%rVzplanck_gen._cdf�s(���!�H�H���w�h��!��n�%�%�%�%r'c�H�t|�||����Sr )rr�)r4r$rts   r%rZzplanck_gen._sf�s���4�;�;�q�'�*�*�+�+�+r'c�2�t|��}||dzzSrG�r
rws    r%r�zplanck_gen._logsf�s���!�H�H���x��1��~�r'c���td|zt|��zdz
��}|dz
j|�|���}|�||��}tj||k||��S)N��r)rr�cliprErVr!r�)r4rartrvrir�s      r%rbzplanck_gen._ppf�sp���D��L�5�!��9�9�,�Q�.�/�/����a��
�� 1� 1�'� :� :�<���y�y���(�(���x���	�5�$�/�/�/r'Nc�X�t|��}|�||���dz
S)Nr�r�)rr�)r4rtr:r;r.s     r%r<zplanck_gen._rvs�s0��
�G�8�_�_����%�%�a�d�%�3�3�c�9�9r'c���dt|��z}t|��t|��dzz}dt|dz��z}ddt|��zz}||||fS)Nrr�r�rQ)rrr)r4rtrlrmrnros      r%rpzplanck_gen._stats�si��
�u�W�~�~�
���7�(�m�m�U�G�8�_�_�q�0�0��
�t�G�C�K� � �
 ��
�q��g����
���3��B��r'c�p�t|��}|t|��z|zt|��z
Sr )rrr)r4rt�Cs   r%rwzplanck_gen._entropy�s5��
�G�8�_�_����s�G�8�}�}�$�Q�&��Q���/�/r're)rzr{r|r}r5rArRrVrZr�rbr<rprwr~r'r%rprp�s���������6J�J�J����0�0�0�&�&�&�,�,�,����0�0�0�:�:�:�:�
���0�0�0�0�0r'rp�planckzA discrete exponential c�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�
boltzmann_gena�A Boltzmann (Truncated Discrete Exponential) random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `boltzmann` is:

    .. math::

        f(k) = (1-\exp(-\lambda)) \exp(-\lambda k) / (1-\exp(-\lambda N))

    for :math:`k = 0,..., N-1`.

    `boltzmann` takes :math:`\lambda > 0` and :math:`N > 0` as shape parameters.

    %(after_notes)s

    %(example)s

    c�z�tdddtjfd��tdddtjfd��gS)NrtFrr�r�Tr1r3s r%r5zboltzmann_gen._shape_info�s<���9�e�a���[�.�I�I��3��q�"�&�k�>�B�B�D�	Dr'c�<�|dk|dkzt|��zSr�r?�r4rtr�s   r%rAzboltzmann_gen._argcheck�s ���!���A��&��Q���7�7r'c��|j|dz
fSrGrCr�s   r%rEzboltzmann_gen._get_support�s���v�q�1�u�}�r'c��dt|��z
dt||z��z
z}|t||z��zSrG�r)r4rKrtr��facts     r%rRzboltzmann_gen._pmf�sB���#�w�h�-�-��!�C����
�O�O�"3�4���C����
�O�O�#�#r'c��t|��}dt||dzz��z
dt||z��z
zSrG)r
r)r4r$rtr�rKs     r%rVzboltzmann_gen._cdf�s@���!�H�H���#�w�h��!��n�%�%�%��#�w�h�q�j�/�/�(9�:�:r'c�,�|dt||z��z
z}td|ztd|z
��zdz
��}|dz
�dtj��}|�|||��}t	j||k||��S)Nrr|rB)rrrr}r!r2rVr�)r4rartr��qnewrvrir�s        r%rbzboltzmann_gen._ppf�s����!�C����
�O�O�#�$���D��L�3�q��v�;�;�.�q�0�1�1���a��
�
�c�2�6�*�*���y�y����+�+���x���	�5�$�/�/�/r'c��t|��}t||z��}|d|z
z||zd|z
zz
}|d|z
dzz||z|zd|z
dzzz
}d|z
d|z
z}||dzz||z|zz
}|d|zz|dzz|dz|zd|zzz
}	|	|dzz}	|dd|zz||zzz|dzz|dz|zdd|zz||zzzz
}
|
|z|z}
|||	|
fS)Nr�rr�r�rPrQr�)r4rtr��z�zNrlrm�trm�trm2rnros           r%rpzboltzmann_gen._stats�s,�����M�M��
�'��!��_�_��
��A��Y�q��t�Q�r�T�{�
"����Q���
�l�Q�q�S��V�Q�r�T�A�I�-�-����t�a��c�l���#�q�&��1�Q�3�r�6�!��
��!��W�S�!�V�^�a��d�2�g�q��t�n�
,��
�$��+�
��
��!�A�#��a��c�	�]�3��6�
!�A�q�D�2�I�q��2��v�b��e�|�$<�
<��
�$�Y��
���3��B��r'N)rzr{r|r}r5rArErRrVrbrpr~r'r%r�r��s���������*D�D�D�8�8�8����$�$�$�;�;�;�0�0�0�����r'r��	boltzmannz!A truncated discrete exponential )r�rDr�c�J�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd
�Zd�Zd	S)
�randint_gena�A uniform discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `randint` is:

    .. math::

        f(k) = \frac{1}{\texttt{high} - \texttt{low}}

    for :math:`k \in \{\texttt{low}, \dots, \texttt{high} - 1\}`.

    `randint` takes :math:`\texttt{low}` and :math:`\texttt{high}` as shape
    parameters.

    %(after_notes)s

    %(example)s

    c��tddtjtjfd��tddtjtjfd��gS)N�lowTr��highr1r3s r%r5zrandint_gen._shape_info%sF���5�$�"�&��"�&�(9�>�J�J��6�4�2�6�'�2�6�):�N�K�K�M�	Mr'c�N�||kt|��zt|��zSr r?�r4r�r�s   r%rAzrandint_gen._argcheck)s&���s�
�k�#�.�.�.��T�1B�1B�B�Br'c��||dz
fSrGr~r�s   r%rEzrandint_gen._get_support,s���D��F�{�r'c�x�tj|��||z
z}tj||k||kz|d��S)NrB)r!�	ones_liker�)r4rKr�r�r.s     r%rRzrandint_gen._pmf/s9���L��O�O�t�c�z�*���x��c��a�$�h�/��B�7�7�7r'c�<�t|��}||z
dz||z
zSrNrz)r4r$r�r�rKs     r%rVzrandint_gen._cdf4s$���!�H�H���C��"�����,�,r'c���t|||z
z|z��dz
}|dz
�||��}|�|||��}tj||k||��SrG)rr}rVr!r�)r4rar�r�rvrir�s       r%rbzrandint_gen._ppf8sf���A����$�s�*�+�+�a�/��������T�*�*���y�y���T�*�*���x���	�5�$�/�/�/r'c��tj|��tj|��}}||zdz
dz}||z
}||zdz
dz}d}d||zdzz||zdz
z}	||||	fS)Nr�r�rg(@rBg333333�)r!r)
r4r�r��m2�m1rl�drmrnros
          r%rpzrandint_gen._stats>s|����D�!�!�2�:�c�?�?�B���2�g��m�q�
 ����G����s�Q�w�$���
��
��1��s��
#�q��s�S�y�
1���3��B��r'Nc�t�tj|��jdkr0tj|��jdkrt||||���S|�*tj||��}tj||��}tjt
t|��tjg���}|||��S)z=An array of *size* random integers >= ``low`` and < ``high``.rr�N)�otypes)r!rr:r�broadcast_to�	vectorizer�int_)r4r�r�r:r;�randints      r%r<zrandint_gen._rvsGs���
�:�c�?�?��1�$�$���D�)9�)9�)>�!�)C�)C���c�4�d�C�C�C�C���
�/�#�t�,�,�C��?�4��.�.�D��,�w�|�\�B�B�')�w�i�1�1�1���w�s�D�!�!�!r'c�&�t||z
��Sr )rr�s   r%rwzrandint_gen._entropyXs���4�#�:���r're)
rzr{r|r}r5rArErRrVrbrpr<rwr~r'r%r�r�
s���������.M�M�M�C�C�C����8�8�8�
-�-�-�0�0�0����"�"�"�"�"����r'r�r�z#A discrete uniform (random integer)c�2�eZdZdZd�Zdd�Zd�Zd�Zd�ZdS)	�zipf_gena�A Zipf (Zeta) discrete random variable.

    %(before_notes)s

    See Also
    --------
    zipfian

    Notes
    -----
    The probability mass function for `zipf` is:

    .. math::

        f(k, a) = \frac{1}{\zeta(a) k^a}

    for :math:`k \ge 1`, :math:`a > 1`.

    `zipf` takes :math:`a > 1` as shape parameter. :math:`\zeta` is the
    Riemann zeta function (`scipy.special.zeta`)

    The Zipf distribution is also known as the zeta distribution, which is
    a special case of the Zipfian distribution (`zipfian`).

    %(after_notes)s

    References
    ----------
    .. [1] "Zeta Distribution", Wikipedia,
           https://en.wikipedia.org/wiki/Zeta_distribution

    %(example)s

    Confirm that `zipf` is the large `n` limit of `zipfian`.

    >>> import numpy as np
    >>> from scipy.stats import zipfian
    >>> k = np.arange(11)
    >>> np.allclose(zipf.pmf(k, a), zipfian.pmf(k, a, n=10000000))
    True

    c�@�tdddtjfd��gS)NrDFrr�r1r3s r%r5zzipf_gen._shape_info�����3���2�6�{�N�C�C�D�Dr'Nc�0�|�||���Sr�)�zipf)r4rDr:r;s    r%r<z
zipf_gen._rvs�s��� � ��� �.�.�.r'c��|dkSrGr~�r4rDs  r%rAzzipf_gen._argcheck�s���1�u�r'c�B�dtj|d��z||zz}|S�Nr�r�rr	)r4rKrDr`s    r%rRz
zipf_gen._pmf�s&��
�7�<��1�%�%�
%��1��
,���	r'c�N�t||dzk||fd�tj��S)Nrc�^�tj||z
d��tj|d��zSrGr�)rDr,s  r%rAz zipf_gen._munp.<locals>.<lambda>�s'����a�!�e�Q�/�/�'�,�q�!�2D�2D�D�r')r
r!r2)r4r,rDs   r%�_munpzzipf_gen._munp�s0���
��A��I��1�v�D�D��F���	r're)	rzr{r|r}r5r<rArRr�r~r'r%r�r�asr������)�)�VE�E�E�/�/�/�/�������
����r'r�r�zA Zipfc�J�t|d��t||dz��z
S)z"Generalized harmonic number, a > 1r)r	�r,rDs  r%�_gen_harmonic_gt1r��s#����1�:�:��Q��!����$�$r'c��tj|��s|Stj|��}tj|t���}tj|ddt���D]$}||k}||xxd|||zzz
cc<�%|S)z#Generalized harmonic number, a <= 1��dtyper���r)r!r:�max�
zeros_like�floatr)r,rD�n_max�out�i�masks      r%�_gen_harmonic_leq1r��s���
�7�1�:�:�����F�1�I�I�E�
�-���
'�
'�
'�C�
�Y�u�a��5�
1�
1�
1�"�"���A�v���D�	�	�	�Q�q�!�D�'�z�\�!�	�	�	�	��Jr'c�x�tj||��\}}t|dk||ftt���S)zGeneralized harmonic numberr��f�f2)r!rr
r�r�r�s  r%�
_gen_harmonicr��sE��
��q�!�$�$�D�A�q��a�!�e�a��V�)�.@�B�B�B�Br'c�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�zipfian_gena{A Zipfian discrete random variable.

    %(before_notes)s

    See Also
    --------
    zipf

    Notes
    -----
    The probability mass function for `zipfian` is:

    .. math::

        f(k, a, n) = \frac{1}{H_{n,a} k^a}

    for :math:`k \in \{1, 2, \dots, n-1, n\}`, :math:`a \ge 0`,
    :math:`n \in \{1, 2, 3, \dots\}`.

    `zipfian` takes :math:`a` and :math:`n` as shape parameters.
    :math:`H_{n,a}` is the :math:`n`:sup:`th` generalized harmonic
    number of order :math:`a`.

    The Zipfian distribution reduces to the Zipf (zeta) distribution as
    :math:`n \rightarrow \infty`.

    %(after_notes)s

    References
    ----------
    .. [1] "Zipf's Law", Wikipedia, https://en.wikipedia.org/wiki/Zipf's_law
    .. [2] Larry Leemis, "Zipf Distribution", Univariate Distribution
           Relationships. http://www.math.wm.edu/~leemis/chart/UDR/PDFs/Zipf.pdf

    %(example)s

    Confirm that `zipfian` reduces to `zipf` for large `n`, `a > 1`.

    >>> import numpy as np
    >>> from scipy.stats import zipf
    >>> k = np.arange(11)
    >>> np.allclose(zipfian.pmf(k, a=3.5, n=10000000), zipf.pmf(k, a=3.5))
    True

    c�z�tdddtjfd��tdddtjfd��gS)NrDFrr-r,Tr�r1r3s r%r5zzipfian_gen._shape_info�s<���3���2�6�{�M�B�B��3��q�"�&�k�>�B�B�D�	Dr'c�\�|dk|dkz|tj|t���kzS)Nrr�)r!rr7�r4rDr,s   r%rAzzipfian_gen._argcheck�s.���Q��1�q�5�!�Q�"�*�Q�c�*B�*B�*B�%B�C�Cr'c�
�d|fSrGr~r�s   r%rEzzipfian_gen._get_support�r�r'c�4�dt||��z||zzSrN�r��r4rKrDr,s    r%rRzzipfian_gen._pmf�s ���]�1�a�(�(�(�1�a�4�/�/r'c�D�t||��t||��zSr r�r�s    r%rVzzipfian_gen._cdf�s!���Q��"�"�]�1�a�%8�%8�8�8r'c��|dz}||zt||��t||��z
zdz||zt||��zzSrGr�r�s    r%rZzzipfian_gen._sf�sU��
��E���A��}�Q��*�*�]�1�a�-@�-@�@�A�A�E��a�4�
�a��+�+�+�-�	.r'c��t||��}t||dz
��}t||dz
��}t||dz
��}t||dz
��}||z}||z|dzz
}	|dz}
|	|
z}||zd|z|z|dzzz
d|dzz|dzzz|dzz}|dz|zd|dzz|z|zz
d|z|dzz|zzd|dzzz
|	dzz}
|
dz}
||||
fS)Nrr�r�rQrPr�r�)r4rDr,�Hna�Hna1�Hna2�Hna3�Hna4�mu1�mu2n�mu2d�mu2rnros              r%rpzzipfian_gen._statss5���A�q�!�!���Q��!��$�$���Q��!��$�$���Q��!��$�$���Q��!��$�$���3�h���S��4��7�"���A�v���T�k���3�h��4����S�!�V�+�+�a��a��i��Q��.>�>��c�
�
J���1�f�T�k�A�c�1�f�H�T�M�$�.�.��3��t�Q�w��t�1C�C��$��'�	��!�1�W�%��
�a����C��R��r'N)rzr{r|r}r5rArErRrVrZrpr~r'r%r�r��s�������,�,�\D�D�D�D�D�D����0�0�0�9�9�9�.�.�.� � � � � r'r��zipfianz	A Zipfianc�>�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d
d	�Z
dS)�dlaplace_genaLA  Laplacian discrete random variable.

    %(before_notes)s

    Notes
    -----
    The probability mass function for `dlaplace` is:

    .. math::

        f(k) = \tanh(a/2) \exp(-a |k|)

    for integers :math:`k` and :math:`a > 0`.

    `dlaplace` takes :math:`a` as shape parameter.

    %(after_notes)s

    %(example)s

    c�@�tdddtjfd��gS)NrDFrr�r1r3s r%r5zdlaplace_gen._shape_info1r�r'c�h�t|dz��t|t|��z��zS�Nr�)rr�abs)r4rKrDs   r%rRzdlaplace_gen._pmf4s+���A�c�E�{�{�S�!��c�!�f�f��-�-�-�-r'c�^�t|��}d�}d�}t|dk||f||���S)Nc�T�dt||z��t|��dzzz
Sr�r��rKrDs  r%rAz#dlaplace_gen._cdf.<locals>.<lambda>:s&���s�A�2��6�{�{�c�!�f�f�q�j�9�9�r'c�R�t||dzz��t|��dzzSrGr�r�s  r%rAz#dlaplace_gen._cdf.<locals>.<lambda>;s#��#�a�1�Q�3�i�.�.�C��F�F�Q�J�7�r'rr�)r
r
)r4r$rDrKr�r�s      r%rVzdlaplace_gen._cdf8s<���!�H�H��9�9��
7�
7���!�q�&�1�a�&�A�"�5�5�5�5r'c
�\�dt|��z}ttj|ddt|��zzkt	||z��|zdz
t	d|z
|z��|z����}|dz
}tj|�||��|k||��S)Nrr�)rrr!r�rrV)r4rarD�constrvris      r%rbzdlaplace_gen._ppf>s����C��F�F�
���B�H�Q���C���G�G��!4�4� ��5��\�\�A�-��1�!�1�Q�3�%�-�0�0�0�1�4�6�6�7�7���q����x��	�	�%��+�+�q�0�%��>�>�>r'c��t|��}d|z|dz
dzz}d|z|dzd|zzdzz|dz
dzz}d|d||dzzdz
fS)Nr�r�r�g$@rQrBrr�)r4rD�ear�rVs     r%rpzdlaplace_gen._statsFsi��
��V�V����e�R��U�Q�J�����e�R��U�3�r�6�\�"�_�%��B���
�2���3��C��Q��J��O�+�+r'c�f�|t|��ztt|dz����z
Sr�)rrrr�s  r%rwzdlaplace_gen._entropyLs)���4��7�7�{�S��a��e���-�-�-�-r'Nc��tjtj|����}|�||���}|�||���}||z
Sr�)r!rrr�)r4rDr:r;�
probOfSuccessr$�ys       r%r<zdlaplace_gen._rvsOsY�� ��2�:�a�=�=�.�1�1�1�
��"�"�=�t�"�<�<���"�"�=�t�"�<�<���1�u�r're)rzr{r|r}r5rRrVrbrprwr<r~r'r%r�r�s���������,E�E�E�.�.�.�6�6�6�?�?�?�,�,�,�.�.�.������r'r��dlaplacezA discrete Laplacianc�2�eZdZdZd�Zdd�Zd�Zd�Zd�ZdS)	�skellam_gena�A  Skellam discrete random variable.

    %(before_notes)s

    Notes
    -----
    Probability distribution of the difference of two correlated or
    uncorrelated Poisson random variables.

    Let :math:`k_1` and :math:`k_2` be two Poisson-distributed r.v. with
    expected values :math:`\lambda_1` and :math:`\lambda_2`. Then,
    :math:`k_1 - k_2` follows a Skellam distribution with parameters
    :math:`\mu_1 = \lambda_1 - \rho \sqrt{\lambda_1 \lambda_2}` and
    :math:`\mu_2 = \lambda_2 - \rho \sqrt{\lambda_1 \lambda_2}`, where
    :math:`\rho` is the correlation coefficient between :math:`k_1` and
    :math:`k_2`. If the two Poisson-distributed r.v. are independent then
    :math:`\rho = 0`.

    Parameters :math:`\mu_1` and :math:`\mu_2` must be strictly positive.

    For details see: https://en.wikipedia.org/wiki/Skellam_distribution

    `skellam` takes :math:`\mu_1` and :math:`\mu_2` as shape parameters.

    %(after_notes)s

    %(example)s

    c�z�tdddtjfd��tdddtjfd��gS)Nr�Frr�r�r1r3s r%r5zskellam_gen._shape_info�s<���5�%�!�R�V��n�E�E��5�%�!�R�V��n�E�E�G�	Gr'Nc�`�|}|�||��|�||��z
Sr r])r4r�r�r:r;r,s      r%r<zskellam_gen._rvs�s7�����$�$�S�!�,�,��$�$�S�!�,�,�-�	.r'c�L�tj��5d}tjd|���tj|dktjd|zdd|z
zd|z��dztjd|zdd|zzd|z��dz��}ddd��n#1swxYwY|S)Nz!overflow encountered in _ncx2_pdfr�r�rr�r)r�r�r�r!r�rO�	_ncx2_pdf)r4r$r�r�r��pxs      r%rRzskellam_gen._pmf�s��
�
$�
&�
&�	E�	E�9�G��#�H�g�>�>�>�>���!�a�%� �*�1�S�5�!�Q�q�S�'�1�S�5�A�A�!�C� �*�1�S�5�!�Q�q�S�'�1�S�5�A�A�!�C�E�E�B�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E�	E����	E�	E�	E�	E��	s�A9B�B� Bc���t|��}tj|dktjd|zd|zd|z��dtjd|zd|dzzd|z��z
��}|S)Nrr����r)r
r!r�rO�	_ncx2_cdf)r4r$r�r�r�s     r%rVzskellam_gen._cdf�sr���!�H�H��
�X�a�!�e��&�q��u�b��d�A�c�E�:�:��&�*�1�S�5�!�Q�q�S�'�1�S�5�A�A�A�C�C���	r'c�V�||z
}||z}|t|dz��z}d|z}||||fS)Nr�rr�)r4r�r��meanrmrnros       r%rpzskellam_gen._stats�s@���S�y���C�i��
�D�#���N�N�
"��
��W���S�"�b� � r're)	rzr{r|r}r5r<rRrVrpr~r'r%r�r�isq��������:G�G�G�.�.�.�.�
������!�!�!�!�!r'r��skellamz	A Skellamc�J�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
�
yulesimon_gena�A Yule-Simon discrete random variable.

    %(before_notes)s

    Notes
    -----

    The probability mass function for the `yulesimon` is:

    .. math::

        f(k) =  \alpha B(k, \alpha+1)

    for :math:`k=1,2,3,...`, where :math:`\alpha>0`.
    Here :math:`B` refers to the `scipy.special.beta` function.

    The sampling of random variates is based on pg 553, Section 6.3 of [1]_.
    Our notation maps to the referenced logic via :math:`\alpha=a-1`.

    For details see the wikipedia entry [2]_.

    References
    ----------
    .. [1] Devroye, Luc. "Non-uniform Random Variate Generation",
         (1986) Springer, New York.

    .. [2] https://en.wikipedia.org/wiki/Yule-Simon_distribution

    %(after_notes)s

    %(example)s

    c�@�tdddtjfd��gS)N�alphaFrr�r1r3s r%r5zyulesimon_gen._shape_info�s���7�E�A�r�v�;��G�G�H�Hr'Nc	��|�|��}|�|��}t|tt||z����z��}|Sr )�standard_exponentialrrr)r4rr:r;�E1�E2�anss       r%r<zyulesimon_gen._rvs�sZ��
�
.�
.�t�
4�
4��
�
.�
.�t�
4�
4���B�3���R�C�%�K� 0� 0�0�1�1�1�2�2���
r'c�8�|tj||dz��zSrG�rr��r4r$rs   r%rRzyulesimon_gen._pmf�s���w�|�A�u�q�y�1�1�1�1r'c��|dkSr�r~)r4rs  r%rAzyulesimon_gen._argcheck�s����	�r'c�R�t|��tj||dz��zSrG�rrrrs   r%rMzyulesimon_gen._logpmf�s#���5�z�z�G�N�1�e�a�i�8�8�8�8r'c�>�d|tj||dz��zz
SrGrrs   r%rVzyulesimon_gen._cdf�s"���1�w�|�A�u�q�y�1�1�1�1�1r'c�8�|tj||dz��zSrGrrs   r%rZzyulesimon_gen._sf�s���7�<��5�1�9�-�-�-�-r'c�R�t|��tj||dz��zSrGrrs   r%r�zyulesimon_gen._logsf�s#���1�v�v���q�%�!�)�4�4�4�4r'c��tj|dktj||dz
z��}tj|dk|dz|dz
|dz
dzzztj��}tj|dktj|��}tj|dkt	|dz
��|dzdzz||dz
zztj��}tj|dktj|��}tj|dk|dz|dzd|zz
dz
||dz
z|dz
zzztj��}tj|dktj|��}||||fS)Nrr�r�r�rQ�1�)r!r�r2�nanr)r4rrlr�rnros      r%rpzyulesimon_gen._stats�s[��
�X�e�q�j�"�&�%�5�1�9�*=�
>�
>���h�u�q�y��q��U�S�[�U�Q�Y��N�:�;�������h�u��z�2�6�3�/�/��
�X�e�a�i��U�Q�Y���5�1�9�q�.�0�E�U�Q�Y�4G�H�������X�e�q�j�"�&�"�
-�
-��
�X�e�a�i����u�a�x�"�u�*�4�r�9�e����?$�',�q�y�?2�3�3�46�F�<�<���X�e�q�j�"�&�"�
-�
-���3��B��r're)
rzr{r|r}r5r<rRrArMrVrZr�rpr~r'r%rr�s������� � �BI�I�I�����2�2�2����9�9�9�2�2�2�.�.�.�5�5�5�����r'r�	yulesimon)r�rDc����fd�}|S)z?Decorator that vectorizes _rvs method to work on ndarray shapesc�X���t|dj|��\}}tj|��}tj|��}tj|��}tj|��r�	g|�|�|�R�Stj|��}tj|j��}tj||||f��}tj	|||��}tj
||�D]��	g�fd�|D���|�|�R�|�<�tj	|||��S)Nrc�D��g|]}tj|�����Sr~)r!�squeeze)�.0�argr�s  �r%�
<listcomp>z<_vectorize_rvs_over_shapes.<locals>._rvs.<locals>.<listcomp>s&���@�@�@�C�R�Z��_�_�Q�/�@�@�@r')r�shaper!�array�all�emptyr�ndim�hstack�moveaxis�ndindex)
r:r;�args�
_rvs1_size�
_rvs1_indicesr��j0�j1r�r<s
        @�r%r<z(_vectorize_rvs_over_shapes.<locals>._rvssK����$0��a����$E�$E�!�
�M��x��~�~���X�j�)�)�
����/�/�
�
�6�-� � �	4��5�3�$�3��3�l�3�3�3�3��h�t�n�n��
�Y�s�x�
 �
 ��
�Y��M�>�*�B�}�,=�>�
?�
?���k�#�r�2�&�&����T�=�.�1�2�	5�	5�A��U�5�@�@�@�@�4�@�@�@�5�%�5�'3�5�5�5�C��F�F��{�3��B�'�'�'r'r~)r<r<s` r%r>r>�s#���(�(�(�(�(�4�Kr'c�@�eZdZdZdZdZd�Zd�Zd�Zd	d�Z	d�Z
d�ZdS)
�_nchypergeom_genz�A noncentral hypergeometric discrete random variable.

    For subclassing by nchypergeom_fisher_gen and nchypergeom_wallenius_gen.

    Nc	���tdddtjfd��tdddtjfd��tdddtjfd��tdddtjfd	��gS)
Nr�Trr-r,r��oddsFr�r1r3s r%r5z_nchypergeom_gen._shape_info-sj���3��q�"�&�k�=�A�A��3��q�"�&�k�=�A�A��3��q�"�&�k�=�A�A��6�5�1�b�f�+�~�F�F�H�	Hr'c�z�|||}}}||z
}tjd||z
��}tj||��}||fSr�r�)	r4r�r,r�r2r�r��x_min�x_maxs	         r%rEz_nchypergeom_gen._get_support3sH���a��q�2��
��V���
�1�a�"�f�%�%���
�1�b�!�!���e�|�r'c���tj|��tj|��}}tj|��tj|��}}|�t��|k|dkz}|�t��|k|dkz}|�t��|k|dkz}|dk}||k}	||k}
||z|z|z|	z|
zSr�)r!rr6r7)r4r�r,r�r2�cond1�cond2�cond3�cond4�cond5�cond6s           r%rAz_nchypergeom_gen._argcheck:s����z�!�}�}�b�j��m�m�1���*�Q�-�-���D�!1�!1�4�����#���!�#��Q��/�����#���!�#��Q��/�����#���!�#��Q��/���q����Q����Q����u�}�u�$�u�,�u�4�u�<�<r'c�J��t�fd���}|||||||���S)Nc���tj|��}t��}t|�
j��}|||||||��}	|	�|��}	|	Sr )r!�prodr�getattr�rvs_name�reshape)r�r,r�r2r:r;�length�urn�rv_genr;r4s          �r%r<z$_nchypergeom_gen._rvs.<locals>._rvs1Gs[����W�T�]�]�F�#�%�%�C��S�$�-�0�0�F��&��A�q�$���=�=�C��+�+�d�#�#�C��Jr'r�r=)r4r�r,r�r2r:r;r<s`       r%r<z_nchypergeom_gen._rvsEsF���	#�	�	�	�	�
$�	#�	��u�Q��1�d��L�I�I�I�Ir'c����tj|||||��\}}}}}|jdkrtj|��Stj�fd���}||||||��S)Nrc�`����||||d��}|�|��S�Ng�-���q=)�dist�probability)r$r�r,r�r2rDr4s      �r%�_pmf1z$_nchypergeom_gen._pmf.<locals>._pmf1Xs.����)�)�A�q�!�T�5�1�1�C��?�?�1�%�%�%r')r!rr:�
empty_liker�)r4r$r�r,r�r2rKs`      r%rRz_nchypergeom_gen._pmfRs�����.�q�!�Q��4�@�@���1�a��D��6�Q�;�;��=��#�#�#�	��	&�	&�	&�	&�
��	&��u�Q��1�a��&�&�&r'c�~��tj�fd���}d|vsd|vr|||||��nd\}}d\}	}
|||	|
fS)Nc�^����||||d��}|���SrH)rIrk)r�r,r�r2rDr4s     �r%�	_moments1z*_nchypergeom_gen._stats.<locals>._moments1as*����)�)�A�q�!�T�5�1�1�C��;�;�=�=� r'r�vre)r!r�)r4r�r,r�r2rkrOrrPrfrKs`          r%rpz_nchypergeom_gen._stats_ss���	��	!�	!�	!�	!�
��	!�.1�G�^�^�s�g�~�~�	�	�!�Q��4�(�(�(�!�	
��1����1��!�Q��z�r're)rzr{r|r}rArIr5rErAr<rRrpr~r'r%r0r0#s����������H��D�H�H�H����	=�	=�	=�J�J�J�J�'�'�'�
�
�
�
�
r'r0c��eZdZdZdZeZdS)�nchypergeom_fisher_genag	A Fisher's noncentral hypergeometric discrete random variable.

    Fisher's noncentral hypergeometric distribution models drawing objects of
    two types from a bin. `M` is the total number of objects, `n` is the
    number of Type I objects, and `odds` is the odds ratio: the odds of
    selecting a Type I object rather than a Type II object when there is only
    one object of each type.
    The random variate represents the number of Type I objects drawn if we
    take a handful of objects from the bin at once and find out afterwards
    that we took `N` objects.

    %(before_notes)s

    See Also
    --------
    nchypergeom_wallenius, hypergeom, nhypergeom

    Notes
    -----
    Let mathematical symbols :math:`N`, :math:`n`, and :math:`M` correspond
    with parameters `N`, `n`, and `M` (respectively) as defined above.

    The probability mass function is defined as

    .. math::

        p(x; M, n, N, \omega) =
        \frac{\binom{n}{x}\binom{M - n}{N-x}\omega^x}{P_0},

    for
    :math:`x \in [x_l, x_u]`,
    :math:`M \in {\mathbb N}`,
    :math:`n \in [0, M]`,
    :math:`N \in [0, M]`,
    :math:`\omega > 0`,
    where
    :math:`x_l = \max(0, N - (M - n))`,
    :math:`x_u = \min(N, n)`,

    .. math::

        P_0 = \sum_{y=x_l}^{x_u} \binom{n}{y}\binom{M - n}{N-y}\omega^y,

    and the binomial coefficients are defined as

    .. math:: \binom{n}{k} \equiv \frac{n!}{k! (n - k)!}.

    `nchypergeom_fisher` uses the BiasedUrn package by Agner Fog with
    permission for it to be distributed under SciPy's license.

    The symbols used to denote the shape parameters (`N`, `n`, and `M`) are not
    universally accepted; they are chosen for consistency with `hypergeom`.

    Note that Fisher's noncentral hypergeometric distribution is distinct
    from Wallenius' noncentral hypergeometric distribution, which models
    drawing a pre-determined `N` objects from a bin one by one.
    When the odds ratio is unity, however, both distributions reduce to the
    ordinary hypergeometric distribution.

    %(after_notes)s

    References
    ----------
    .. [1] Agner Fog, "Biased Urn Theory".
           https://cran.r-project.org/web/packages/BiasedUrn/vignettes/UrnTheory.pdf

    .. [2] "Fisher's noncentral hypergeometric distribution", Wikipedia,
           https://en.wikipedia.org/wiki/Fisher's_noncentral_hypergeometric_distribution

    %(example)s

    �
rvs_fisherN)rzr{r|r}rArrIr~r'r%rRrRls'������G�G�R�H�%�D�D�Dr'rR�nchypergeom_fisherz$A Fisher's noncentral hypergeometricc��eZdZdZdZeZdS)�nchypergeom_wallenius_gena}	A Wallenius' noncentral hypergeometric discrete random variable.

    Wallenius' noncentral hypergeometric distribution models drawing objects of
    two types from a bin. `M` is the total number of objects, `n` is the
    number of Type I objects, and `odds` is the odds ratio: the odds of
    selecting a Type I object rather than a Type II object when there is only
    one object of each type.
    The random variate represents the number of Type I objects drawn if we
    draw a pre-determined `N` objects from a bin one by one.

    %(before_notes)s

    See Also
    --------
    nchypergeom_fisher, hypergeom, nhypergeom

    Notes
    -----
    Let mathematical symbols :math:`N`, :math:`n`, and :math:`M` correspond
    with parameters `N`, `n`, and `M` (respectively) as defined above.

    The probability mass function is defined as

    .. math::

        p(x; N, n, M) = \binom{n}{x} \binom{M - n}{N-x}
        \int_0^1 \left(1-t^{\omega/D}\right)^x\left(1-t^{1/D}\right)^{N-x} dt

    for
    :math:`x \in [x_l, x_u]`,
    :math:`M \in {\mathbb N}`,
    :math:`n \in [0, M]`,
    :math:`N \in [0, M]`,
    :math:`\omega > 0`,
    where
    :math:`x_l = \max(0, N - (M - n))`,
    :math:`x_u = \min(N, n)`,

    .. math::

        D = \omega(n - x) + ((M - n)-(N-x)),

    and the binomial coefficients are defined as

    .. math:: \binom{n}{k} \equiv \frac{n!}{k! (n - k)!}.

    `nchypergeom_wallenius` uses the BiasedUrn package by Agner Fog with
    permission for it to be distributed under SciPy's license.

    The symbols used to denote the shape parameters (`N`, `n`, and `M`) are not
    universally accepted; they are chosen for consistency with `hypergeom`.

    Note that Wallenius' noncentral hypergeometric distribution is distinct
    from Fisher's noncentral hypergeometric distribution, which models
    take a handful of objects from the bin at once, finding out afterwards
    that `N` objects were taken.
    When the odds ratio is unity, however, both distributions reduce to the
    ordinary hypergeometric distribution.

    %(after_notes)s

    References
    ----------
    .. [1] Agner Fog, "Biased Urn Theory".
           https://cran.r-project.org/web/packages/BiasedUrn/vignettes/UrnTheory.pdf

    .. [2] "Wallenius' noncentral hypergeometric distribution", Wikipedia,
           https://en.wikipedia.org/wiki/Wallenius'_noncentral_hypergeometric_distribution

    %(example)s

    �
rvs_walleniusN)rzr{r|r}rArrIr~r'r%rVrV�s'������G�G�R�H�'�D�D�Dr'rV�nchypergeom_walleniusz&A Wallenius' noncentral hypergeometric)^�	functoolsrr��scipyr�
scipy.specialrrrrrHr	�scipy._lib._utilr
r�scipy.interpolater�numpyr
rrrrrrrrrr!�_distn_infrastructurerrrr�scipy.stats._boost�statsrO�
_biasedurnrrrr&r)rr�r�r�r�r�r�r�r�r�r'r)rFrHrWrYr^rpr�r�r�r�r�r�r�r�r�r�r�r�r�r2r�r�rrrr>r0rRrTrVrX�list�globals�copy�items�pairs�_distn_names�_distn_gen_names�__all__r~r'r%�<module>rks���
����������������I�I�I�I�I�I�I�I�I�I�I�I�I�I�5�5�5�5�5�5�5�5�&�&�&�&�&�&�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�����>�>�>�>�>�>�>�>�>�>�>�>�#�#�#�#�#�#�#�#�#�+�+�+�+�+�+�+�+�+�+�
���M*�M*�M*�M*�M*��M*�M*�M*�`	�	�w�����>#�>#�>#�>#�>#�I�>#�>#�>#�B
�M�A�K�0�0�0�	�O�O�O�O�O�K�O�O�O�d
�M�{�+�+�+�	�o
�o
�o
�o
�o
��o
�o
�o
�d
���	"�	"�	"��B�B�B�B�B�{�B�B�B�J�x�!�&�=�9�9�9��Q�Q�Q�Q�Q�K�Q�Q�Q�h
�M�{�+�+�+�	�\�\�\�\�\�[�\�\�\�~�^��
.�
.�
.�
�5�5�5�5�5��5�5�5�p
��a�h��	A�	A�	A��?�?�?�?�?�+�?�?�?�D�+�9�{�
;�
;�
;��D0�D0�D0�D0�D0��D0�D0�D0�N
��a�h�1J�	K�	K�	K��<�<�<�<�<�K�<�<�<�~
�M�{�a�#F�
H�
H�
H�	�L�L�L�L�L�+�L�L�L�^�+�9�0)�*�*�*��
>�>�>�>�>�{�>�>�>�B�x�!�&�8�4�4�4��%�%�%�
�
�
�B�B�B�U �U �U �U �U �+�U �U �U �p�+��	�K�
@�
@�
@��H�H�H�H�H�;�H�H�H�V�<�2�6�'�'�2H�J�J�J��=!�=!�=!�=!�=!�+�=!�=!�=!�@�+����i�+�
F�
F�
F��K�K�K�K�K�K�K�K�K�\
�M�{�a�0�0�0�	�#�#�#�LF�F�F�F�F�{�F�F�F�RK&�K&�K&�K&�K&�-�K&�K&�K&�\,�+�	�
3�5�5�5��
K(�K(�K(�K(�K(� 0�K(�K(�K(�\2�1�	 �
5�7�7�7��	
��W�W�Y�Y�^�^�
�
�
#�
#�
%�
%�&�&��!7�!7��{�!K�!K����
�)�
)���r'

Youez - 2016 - github.com/yon3zu
LinuXploit