
    ukiZ                     <   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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	 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	 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betaincxlogyxlog1py)Array	ArrayLikexablocscalereturnc                 6   t        d| ||||      \  } }}}}t        | d      }t        |d      }t        j                  t	        ||            }t        j
                  t        j                  | |      |      }t        j                  t        t        j                  ||      |      t        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$                  ||            t        j$                  ||            t         j&                  |      }|S )ai  Beta log probability distribution function.

  JAX implementation of :obj:`scipy.stats.beta` ``logpdf``.

  The pdf of the beta function is:

  .. math::

    f(x, a, b) = \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}

  where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function,
  It is defined for :math:`0\le x\le 1` and :math:`b>0`.

  Args:
    x: arraylike, value at which to evaluate the PDF
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter
    scale: arraylike, distribution scale parameter

  Returns:
    array of logpdf values

  See Also:
    - :func:`jax.scipy.stats.beta.cdf`
    - :func:`jax.scipy.stats.beta.pdf`
    - :func:`jax.scipy.stats.beta.sf`
    - :func:`jax.scipy.stats.beta.logcdf`
    - :func:`jax.scipy.stats.beta.logsf`
  zbeta.logpdf   r   )r   
_lax_constr   negr   divsubaddr	   r
   logjnpwhere
logical_orgtltnpinflenan)r   r   r   r   r   onezero
shape_termylog_linear_term	log_probsresultresult_positive_constantss                T/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/_src/scipy/stats/beta.pylogpdfr-      sw   @ -]Aq!S%P!Q31a#	Aq	$wwva|$*	ggcggaou%!GGE#''!S/15#CGGAsOSWWQZ@B/ggcggj/:CGGENK)99S^^CFF1cggc5.A$B$'FF1cN468ffWiI&!iis~~cffQPToWZW]W]^_aeWf7g7:vveT7J)LMOVVU[]	""    c           	      F    t        j                  t        | ||||            S )ab  Beta probability distribution function.

  JAX implementation of :obj:`scipy.stats.beta` ``pdf``.

  The pdf of the beta function is:

  .. math::

    f(x, a, b) = \frac{\Gamma(a + b)}{\Gamma(a)\Gamma(b)} x^{a-1}(1-x)^{b-1}

  where :math:`\Gamma` is the :func:`~jax.scipy.special.gamma` function.
  It is defined for :math:`0\le x\le 1` and :math:`b>0`.

  Args:
    x: arraylike, value at which to evaluate the PDF
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter
    scale: arraylike, distribution scale parameter

  Returns:
    array of pdf values

  See Also:
    - :func:`jax.scipy.stats.beta.cdf`
    - :func:`jax.scipy.stats.beta.sf`
    - :func:`jax.scipy.stats.beta.logcdf`
    - :func:`jax.scipy.stats.beta.logpdf`
    - :func:`jax.scipy.stats.beta.logsf`
  )r   expr-   r   r   r   r   r   s        r,   pdfr2   H   s!    @ 
1ae,	--r.   c                     t        d| ||||      \  } }}}}t        ||t        j                  t	        | d      t        j
                  t        j                  | |      |      t	        | d                  S )a>  Beta cumulative distribution function

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

  The cdf is defined as

  .. math::

     f_{cdf}(x, a, b) = \int_{-\infty}^x f_{pdf}(y, a, b)\mathrm{d}y

  where :math:`f_{pdf}` is the beta distribution probability density function,
  :func:`jax.scipy.stats.beta.pdf`.

  Args:
    x: arraylike, value at which to evaluate the CDF
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter
    scale: arraylike, distribution scale parameter

  Returns:
    array of cdf values

  See Also:
    - :func:`jax.scipy.stats.beta.pdf`
    - :func:`jax.scipy.stats.beta.sf`
    - :func:`jax.scipy.stats.beta.logcdf`
    - :func:`jax.scipy.stats.beta.logpdf`
    - :func:`jax.scipy.stats.beta.logsf`
  zbeta.cdfr   r   r   r   r   clampr   r   r   r1   s        r,   cdfr6   k   so    @ -ZAq#uM!Q3	IIA	ggcggaou%A
 r.   c           	      F    t        j                  t        | ||||            S )aF  Beta log cumulative distribution function.

  JAX implementation of :obj:`scipy.stats.beta` ``logcdf``.

  The cdf is defined as

  .. math::

     f_{cdf}(x, a, b) = \int_{-\infty}^x f_{pdf}(y, a, b)\mathrm{d}y

  where :math:`f_{pdf}` is the beta distribution probability density function,
  :func:`jax.scipy.stats.beta.pdf`.

  Args:
    x: arraylike, value at which to evaluate the CDF
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter
    scale: arraylike, distribution scale parameter

  Returns:
    array of logcdf values

  See Also:
    - :func:`jax.scipy.stats.beta.cdf`
    - :func:`jax.scipy.stats.beta.pdf`
    - :func:`jax.scipy.stats.beta.sf`
    - :func:`jax.scipy.stats.beta.logpdf`
    - :func:`jax.scipy.stats.beta.logsf`
  )r   r   r6   r1   s        r,   logcdfr8      s!    @ 
Q1c5)	**r.   c                     t        d| ||||      \  } }}}}t        ||dt        j                  t	        | d      t        j
                  t        j                  | |      |      t	        | d            z
        S )a1  Beta distribution survival function.

  JAX implementation of :obj:`scipy.stats.beta` ``sf``.

  The survival function is defined as

  .. math::

     f_{sf}(x, a, b) = 1 - f_{cdf}(x, a, b)

  where :math:`f_{cdf}(x, a, b)` is the beta cumulative distribution function,
  :func:`jax.scipy.stats.beta.cdf`.

  Args:
    x: arraylike, value at which to evaluate the SF
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter
    scale: arraylike, distribution scale parameter

  Returns:
    array of sf values.

  See Also:
    - :func:`jax.scipy.stats.beta.cdf`
    - :func:`jax.scipy.stats.beta.pdf`
    - :func:`jax.scipy.stats.beta.logcdf`
    - :func:`jax.scipy.stats.beta.logpdf`
    - :func:`jax.scipy.stats.beta.logsf`
  zbeta.sfr   r   r4   r1   s        r,   sfr:      sv    @ -Y1aeL!Q3			A	ggcggaou%A	 
 r.   c           	      F    t        j                  t        | ||||            S )a8  Beta distribution log survival function.

  JAX implementation of :obj:`scipy.stats.beta` ``logsf``.

  The survival function is defined as

  .. math::

     f_{sf}(x, a, b) = 1 - f_{cdf}(x, a, b)

  where :math:`f_{cdf}(x, a, b)` is the beta cumulative distribution function,
  :func:`jax.scipy.stats.beta.cdf`.

  Args:
    x: arraylike, value at which to evaluate the SF
    a: arraylike, distribution shape parameter
    b: arraylike, distribution shape parameter
    loc: arraylike, distribution offset parameter
    scale: arraylike, distribution scale parameter

  Returns:
    array of logsf values.

  See Also:
    - :func:`jax.scipy.stats.beta.cdf`
    - :func:`jax.scipy.stats.beta.pdf`
    - :func:`jax.scipy.stats.beta.sf`
    - :func:`jax.scipy.stats.beta.logcdf`
    - :func:`jax.scipy.stats.beta.logpdf`
  )r   r   r:   r1   s        r,   logsfr<      s!    @ 
Aq!S%(	))r.   )r   r   )r   r    jax._srcr   r   jax._src.lax.laxr   r   jax._src.numpy.utilr   jax._src.scipy.specialr   r   r	   r
   jax._src.typingr   r   r-   r2   r6   r8   r:   r<    r.   r,   <module>rC      sn     ! 1 4 B B , 34,#i ,#I ,#) ,#,#&/,#8=,#` 01 .9  .  .y  . .#, .5: .H 01)9 ) )y ))#,)5:)Z 34 +i  +I  +)  + +&/ +8= +H /0)) )	 )i ))"+)49)Z 23 *Y  *9  *  * *%. *7< *r.   