
    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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ed
edefdZdS )    )laxN)_const)promote_dtypes_inexact)gammalnxlogy)Array	ArrayLikexreturnc                     t          j        | d          }t          j        | dk    d          t          |dz
            dk     z  S )Nr   axis   gư>)jnpsumallabs)r
   x_sums     ^/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/scipy/stats/dirichlet.py_is_simplexr      sC    
'!!


%	QQ			3uqy>>D#8	99    alphac                 0    t          t          | |           S )aV  Dirichlet log probability distribution function.

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

  The Dirichlet probability density function is

  .. math::

     f(\mathbf{x}) = \frac{1}{B(\mathbf{\alpha})} \prod_{i=1}^K x_i^{\alpha_i - 1}

  where :math:`B(\mathbf{\alpha})` is the :func:`~jax.scipy.special.beta` function
  in a :math:`K`-dimensional vector space.

  Args:
    x: arraylike, value at which to evaluate the PDF
    alpha: arraylike, distribution shape parameter

  Returns:
    array of logpdf values.

  See Also:
    :func:`jax.scipy.stats.dirichlet.pdf`
  )_logpdfr   r
   r   s     r   logpdfr      s    0 
(E22	33r   c           
         |j         dk    rt          d|j                   | j        d         |j        d         |j        d         dz
  fvrt          d| j         d|j                   t          | d          }| j        d         |j        d         k    r@t	          j        | t          j        ||                     dd                    gd          } t	          j        t          |                    t          t	          j        |                    z
  }| j         dk    r)t          j
        ||j        d	| j         dz
  z  z   d
          }t          j        t	          j        t          t          j        ||          |           d          |          }t	          j        t          |           |t          j                   S )Nr   z1`alpha` must be one-dimensional; got alpha.shape=r   z[`x` must have either the same number of entries as `alpha` or one entry fewer; got x.shape=z, alpha.shape=T)keepdimsr   )r   )r   )ndim
ValueErrorshape
_lax_constr   concatenater   subr   r   broadcast_in_dimr   wherer   inf)r
   r   onenormalize_term	log_probss        r   r   r   6   s   
Z1__
G%+GG   WQZAA(:;;;
N)*N N@EN N   	1a#WQZ5;q>!!CGCq4)@)@AABKKKA775>>**WSWU^^-D-DD.VaZZ dafqj6I(I4PPEgcgeCGE3$7$7;;!DDDnUU)	;q>>9swh	7	77r   c                 F    t          j        t          | |                    S )aO  Dirichlet probability distribution function.

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

  The Dirichlet probability density function is

  .. math::

     f(\mathbf{x}) = \frac{1}{B(\mathbf{\alpha})} \prod_{i=1}^K x_i^{\alpha_i - 1}

  where :math:`B(\mathbf{\alpha})` is the :func:`~jax.scipy.special.beta` function
  in a :math:`K`-dimensional vector space.

  Args:
    x: arraylike, value at which to evaluate the PDF
    alpha: arraylike, distribution shape parameter

  Returns:
    array of pdf values.

  See Also:
    :func:`jax.scipy.stats.dirichlet.logpdf`
  )r   expr   r   s     r   pdfr-   J   s    0 
5!!	"	""r   )jaxr   	jax.numpynumpyr   jax._src.lax.laxr   r"   jax._src.numpy.utilr   jax.scipy.specialr   r   jax._src.typingr   r	   r   r   r   r-    r   r   <module>r6      s&               1 1 1 1 1 1 6 6 6 6 6 6 , , , , , , , , , , , , , , , ,:5 :U : : : :
4i 4	 4e 4 4 4 448u 8U 8u 8 8 8 8(#9 #Y #5 # # # # # #r   