
    VpfH                     
   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def
d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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dded	ed
ededef
dZdS )    )laxN)_const)promote_args_inexact)Array	ArrayLike)gammainc	gammaincc   xdflocscalereturnc                 j   t          d| |||          \  } }}}t          | d          }t          | 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        |	t          j        |                    |          }
t          j        t          j        | |          t          j         |
          S )a  Chi-square log probability distribution function.

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

  The chi-square probability distribution function is given by:

  .. math::

     f(x, k) = \begin{cases}
       \frac{x^{k/2-1}e^{-x/2}}{2^{k/2}\Gamma(k/2)} & x \ge 0 \\
       0 & \mathrm{otherwise}
     \end{cases}

  for :math:`k` degrees of freedom, and where :math:`\Gamma` is the
  :func:`~jax.scipy.special.gamma` function. JAX follows the scipy
  convention of using ``df`` to denote degrees of freedom.

  Args:
    x: arraylike, value at which to evaluate the PDF
    df: 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.chi2.cdf`
    - :func:`jax.scipy.stats.chi2.pdf`
    - :func:`jax.scipy.stats.chi2.sf`
    - :func:`jax.scipy.stats.chi2.logcdf`
    - :func:`jax.scipy.stats.chi2.logsf`
  zchi2.logpdfr
      )r   
_lax_constr   divsubmullognegaddlgammajnpwhereltinf)r   r   r   r   onetwoy	df_on_twokernel	nrml_cnst	log_probss              Y/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/scipy/stats/chi2.pylogpdfr&      s6   D +=!ReLL!Re1a#1a#	gcgaoou%%!gb#)737379c22CGAJJ??3PP&gcgcj33CGCGCGCLLRT<U<UVY4Z4Z[[\\)gcgi88&AA)	36!S>>CG8Y	7	77    c                 J    t          j        t          | |||                    S )a  Chi-square probability distribution function.

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

  The chi-square probability distribution function is given by:

  .. math::

     f(x, k) = \begin{cases}
       \frac{x^{k/2-1}e^{-x/2}}{2^{k/2}\Gamma(k/2)} & x \ge 0 \\
       0 & \mathrm{otherwise}
     \end{cases}

  for :math:`k` degrees of freedom, and where :math:`\Gamma` is the
  :func:`~jax.scipy.special.gamma` function. JAX follows the scipy
  convention of using ``df`` to denote degrees of freedom.

  Args:
    x: arraylike, value at which to evaluate the PDF
    df: 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.chi2.cdf`
    - :func:`jax.scipy.stats.chi2.sf`
    - :func:`jax.scipy.stats.chi2.logcdf`
    - :func:`jax.scipy.stats.chi2.logpdf`
    - :func:`jax.scipy.stats.chi2.logsf`
  )r   expr&   r   r   r   r   s       r%   pdfr+   G   s#    D 
2sE**	+	++r'   c                 ~   t          d| |||          \  } }}}t          |d          }t          t          j        ||          t          j        t          | d          t          j        t          j        | |          t          j        ||                    t          | t          j	                                      S )aQ  Chi-square cumulative distribution function.

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

  The cdf is defined as

  .. math::

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

  where :math:`f_{pdf}` is the probability density function,
  :func:`jax.scipy.stats.chi2.pdf`. JAX follows the scipy
  convention of using ``df`` to denote degrees of freedom.

  Args:
    x: arraylike, value at which to evaluate the CDF
    df: 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.chi2.pdf`
    - :func:`jax.scipy.stats.chi2.sf`
    - :func:`jax.scipy.stats.chi2.logcdf`
    - :func:`jax.scipy.stats.chi2.logpdf`
    - :func:`jax.scipy.stats.chi2.logsf`
  zchi2.cdfr   r   )
r   r   r   r   r   clampr   r   r   r   r   r   r   r   r   s        r%   cdfr/   l   s    > +:q"c5II!Re5!#	GBIA	g3s  CG 

 

 
r'   c                 J    t          j        t          | |||                    S )aW  Chi-square log cumulative distribution function.

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

  The cdf is defined as

  .. math::

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

  where :math:`f_{pdf}` is the probability density function,
  :func:`jax.scipy.stats.chi2.pdf`. JAX follows the scipy
  convention of using ``df`` to denote degrees of freedom.

  Args:
    x: arraylike, value at which to evaluate the CDF
    df: 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.chi2.cdf`
    - :func:`jax.scipy.stats.chi2.pdf`
    - :func:`jax.scipy.stats.chi2.sf`
    - :func:`jax.scipy.stats.chi2.logpdf`
    - :func:`jax.scipy.stats.chi2.logsf`
  )r   r   r/   r*   s       r%   logcdfr1      s"    > 
QC''	(	((r'   c                 ~   t          d| |||          \  } }}}t          |d          }t          t          j        ||          t          j        t          | d          t          j        t          j        | |          t          j        ||                    t          | t          j	                                      S )a?  Chi-square survival function.

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

  The survival function is defined as

  .. math::

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

  where :math:`f_{cdf}(x, k)` is the cumulative distribution function,
  :func:`jax.scipy.stats.chi2.cdf`. JAX follows the scipy
  convention of using ``df`` to denote degrees of freedom.

  Args:
    x: arraylike, value at which to evaluate the SF
    df: 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.chi2.cdf`
    - :func:`jax.scipy.stats.chi2.pdf`
    - :func:`jax.scipy.stats.chi2.logcdf`
    - :func:`jax.scipy.stats.chi2.logpdf`
    - :func:`jax.scipy.stats.chi2.logsf`
  zchi2.sfr   r   )
r   r   r	   r   r   r-   r   r   r   r   r.   s        r%   sfr3      s    > +9aS%HH!Re5!#	GBIA	g3s  CG 

 

 
r'   c                 J    t          j        t          | |||                    S )aF  Chi-square log survival function.

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

  The survival function is defined as

  .. math::

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

  where :math:`f_{cdf}(x, k)` is the cumulative distribution function,
  :func:`jax.scipy.stats.chi2.cdf`. JAX follows the scipy
  convention of using ``df`` to denote degrees of freedom.

  Args:
    x: arraylike, value at which to evaluate the SF
    df: 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.chi2.cdf`
    - :func:`jax.scipy.stats.chi2.pdf`
    - :func:`jax.scipy.stats.chi2.sf`
    - :func:`jax.scipy.stats.chi2.logcdf`
    - :func:`jax.scipy.stats.chi2.logpdf`
  )r   r   r3   r*   s       r%   logsfr5      s"    > 
Ar3&&	'	''r'   )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/   r1   r3   r5    r'   r%   <module>r>      s               1 1 1 1 1 1 4 4 4 4 4 4 , , , , , , , , 1 1 1 1 1 1 1 1-8 -8i -8Y -8Y -89 -8UZ -8 -8 -8 -8`", ",9 ",) ",) ",	 ",RW ", ", ", ",J+ +9 +) +) +	 +RW + + + +\) )i )Y )Y )9 )UZ ) ) ) )D+ +) + + +y +QV + + + +\( (Y (I (I () (TY ( ( ( ( ( (r'   