SciPy

scipy.special.entr

scipy.special.entr(x) = <ufunc 'entr'>

Elementwise function for computing entropy.

\[\begin{split}\text{entr}(x) = \begin{cases} - x \log(x) & x > 0 \\ 0 & x = 0 \\ -\infty & \text{otherwise} \end{cases}\end{split}\]
Parameters:

x : ndarray

Input array.

Returns:

res : ndarray

The value of the elementwise entropy function at the given points x.

See also

kl_div, rel_entr

Notes

This function is concave.

New in version 0.15.0.