SciPy

scipy.special.kl_div

scipy.special.kl_div(x, y) = <ufunc 'kl_div'>

Elementwise function for computing Kullback-Leibler divergence.

kl_div(x,y)={xlog(x/y)x+yx>0,y>0yx=0,y0otherwise
Parameters
xndarray

First input array.

yndarray

Second input array.

Returns
resndarray

Output array.

See also

entr, rel_entr

Notes

This function is non-negative and is jointly convex in x and y.

New in version 0.15.0.

Previous topic

scipy.special.rel_entr

Next topic

scipy.special.huber