scipy.special.kl_div¶
- scipy.special.kl_div(x, y) = <ufunc 'kl_div'>¶
Elementwise function for computing Kullback-Leibler divergence.
\[\begin{split}\text{kl\_div}(x, y) = \begin{cases} x \log(x / y) - x + y & x > 0, y > 0 \\ y & x = 0, y \ge 0 \\ \infty & \text{otherwise} \end{cases}\end{split}\]Parameters: x : ndarray
First input array.
y : ndarray
Second input array.
Returns: res : ndarray
Output array.
Notes
This function is non-negative and is jointly convex in x and y.
New in version 0.14.0.