
    Vpf              	           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lmZmZ ddeded	ed
efdZddeded	ed
efdZdeded
efdZdeded
efdZdS )    )laxN)_const)promote_args_inexact)Array	ArrayLike)xlogyxlog1pykplocreturnc           	         t          d| ||          \  } }}t          | d          }t          | d          }t          j        | |          }t	          ||          t          t          j        ||          |           z   }t          j        t          j        t          j	        ||          t          j
        ||                    t          j         |          S )ax  Bernoulli log probability mass function.

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

  The Bernoulli probability mass function is defined as

  .. math::

     f(k) = \begin{cases}
       1 - p, & k = 0 \\
       p, & k = 1 \\
       0, & \mathrm{otherwise}
     \end{cases}

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

  Returns:
    array of logpmf values

  See Also:
    - :func:`jax.scipy.stats.bernoulli.cdf`
    - :func:`jax.scipy.stats.bernoulli.pmf`
    - :func:`jax.scipy.stats.bernoulli.ppf`
  zbernoulli.logpmfr      )r   
_lax_constr   subr   r	   jnpwhere
logical_orltgtinf)r
   r   r   zeroonex	log_probss          ^/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/scipy/stats/bernoulli.pylogpmfr      s    8 ##5q!SAA)!Q	Aq		$1a#	gaoo!AqkkGCGCOOaR888)	3>#&D//36!S>>BB7(I
' 
' '    c                 H    t          j        t          | ||                    S )aq  Bernoulli probability mass function.

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

  The Bernoulli probability mass function is defined as

  .. math::

     f(k) = \begin{cases}
       1 - p, & k = 0 \\
       p, & k = 1 \\
       0, & \mathrm{otherwise}
     \end{cases}

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

  Returns:
    array of pmf values

  See Also:
    - :func:`jax.scipy.stats.bernoulli.cdf`
    - :func:`jax.scipy.stats.bernoulli.logpmf`
    - :func:`jax.scipy.stats.bernoulli.ppf`
  )r   expr   )r
   r   r   s      r   pmfr!   <   s     8 
1c""	#	##r   c           	         t          d| |          \  } }t          | d          t          | d          }}t          j        |           t          j        |          z  ||k     z  ||k    z  t	          j        | |          t          j        t	          j        | |          t	          j        | |                    t	          j        | |          g}t          j        |||z
  |g}t          j	        ||          S )a  Bernoulli cumulative distribution function.

  JAX implementation of :obj:`scipy.stats.bernoulli` ``cdf``

  The Bernoulli cumulative distribution function is defined as:

  .. math::

     f_{cdf}(k, p) = \sum_{i=0}^k f_{pmf}(k, p)

  where :math:`f_{pmf}(k, p)` is the Bernoulli probability mass function
  :func:`jax.scipy.stats.bernoulli.pmf`.

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

  Returns:
    array of cdf values

  See Also:
    - :func:`jax.scipy.stats.bernoulli.logpmf`
    - :func:`jax.scipy.stats.bernoulli.pmf`
    - :func:`jax.scipy.stats.bernoulli.ppf`
  zbernoulli.cdfr   r   )
r   r   r   isnanr   r   logical_andgenanselect)r
   r   r   r   condsvalss         r   cdfr*   [   s    6 
oq!	4	4$!QA
1a 0 0$IaLL39Q<<1t8,C8F1dOOOCF1dOOSVAs^^44F1cNN	% '4q#	&$	E4	 	  r   qc                    t          d| |          \  } }t          | d          t          | d          }}t          j        t          j        |           t          j        |          z  ||k     z  ||k    z  | |k     z  | |k    z  t          j        t          j        t          j        | ||z
            ||                    S )a.  Bernoulli percent point function.

  JAX implementation of :obj:`scipy.stats.bernoulli` ``ppf``

  The percent point function is the inverse of the cumulative
  distribution function, :func:`jax.scipy.stats.bernoulli.cdf`.

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

  Returns:
    array of ppf values

  See Also:
    - :func:`jax.scipy.stats.bernoulli.cdf`
    - :func:`jax.scipy.stats.bernoulli.logpmf`
    - :func:`jax.scipy.stats.bernoulli.pmf`
  zbernoulli.ppfr   r   )r   r   r   r   r#   r&   r   le)r+   r   r   r   s       r   ppfr.      s    * 
oq!	4	4$!QA
1a 0 0$	IaLL39Q<<1t8,C8AHESQGIcfQa  $,,
 
 r   )r   )jaxr   	jax.numpynumpyr   jax._src.lax.laxr   r   jax._src.numpy.utilr   jax._src.typingr   r   jax.scipy.specialr   r	   r   r!   r*   r.    r   r   <module>r7      sG               1 1 1 1 1 1 4 4 4 4 4 4 , , , , , , , , , , , , , , , ,"' "'i "'I "'I "'e "' "' "' "'J$ $9 $ $ $5 $ $ $ $>$!9 $! $!u $! $! $! $!N9  u      r   