MCPcopy Create free account
hub / github.com/PythonOT/POT / kl_div

Method kl_div

ot/backend.py:984–998  ·  view source on GitHub ↗

r""" Computes the (Generalized) Kullback-Leibler divergence. This function follows the api from :any:`scipy.stats.entropy`. Parameter eps is used to avoid numerical errors and is added in the log. .. math:: KL(p,q) = \langle \mathbf{p}, log(\mathbf{p}

(self, p, q, mass=False, eps=1e-16)

Source from the content-addressed store, hash-verified

982 raise NotImplementedError()
983
984 def kl_div(self, p, q, mass=False, eps=1e-16):
985 r"""
986 Computes the (Generalized) Kullback-Leibler divergence.
987
988 This function follows the api from :any:`scipy.stats.entropy`.
989
990 Parameter eps is used to avoid numerical errors and is added in the log.
991
992 .. math::
993 KL(p,q) = \langle \mathbf{p}, log(\mathbf{p} / \mathbf{q} + eps \rangle
994 + \mathbb{1}_{mass=True} \langle \mathbf{q} - \mathbf{p}, \mathbf{1} \rangle
995
996 See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html
997 """
998 raise NotImplementedError()
999
1000 def isfinite(self, a):
1001 r"""

Callers 14

test_empty_backendFunction · 0.95
co_optimal_transportFunction · 0.45
solveFunction · 0.45
reg_klFunction · 0.45
marg_klFunction · 0.45
mm_unbalancedFunction · 0.45
div_between_productFunction · 0.45
uot_cost_matrixFunction · 0.45

Calls

no outgoing calls

Tested by 3

test_empty_backendFunction · 0.76
test_func_backendsFunction · 0.36
test_kl_divFunction · 0.36