
    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mZmZ d dlmZmZ dded	ed
ededef
dZdded	ed
ededef
dZy)    N)lax)numpy)promote_args_inexact)_const)gammalnxlogyxlog1py)Array	ArrayLikeknplocreturnc           
         t        d| |||      \  } }}}t        j                  | |      }t        |d      }t        j                  t	        |dz         t        j
                  t	        |dz         t	        ||z
  dz                     }t        j
                  t        ||      t        t        j                  ||      t        j                  |                  }t        j
                  ||      }t        j                  t        j                  t        j                  ||      t        j                  ||            t        j                  ||            }	t        j                  |	d|      }t        j                  t        j                  | |      t        j                  | ||z   dz         z  |t         j"                         S )aE  Binomial log probability mass function.

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

  The binomial probability mass function is defined as

  .. math::

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

  for :math:`0\le p\le 1` and non-negative integers :math:`k`.

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

  Returns:
    array of logpmf values.

  See Also:
    :func:`jax.scipy.stats.binom.pmf`
  zbinom.logpmfr      g        )r   r   sub
_lax_constr   addr   r	   negjnp
logical_orlogical_andeqwheregeltnpinf)
r   r   r   r   yzero	comb_termlog_linear_term	log_probsy_n_conds
             U/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/_src/scipy/stats/binom.pylogpmfr'      s@   2 &naAsC,!Q3	ggao!	Aq	$gga!en	ggga!enga!eai01) GGE!QKA
)KL/ggi1)^^COOCFF1dOSVVAt_MFF?D9;(ii"i0)	366!S>CFF1cAgk$::Iw	OO    c                 D    t        j                  t        | |||            S )a@  Binomial probability mass function.

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

  The binomial probability mass function is defined as

  .. math::

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

  for :math:`0\le p\le 1` and non-negative integers :math:`k`.

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

  Returns:
      array of pmf values.

  See Also:
    :func:`jax.scipy.stats.binom.logpmf`
  )r   expr'   )r   r   r   r   s       r&   pmfr+   A   s    2 
1a%	&&r(   )r   )r   r   jax._srcr   r   jax._src.numpy.utilr   jax._src.lax.laxr   r   jax._src.scipy.specialr   r   r	   jax._src.typingr
   r   r'   r+    r(   r&   <module>r2      sv      ! 4 1 : : ,%Pi %PI %P) %P) %PE %PP'9 ' 'y 'y ' 'r(   