
    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 	 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deded	ed
edef
dZy)    N)lax)numpy)_const)promote_args_inexact)Array	ArrayLikexblocscalereturnc                 L   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                   |      S )a8  Pareto log probability distribution function.

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

  The Pareto probability density function is given by

  .. math::

     f(x, b) = \begin{cases}
       bx^{-(b+1)} & x \ge 1\\
       0 & x < 1
     \end{cases}

  and is defined for :math:`b > 0`.

  Args:
    x: arraylike, value at which to evaluate the PDF
    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.pareto.logcdf`
    - :func:`jax.scipy.stats.pareto.logsf`
    - :func:`jax.scipy.stats.pareto.cdf`
    - :func:`jax.scipy.stats.pareto.pdf`
    - :func:`jax.scipy.stats.pareto.ppf`
    - :func:`jax.scipy.stats.pareto.sf`
  zpareto.logpdf   )r   
_lax_constr   divsublognegaddmuljnpwhereltnpinf)r	   r
   r   r   onescaled_xnormalize_term	log_probss           V/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/jax/_src/scipy/stats/pareto.pylogpdfr!      s    F */1aeL!QU1a#WWSWWQ_e,(773775!,-.ggGGNCGGCGGAsOSWWX5FGH) 
366!SWWS%01BFF7I	FF    c                 D    t        j                  t        | |||            S )a1  Pareto probability distribution function.

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

  The Pareto probability density function is given by

  .. math::

     f(x, b) = \begin{cases}
       bx^{-(b+1)} & x \ge 1\\
       0 & x < 1
     \end{cases}

  and is defined for :math:`b > 0`.

  Args:
    x: arraylike, value at which to evaluate the PDF
    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.pareto.logcdf`
    - :func:`jax.scipy.stats.pareto.logpdf`
    - :func:`jax.scipy.stats.pareto.logsf`
    - :func:`jax.scipy.stats.pareto.cdf`
    - :func:`jax.scipy.stats.pareto.ppf`
    - :func:`jax.scipy.stats.pareto.sf`
  )r   expr!   r	   r
   r   r   s       r    pdfr&   F   s    F 
1c5)	**r"   c           	         t        d| |||      \  } }}}t        | d      }t        | d      }t        j                  t        j                  | |      |      }t        j                  |t        j
                  |t        j                  |                  }t        j                  t        j                  | t        j                  ||            ||      S )a3  Pareto cumulative distribution function.

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

  The Pareto cumulative distribution function is given by

  .. math::

     F(x, b) = \begin{cases}
       1 - x^{-b} & x \ge 1\\
       0 & x < 1
     \end{cases}

  and is defined for :math:`b > 0`.

  Args:
    x: arraylike, value at which to evaluate the CDF
    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.pareto.logcdf`
    - :func:`jax.scipy.stats.pareto.logpdf`
    - :func:`jax.scipy.stats.pareto.logsf`
    - :func:`jax.scipy.stats.pareto.pdf`
    - :func:`jax.scipy.stats.pareto.ppf`
    - :func:`jax.scipy.stats.pareto.sf`
  z
pareto.cdfr   r   )r   r   r   r   r   powr   r   r   r   r   )r	   r
   r   r   r   zeror   cdfs           r    r*   r*   l   s    F *,1c5I!QU1a#	Aq	$WWSWWQ_e,(SWWXswwqz23#	366!SWWS%014	==r"   c           
         t        d| |||      \  } }}}t        j                  t        j                  | |      |      }t        j                  t        j
                  t        j                  |t        j
                  |                        }t        j                  t        j                  | t        j                  ||            t        j                   |      S )a:  Pareto log cumulative distribution function.

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

  The Pareto cumulative distribution function is given by

  .. math::

     F(x, b) = \begin{cases}
       1 - x^{-b} & x \ge 1\\
       0 & x < 1
     \end{cases}

  and is defined for :math:`b > 0`.

  Args:
    x: arraylike, value at which to evaluate the CDF
    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.pareto.logpdf`
    - :func:`jax.scipy.stats.pareto.logsf`
    - :func:`jax.scipy.stats.pareto.cdf`
    - :func:`jax.scipy.stats.pareto.pdf`
    - :func:`jax.scipy.stats.pareto.ppf`
    - :func:`jax.scipy.stats.pareto.sf`
  zpareto.logcdf)r   r   r   r   log1pr   r(   r   r   r   r   r   r   )r	   r
   r   r   r   
logcdf_vals         r    logcdfr.      s    F */1aeL!QUWWSWWQ_e,(yy3771:!>?@*	366!SWWS%01BFF7J	GGr"   c           	         t        d| |||      \  } }}}t        | d      }t        j                  t        j                  | |      |      }t        j
                  t        j                  |t        j                  |                  }t        j                  t        j                  | t        j                  ||            ||      S )a5  Pareto log survival function.

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

  The Pareto survival function is given by

  .. math::

     S(x, b) = \begin{cases}
       x^{-b} & x \ge 1\\
       1 & x < 1
     \end{cases}

  and is defined for :math:`b > 0`.

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

  Returns:
    array of log survival function values.

  See Also:
    - :func:`jax.scipy.stats.pareto.logcdf`
    - :func:`jax.scipy.stats.pareto.logpdf`
    - :func:`jax.scipy.stats.pareto.cdf`
    - :func:`jax.scipy.stats.pareto.pdf`
    - :func:`jax.scipy.stats.pareto.ppf`
    - :func:`jax.scipy.stats.pareto.sf`
  zpareto.logsfr   )r   r   r   r   r   r   r   r   r   r   r   r   )r	   r
   r   r   r)   r   	logsf_vals          r    logsfr1      s    F *.!QUK!QU	Aq	$WWSWWQ_e,(ggcgga!234)	366!SWWS%014	CCr"   c                 D    t        j                  t        | |||            S )a-  Pareto survival function.

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

  The Pareto survival function is given by

  .. math::

     S(x, b) = \begin{cases}
       x^{-b} & x \ge 1\\
       1 & x < 1
     \end{cases}

  and is defined for :math:`b > 0`.

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

  Returns:
    array of survival function values.

  See Also:
    - :func:`jax.scipy.stats.pareto.logcdf`
    - :func:`jax.scipy.stats.pareto.logpdf`
    - :func:`jax.scipy.stats.pareto.logsf`
    - :func:`jax.scipy.stats.pareto.cdf`
    - :func:`jax.scipy.stats.pareto.pdf`
    - :func:`jax.scipy.stats.pareto.ppf`
  )r   r$   r1   r%   s       r    sfr3      s    F 
q!S%(	))r"   qc                    t        d| |||      \  } }}}t        | d      }t        j                  |t        j                  |t        j
                  t        j                  ||       t        j                  t        j                  ||                              }t        j                  t        j                  |       | dk  z  | dkD  z  t        j                  |      S )a  Pareto percent point function (inverse CDF).

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

  The Pareto percent point function is the inverse of the Pareto CDF, and is
  given by

  .. math::

     F^{-1}(q, b) = \begin{cases}
       (1 - q)^{-1/b} & 0 \le q < 1\\
       \text{NaN} & \text{otherwise}
     \end{cases}

  and is defined for :math:`b > 0`.

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

  Returns:
    array of percent point function values.

  See Also:
    - :func:`jax.scipy.stats.pareto.logcdf`
    - :func:`jax.scipy.stats.pareto.logpdf`
    - :func:`jax.scipy.stats.pareto.logsf`
    - :func:`jax.scipy.stats.pareto.cdf`
    - :func:`jax.scipy.stats.pareto.pdf`
    - :func:`jax.scipy.stats.pareto.sf`
  z
pareto.ppfr   r   )r   r   r   r   r   r(   r   r   r   r   r   isnanr   nan)r4   r
   r   r   r   ppf_vals         r    ppfr9     s    H *,1c5I!QU1a#GGQa1IJ	K' 
399Q<1q5)QU3RVVW	EEr"   )r   r   )r   r   jax._srcr   r   jax._src.lax.laxr   r   jax._src.numpy.utilr   jax._src.typingr   r   r!   r&   r*   r.   r1   r3   r9    r"   r    <module>r?      s      ! 1 4 , FG*G*G*G#,*G9B*G
*G\ FG#+#+#+#,#+9B#+
#+N FG(>(>(>#,(>9B(>
(>X FG&H&H&H#,&H9B&H
&HT FG'D'D'D#,'D9B'D
'DV FG#*#*#*#,#*9B#*
#*N FG)F)F)F#,)F9B)F
)Fr"   