
    uki                         d dl Zd dlmZ d dlm Z d dlmZ d dlm	Z	 d dl
mZ d dlmZmZ 	 dded	ed
edededefdZ	 dded	ed
edededefdZy)    N)lax)numpy)_const)promote_args_inexact)betaln)Array	ArrayLikeknablocreturnc                    t        d| ||||      \  } }}}}t        j                  t        j                  |       |      }t	        |d      }t	        |d      }t        j
                  t        j                  t        j                  |      t        t        j                  t        j                  ||      |      t        j                  ||                        }t        j                  t        t        j                  ||      t        j                  t        j                  ||      |            t        ||            }	t        j                  ||	      }
t        j                  t        j                  t        j                  ||      t        j                  ||            d|
      }
t        j                  t        j                  t        j                  |t        j
                  |            t        j                  ||            t        j                   t        j                  ||      |            }t        j                  |t"        j$                   |
      }
t        j                  t        j                  t        j                  ||      t        j                   ||            t        j                   ||            }t        j                  |t"        j&                  |
      S )a
  Beta-binomial log probability mass function.

  JAX implementation of :obj:`scipy.stats.betabinom` ``logpmf``

  The beta-binomial distribution's probability mass function is defined as

  .. math::

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

  where :math:`B(a, b)` is the :func:`~jax.scipy.special.beta` function. It is
  defined for :math:`n\ge 0`, :math:`a>0`, :math:`b>0`, and non-negative integers `k`.

  Args:
    k: arraylike, value at which to evaluate the PMF
    n: arraylike, distribution shape parameter
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter

  Returns:
    array of logpmf values

  See Also:
    :func:`jax.scipy.stats.betabinom.pmf`
  zbetabinom.logpmf   r   g        )r   r   subfloor
_lax_constnegaddlog1pr   jnpwherelogical_andeq
logical_orltgtlenpinfnan)r
   r   r   r   r   yonezerocombilnbeta_lns	log_probsy_cond
n_a_b_conds                Y/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/_src/scipy/stats/betabinom.pylogpmfr,      s   8 ));Q1aM/!Q1c	ggciilC !1a#	Aq	$GGCGGCIIaL&1s1KSWWUVWZ^*\]^'WWVCGGAaL#''#''!A,q*ABF1QKP(gggx()iiq$4I2yY)>>#..3773<)@#&&A,O&&A57&ii3)~~cnnSVVAt_cffQoNPSPVPVWXZ^P_`*	:rvvy	11    c           	      F    t        j                  t        | ||||            S )a  Beta-binomial probability mass function.

  JAX implementation of :obj:`scipy.stats.betabinom` ``pmf``.

  The beta-binomial distribution's probability mass function is defined as

  .. math::

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

  where :math:`B(a, b)` is the :func:`~jax.scipy.special.beta` function. It is
  defined for :math:`n\ge 0`, :math:`a>0`, :math:`b>0`, and non-negative integers `k`.

  Args:
    k: arraylike, value at which to evaluate the PMF
    n: arraylike, distribution shape parameter
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter

  Returns:
    array of pmf values

  See Also:
    :func:`jax.scipy.stats.betabinom.logpmf`
  )r   expr,   )r
   r   r   r   r   s        r+   pmfr0   D   s     8 
1aC(	))r-   )r   )r   r    jax._srcr   r   jax._src.lax.laxr   r   jax._src.numpy.utilr   jax._src.scipy.specialr   jax._src.typingr   r	   r,   r0    r-   r+   <module>r7      s      ! 1 4 ) , (2i (2I (2) (2	 (2(2"'(2X *9 * *y *Y **$*r-   