
    `i                     0    d dl Z d dlZd dlmZ d ZddZdS )    N)specialc                 j    |                      |d          }| j        j        dk    r| |z  } n| |z  } | S )z4Normalize, preserving floating point precision of x.T)axiskeepdimsf)sumdtypekind)xr   x_sums      t/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/stats/_distributions.py
_normalizer      s?    EEtdE++Ew|s	U
IH    c                 D   | j         j        dk    s||j         j        dk    rt          d          | j         j        dv rt          j        nt          j        }|                     |d          } t          | |          } |t          j
        |           }n[|j        | j        k    rt          d          |                    |d          }t          ||          }t          j        | |          }t	          j        ||          }||t          j        |          z  }|S )	a  Calculate the entropy of a distribution for given probability values.

    If only probabilities ``pk`` are given, the entropy is calculated as
    ``S = -sum(pk * log(pk), axis=axis)``.

    If ``qk`` is not None, then compute the Kullback-Leibler divergence
    ``S = sum(pk * log(pk / qk), axis=axis)``.

    This routine will normalize ``pk`` and ``qk`` if they don't sum to 1.

    Args:
        pk (ndarray): Defines the (discrete) distribution. ``pk[i]`` is the
            (possibly unnormalized) probability of event ``i``.
        qk (ndarray, optional): Sequence against which the relative entropy is
            computed. Should be in the same format as ``pk``.
        base (float, optional): The logarithmic base to use, defaults to ``e``
            (natural logarithm).
        axis (int, optional): The axis along which the entropy is calculated.
            Default is 0.

    Returns:
        S (cupy.ndarray): The calculated entropy.

    cNzcomplex dtype not supportedefF)copyzqk and pk must have same shape.)r   )r	   r
   	TypeErrorcharcupyfloat32float64astyper   r   entrshape
ValueErrorrel_entrr   mathlog)pkqkbaser   
float_typevecss          r   entropyr&      s   2 
x}r~"(-32F2F5666!#$!6!6DLJ	:E	*	*B	B		B	zl28rx>???YYzY..D!!r2&&4   A	TXd^^Hr   )NNr   )r   r   cupyx.scipyr   r   r&    r   r   <module>r)      sV             * * * * * *r   