ó
î&]\c           @` sŽ  d  d l  m Z m Z m Z d  d l m Z d  d l m Z m Z m	 Z	 m
 Z d  d l m Z d  d l m Z d  d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z d  d l Z d d	 l m Z m Z m Z m  Z  d
 e f d „  ƒ  YZ! e! d d ƒ Z" d e! f d „  ƒ  YZ# e# d d d d ƒ Z$ d e f d „  ƒ  YZ% e% d d ƒ Z& d e f d „  ƒ  YZ' e' d d d d d d ƒ Z( d e f d „  ƒ  YZ) e) d d ƒ Z* d e f d „  ƒ  YZ+ e+ d d d d  d d! ƒ Z, d" e f d# „  ƒ  YZ- e- d d$ d d% ƒ Z. d& e f d' „  ƒ  YZ/ e/ d d  d d( d d) ƒ Z0 d* e f d+ „  ƒ  YZ1 e1 d d, d d- ƒ Z2 d. e f d/ „  ƒ  YZ3 e3 d d0 d d1 ƒ Z4 d2 e f d3 „  ƒ  YZ5 e5 d d d d4 d d5 ƒ Z6 d6 e f d7 „  ƒ  YZ7 e7 d e j8 d d8 d d9 ƒ Z9 d: e f d; „  ƒ  YZ: e: d e j8 d d< d d= ƒ Z; d> e f d? „  ƒ  YZ< e< d d@ d d ƒ Z= e> e? ƒ  j@ ƒ  ƒ ZA e  eA e ƒ \ ZB ZC eB eC ZD d S(A   i    (   t   divisiont   print_functiont   absolute_import(   t   special(   t   entrt	   logsumexpt   betalnt   gammaln(   t   broadcast_to(   t
   _lazywhere(
   t   floort   ceilt   logt   expt   sqrtt   log1pt   expm1t   tanht   cosht   sinhNi   (   t   rv_discretet	   _ncx2_pdft	   _ncx2_cdft   get_distribution_namest	   binom_genc           B` sb   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d d	 „ Z
 d
 „  Z RS(   sE  A 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 ``k`` in ``{0, 1,..., n}``.

    `binom` takes ``n`` and ``p`` as shape parameters.

    %(after_notes)s

    %(example)s

    c         C` s   |  j  j | | |  j ƒ S(   N(   t   _random_statet   binomialt   _size(   t   selft   nt   p(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _rvs*   s    c         C` s'   | |  _  | d k | d k @| d k @S(   Ni    i   (   t   b(   R   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt	   _argcheck-   s    	c         C` se   t  | ƒ } t | d ƒ t | d ƒ t | | d ƒ } | t j | | ƒ t j | | | ƒ S(   Ni   (   R
   t   gamlnR   t   xlogyt   xlog1py(   R   t   xR   R   t   kt   combiln(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _logpmf1   s    0c         C` s   t  |  j | | | ƒ ƒ S(   N(   R   R(   (   R   R%   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _pmf6   s    c         C` s%   t  | ƒ } t j | | | ƒ } | S(   N(   R
   R   t   bdtr(   R   R%   R   R   R&   t   vals(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _cdf:   s    c         C` s   t  | ƒ } t j | | | ƒ S(   N(   R
   R   t   bdtrc(   R   R%   R   R   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _sf?   s    c         C` s_   t  t j | | | ƒ ƒ } t j | d d ƒ } t j | | | ƒ } t j | | k | | ƒ S(   Ni   i    (   R   R   t   bdtrikt   npt   maximumR*   t   where(   R   t   qR   R   R+   t   vals1t   temp(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _ppfC   s    t   mvc   	      C` s†   d | } | | } | | | } d \ } } d | k rQ | | t | ƒ } n  d | k rv d d | | | } n  | | | | f S(   Ng      ð?t   sR&   i   (   NN(   t   NoneR   (	   R   R   R   t   momentsR3   t   mut   vart   g1t   g2(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _statsI   s    

c         C` sB   t  j d | d !} |  j | | | ƒ } t  j t | ƒ d d ƒS(   Ni    i   t   axis(   R0   t   r_R)   t   sumR   (   R   R   R   R&   R+   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _entropyT   s    (   t   __name__t
   __module__t   __doc__R   R!   R(   R)   R,   R.   R6   R?   RC   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR      s   							t   namet   binomt   bernoulli_genc           B` s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s  A 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\}`.

    `bernoulli` takes :math:`p` as shape parameter.

    %(after_notes)s

    %(example)s

    c         C` s   t  j |  d | ƒ S(   Ni   (   R   R   (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   t   s    c         C` s   | d k | d k @S(   Ni    i   (    (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   w   s    c         C` s   t  j | d | ƒ S(   Ni   (   RH   R(   (   R   R%   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR(   z   s    c         C` s   t  j | d | ƒ S(   Ni   (   RH   R)   (   R   R%   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   }   s    c         C` s   t  j | d | ƒ S(   Ni   (   RH   R,   (   R   R%   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   ‚   s    c         C` s   t  j | d | ƒ S(   Ni   (   RH   R.   (   R   R%   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR.   …   s    c         C` s   t  j | d | ƒ S(   Ni   (   RH   R6   (   R   R3   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6   ˆ   s    c         C` s   t  j d | ƒ S(   Ni   (   RH   R?   (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   ‹   s    c         C` s   t  | ƒ t  d | ƒ S(   Ni   (   R   (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRC   Ž   s    (   RD   RE   RF   R   R!   R(   R)   R,   R.   R6   R?   RC   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRI   ]   s   								R    t	   bernoullit
   nbinom_genc           B` sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s_  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`.

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

    %(after_notes)s

    %(example)s

    c         C` s   |  j  j | | |  j ƒ S(   N(   R   t   negative_binomialR   (   R   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   ¯   s    c         C` s   | d k | d k @| d k @S(   Ni    i   (    (   R   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   ²   s    c         C` s   t  |  j | | | ƒ ƒ S(   N(   R   R(   (   R   R%   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   µ   s    c         C` sK   t  | | ƒ t  | d ƒ t  | ƒ } | | t | ƒ t j | | ƒ S(   Ni   (   R"   R   R   R$   (   R   R%   R   R   t   coeff(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR(   ¹   s    (c         C` s#   t  | ƒ } t j | | d | ƒ S(   Ni   (   R
   R   t   betainc(   R   R%   R   R   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   ½   s    c         C` s   t  | ƒ } t j | | | ƒ S(   N(   R
   R   t   nbdtrc(   R   R%   R   R   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _sf_skipÁ   s    c         C` sb   t  t j | | | ƒ ƒ } | d j d t j ƒ } |  j | | | ƒ } t j | | k | | ƒ S(   Ni   g        (   R   R   t   nbdtrikt   clipR0   t   infR,   R2   (   R   R3   R   R   R+   R4   R5   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6   Æ   s    c   	      C` sv   d | } | d } | | } | | | } | | t  | | | ƒ } d d | | | | | } | | | | f S(   Ng      ð?i   (   R   (	   R   R   R   t   Qt   PR;   R<   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   Ì   s    


(   RD   RE   RF   R   R!   R)   R(   R,   RP   R6   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRK   •   s   							t   nbinomt   geom_genc           B` s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   s$  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`.

    `geom` takes :math:`p` as shape parameter.

    %(after_notes)s

    %(example)s

    c         C` s   |  j  j | d |  j ƒS(   Nt   size(   R   t	   geometricR   (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   ï   s    c         C` s   | d k | d k @S(   Ni   i    (    (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   ò   s    c         C` s   t  j d | | d ƒ | S(   Ni   (   R0   t   power(   R   R&   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   õ   s    c         C` s   t  j | d | ƒ t | ƒ S(   Ni   (   R   R$   R   (   R   R&   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR(   ù   s    c         C` s"   t  | ƒ } t t | ƒ | ƒ S(   N(   R
   R   R   (   R   R%   R   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   ü   s    c         C` s   t  j |  j | | ƒ ƒ S(   N(   R0   R   t   _logsf(   R   R%   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR.      s    c         C` s   t  | ƒ } | t | ƒ S(   N(   R
   R   (   R   R%   R   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR[     s    c         C` s[   t  t | ƒ t | ƒ ƒ } |  j | d | ƒ } t j | | k | d k @| d | ƒ S(   Ni   i    (   R   R   R,   R0   R2   (   R   R3   R   R+   R5   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6     s    c         C` si   d | } d | } | | | } d | t  | ƒ } t j d d d g | ƒ d | } | | | | f S(   Ng      ð?g       @i   iúÿÿÿi   (   R   R0   t   polyval(   R   R   R;   t   qrR<   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?     s    

#(   RD   RE   RF   R   R!   R)   R(   R,   R.   R[   R6   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRW   Ù   s   								t   at   geomt   longnames   A geometrict   hypergeom_genc           B` sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s³  A 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
    --------
    >>> 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)

    c         C` s#   |  j  j | | | | d |  j ƒS(   NRX   (   R   t   hypergeometricR   (   R   t   MR   t   N(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   V  s    c         C` sp   | d k | d k @| d k @} | | | k | | k @M} t  j | | | d ƒ |  _ t  j | | ƒ |  _ | S(   Ni    (   R0   R1   R^   t   minimumR    (   R   Rc   R   Rd   t   cond(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   Y  s
     c   	      C` s£   | | } } | | } t  | d d ƒ t  | d d ƒ t  | | d | d ƒ t  | d | | d ƒ t  | | d | | | d ƒ t  | d d ƒ } | S(   Ni   (   R   (	   R   R&   Rc   R   Rd   t   tott   goodt   badt   result(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR(   `  s
    
tc         C` s   t  |  j | | | | ƒ ƒ S(   N(   R   R(   (   R   R&   Rc   R   Rd   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   h  s    c   
      C` sL  d | d | d | } } } | | } | | } | | } | | | | | d | | | d } | | | d | | d t  | d | | | | | ƒ } | | d d | | | d | | }	 |	 | d | | 9}	 |	 d | | | | | d | d 7}	 |	 | | | | | | d | d }	 | | | |	 f S(	   Ng      ð?i   i   g       @g      @g      @i   g      @(   R   (
   R   Rc   R   Rd   t   mR   R;   R<   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   m  s     


*@***c         C` sV   t  j | | | t | | ƒ d !} |  j | | | | ƒ } t  j t | ƒ d d ƒS(   Ni   R@   i    (   R0   RA   t   mint   pmfRB   R   (   R   Rc   R   Rd   R&   R+   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRC   ~  s    %c         C` s   g  } xk t  | | | | ƒ D]T \ } } } }	 t j | d |	 d ƒ }
 | j t j |  j |
 | | |	 ƒ ƒ ƒ q Wt j | ƒ S(   s1   More precise calculation, 1 - cdf doesn't cut it.i   (   t   zipR0   t   aranget   appendRB   R)   t   asarray(   R   R&   Rc   R   Rd   t   rest   quantRg   Rh   t   drawt   k2(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR.   ƒ  s
    (,c         C` s~   g  } xh t  | | | | ƒ D]Q \ } } } }	 t j | d |	 d ƒ }
 | j t |  j |
 | | |	 ƒ ƒ ƒ q Wt j | ƒ S(   s7   
        More precise calculation than log(sf)
        i   (   Rn   R0   Ro   Rp   R   R(   Rq   (   R   R&   Rc   R   Rd   Rr   Rs   Rg   Rh   Rt   Ru   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR[   ‘  s
    ()(   RD   RE   RF   R   R!   R(   R)   R?   RC   R.   R[   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRa     s   =							t	   hypergeomt
   logser_genc           B` s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sK  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`.

    `logser` takes :math:`p` as shape parameter.

    %(after_notes)s

    %(example)s

    c         C` s   |  j  j | d |  j ƒS(   NRX   (   R   t	   logseriesR   (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   ·  s    c         C` s   | d k | d k  @S(   Ni    i   (    (   R   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   ¼  s    c         C` s'   t  j | | ƒ d | t j | ƒ S(   Ng      ð?(   R0   RZ   R   R   (   R   R&   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   ¿  s    c         C` s1  t  j | ƒ } | | d | } | | | d d } | | | } | | d | d | d } | d | | d | d } | t j | d ƒ } | | d | d d d | | d d d | | | d d }	 |	 d | | d | | | d | d }
 |
 | d d } | | | | f S(	   Ng      ð?i   i   g      ø?i   i   i   g      @(   R   R   R0   RZ   (   R   R   t   rR;   t   mu2pR<   t   mu3pt   mu3R=   t   mu4pt   mu4R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   Ã  s    ?.(   RD   RE   RF   R   R!   R)   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRw   ¡  s
   			t   logsers   A logarithmict   poisson_genc           B` sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s8  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` as shape parameter.

    %(after_notes)s

    %(example)s

    c         C` s
   | d k S(   Ni    (    (   R   R;   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   î  s    c         C` s   |  j  j | |  j ƒ S(   N(   R   t   poissonR   (   R   R;   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   ñ  s    c         C` s(   t  j | | ƒ t | d ƒ | } | S(   Ni   (   R   R#   R"   (   R   R&   R;   t   Pk(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR(   ô  s    $c         C` s   t  |  j | | ƒ ƒ S(   N(   R   R(   (   R   R&   R;   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   ø  s    c         C` s   t  | ƒ } t j | | ƒ S(   N(   R
   R   t   pdtr(   R   R%   R;   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   ü  s    c         C` s   t  | ƒ } t j | | ƒ S(   N(   R
   R   t   pdtrc(   R   R%   R;   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR.      s    c         C` sY   t  t j | | ƒ ƒ } t j | d d ƒ } t j | | ƒ } t j | | k | | ƒ S(   Ni   i    (   R   R   t   pdtrikR0   R1   Rƒ   R2   (   R   R3   R;   R+   R4   R5   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6     s    c         C` sm   | } t  j | ƒ } | d k } t | | f d „  t  j ƒ } t | | f d „  t  j ƒ } | | | | f S(   Ni    c         S` s   t  d |  ƒ S(   Ng      ð?(   R   (   R%   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   <lambda>  s    c         S` s   d |  S(   Ng      ð?(    (   R%   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR†     s    (   R0   Rq   R	   RS   (   R   R;   R<   t   tmpt
   mu_nonzeroR=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   
  s    (   RD   RE   RF   R!   R   R(   R)   R,   R.   R6   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR€   Ö  s   							R   s	   A Poissont
   planck_genc           B` sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   se  A 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.

    %(after_notes)s

    %(example)s

    c         C` s
   | d k S(   Ni    (    (   R   t   lambda_(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   ,  s    c         C` s   d t  | ƒ t  | | ƒ S(   Ni   (   R   (   R   R&   RŠ   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   /  s    c         C` s#   t  | ƒ } d t | | d ƒ S(   Ni   (   R
   R   (   R   R%   RŠ   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   2  s    c         C` s   t  j |  j | | ƒ ƒ S(   N(   R0   R   R[   (   R   R%   RŠ   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR.   6  s    c         C` s   t  | ƒ } | | d S(   Ni   (   R
   (   R   R%   RŠ   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR[   9  s    c         C` sf   t  d | t | ƒ d ƒ } | d j |  j t j ƒ } |  j | | ƒ } t j | | k | | ƒ S(   Ng      ð¿i   (   R   R   RR   R^   R0   RS   R,   R2   (   R   R3   RŠ   R+   R4   R5   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6   =  s    c         C` sh   d t  | ƒ d } t  | ƒ t | ƒ d } d t | d ƒ } d d t | ƒ } | | | | f S(   Ni   i   g       @i   (   R   R   R   (   R   RŠ   R;   R<   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   C  s
    c         C` s4   | } d t  | ƒ } | t  | ƒ | t | ƒ S(   Ni   (   R   R   (   R   RŠ   t   lt   C(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRC   J  s    (   RD   RE   RF   R!   R)   R,   R.   R[   R6   R?   RC   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR‰     s   							t   plancks   A discrete exponential t   boltzmann_genc           B` s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s—  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         C` s*   d |  _  | d |  _ | d k | d k @S(   Ni    i   (   R^   R    (   R   RŠ   Rd   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   i  s    	c         C` s7   d t  | ƒ d t  | | ƒ } | t  | | ƒ S(   Ni   (   R   (   R   R&   RŠ   Rd   t   fact(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   n  s    $c         C` s6   t  | ƒ } d t | | d ƒ d t | | ƒ S(   Ni   (   R
   R   (   R   R%   RŠ   Rd   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   t  s    c         C` s‚   | d t  | | ƒ } t d | t d | ƒ d ƒ } | d j d t j ƒ } |  j | | | ƒ } t j | | k | | ƒ S(   Ni   g      ð¿g        (   R   R   R   RR   R0   RS   R,   R2   (   R   R3   RŠ   Rd   t   qnewR+   R4   R5   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6   x  s
    "c         C` s*  t  | ƒ } t  | | ƒ } | d | | | d | } | d | d | | | d | d } d | d | } | | d | | | } | d | | d | d | d | }	 |	 | d }	 | d d | | | | d | d | d d | | | }
 |
 | | }
 | | |	 |
 f S(   Ng      ð?i   i   i   g      ø?i   (   R   (   R   RŠ   Rd   t   zt   zNR;   R<   t   trmt   trm2R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?     s    **B(   RD   RE   RF   R!   R)   R,   R6   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRŽ   S  s   				t	   boltzmanns!   A truncated discrete exponential t   randint_genc           B` sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   sF  A uniform discrete random variable.

    %(before_notes)s

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

    .. math::

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

    for ``k = low, ..., high - 1``.

    `randint` takes ``low`` and ``high`` as shape parameters.

    %(after_notes)s

    %(example)s

    c         C` s    | |  _  | d |  _ | | k S(   Ni   (   R^   R    (   R   t   lowt   high(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   §  s    	c         C` s:   t  j | ƒ | | } t  j | | k | | k  @| d ƒ S(   Ng        (   R0   t	   ones_likeR2   (   R   R&   R—   R˜   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   ¬  s    c         C` s    t  | ƒ } | | d | | S(   Ng      ð?(   R
   (   R   R%   R—   R˜   R&   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   ±  s    c         C` s`   t  | | | | ƒ d } | d j | | ƒ } |  j | | | ƒ } t j | | k | | ƒ S(   Ni   (   R   RR   R,   R0   R2   (   R   R3   R—   R˜   R+   R4   R5   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6   µ  s    c   
      C` s   t  j | ƒ t  j | ƒ } } | | d d } | | } | | d d } d } d | | d | | d }	 | | | |	 f S(	   Ng      ð?i   i   g      (@g        g      Àg      @g333333ó¿(   R0   Rq   (
   R   R—   R˜   t   m2t   m1R;   t   dR<   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   »  s    
c         C` sd   |  j  d k	 r6 t | |  j  ƒ } t | |  j  ƒ } n  t j |  j j d t j g ƒ} | | | ƒ S(   s=   An array of *size* random integers >= ``low`` and < ``high``.t   otypesN(   R   R9   R   R0   t	   vectorizeR   t   randintt   int_(   R   R—   R˜   RŸ   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   Ä  s
    !c         C` s   t  | | ƒ S(   N(   R   (   R   R—   R˜   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRC   Ð  s    (
   RD   RE   RF   R!   R)   R,   R6   R?   R   RC   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR–   ‘  s   							RŸ   s#   A discrete uniform (random integer)t   zipf_genc           B` s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sr  A Zipf discrete random variable.

    %(before_notes)s

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

    .. math::

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

    for :math:`k \ge 1`.

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

    %(after_notes)s

    %(example)s

    c         C` s   |  j  j | d |  j ƒS(   NRX   (   R   t   zipfR   (   R   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   ð  s    c         C` s
   | d k S(   Ni   (    (   R   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   ó  s    c         C` s"   d t  j | d ƒ | | } | S(   Ng      ð?i   (   R   t   zeta(   R   R&   R^   R‚   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   ö  s    c         C` s)   t  | | d k | | f d „  t j ƒ S(   Ni   c         S` s$   t  j |  | d ƒ t  j |  d ƒ S(   Ni   (   R   R£   (   R^   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR†   þ  s    (   R	   R0   RS   (   R   R   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   _munpû  s    (   RD   RE   RF   R   R!   R)   R¤   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR¡   Ù  s
   			R¢   s   A Zipft   dlaplace_genc           B` s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sL  A  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         C` s#   t  | d ƒ t | t | ƒ ƒ S(   Ng       @(   R   R   t   abs(   R   R&   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)     s    c         C` sC   t  | ƒ } d „  } d „  } t | d k | | f d | d | ƒS(   Nc         S` s!   d t  | |  ƒ t  | ƒ d S(   Ng      ð?i   (   R   (   R&   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR†   !  s    c         S` s    t  | |  d ƒ t  | ƒ d S(   Ni   (   R   (   R&   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR†   "  s    i    t   ft   f2(   R
   R	   (   R   R%   R^   R&   R§   R¨   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,     s    		c         C` s”   d t  | ƒ } t t j | d d t  | ƒ k  t | | ƒ | d t d | | ƒ | ƒ ƒ } | d } t j |  j | | ƒ | k | | ƒ S(   Ni   g      ð?(   R   R   R0   R2   R   R,   (   R   R3   R^   t   constR+   R4   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR6   %  s    !
c         C` sh   t  | ƒ } d | | d d } d | | d d | d | d d } d | d | | d d f S(   Ng       @g      ð?i   g      $@i   g        g      @(   R   (   R   R^   t   eat   mu2R~   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   -  s    *c         C` s"   | t  | ƒ t t | d ƒ ƒ S(   Ng       @(   R   R   R   (   R   R^   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyRC   3  s    (   RD   RE   RF   R)   R,   R6   R?   RC   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR¥     s   				t   dlaplaces   A discrete Laplaciant   skellam_genc           B` s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sÍ  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         C` s/   |  j  } |  j j | | ƒ |  j j | | ƒ S(   N(   R   R   R   (   R   t   mu1R«   R   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   Y  s    	c         C` s_   t  j | d k  t d | d d | d | ƒ d t d | d d | d | ƒ d ƒ } | S(   Ni    i   i   (   R0   R2   R   (   R   R%   R®   R«   t   px(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   ^  s    #)c      	   C` sc   t  | ƒ } t j | d k  t d | d | d | ƒ d t d | d | d d | ƒ ƒ } | S(   Ni    i   iþÿÿÿi   (   R
   R0   R2   R   (   R   R%   R®   R«   R¯   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   e  s
    )c         C` sB   | | } | | } | t  | d ƒ } d | } | | | | f S(   Ni   i   (   R   (   R   R®   R«   t   meanR<   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   l  s
    


(   RD   RE   RF   R   R)   R,   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR­   ;  s
   			t   skellams	   A Skellamt   yulesimon_genc           B` sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   sî  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         C` sQ   |  j  j |  j ƒ } |  j  j |  j ƒ } t | t t | | ƒ ƒ ƒ } | S(   N(   R   t   standard_exponentialR   R   R   R   (   R   t   alphat   E1t   E2t   ans(    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR   ™  s    #c         C` s   | t  j | | d ƒ S(   Ni   (   R   t   beta(   R   R%   R´   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR)   Ÿ  s    c         C` s
   | d k S(   Ni    (    (   R   R´   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR!   ¢  s    c         C` s   t  | ƒ t j | | d ƒ S(   Ni   (   R   R   R   (   R   R%   R´   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR(   ¥  s    c         C` s   d | t  j | | d ƒ S(   Ni   (   R   R¸   (   R   R%   R´   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR,   ¨  s    c         C` s   | t  j | | d ƒ S(   Ni   (   R   R¸   (   R   R%   R´   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR.   «  s    c         C` s   t  | ƒ t j | | d ƒ S(   Ni   (   R   R   R   (   R   R%   R´   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR[   ®  s    c         C` sP  t  j | d k t  j | | d ƒ } t  j | d k | d | d | d d t  j ƒ } t  j | d k t  j | ƒ } t  j | d k t | d ƒ | d d | | d t  j ƒ } t  j | d k t  j | ƒ } t  j | d k | d | d d | d | | d | d t  j ƒ } t  j | d k t  j | ƒ } | | | | f S(   Ni   i   g       @i   i   i1   i   (   R0   R2   RS   t   nanR   (   R   R´   R;   R«   R=   R>   (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR?   ±  s    &%!(   RD   RE   RF   R   R)   R!   R(   R,   R.   R[   R?   (    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyR²   w  s   !							t	   yulesimon(E   t
   __future__R    R   R   t   scipyR   t   scipy.specialR   R   R   R   R"   t   scipy._lib._numpy_compatR   t   scipy._lib._utilR	   t   numpyR
   R   R   R   R   R   R   R   R   R   R0   t   _distn_infrastructureR   R   R   R   R   RH   RI   RJ   RK   RV   RW   R_   Ra   Rv   Rw   R   R€   R   R‰   R   RŽ   R•   R–   RŸ   R¡   R¢   R¥   RS   R¬   R­   R±   R²   Rº   t   listt   globalst   itemst   pairst   _distn_namest   _distn_gen_namest   __all__(    (    (    s;   lib/python2.7/site-packages/scipy/stats/_discrete_distns.pyt   <module>   sP   "F"F5A<…2=::	C)29K