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

Function dist0

ot/utils.py:426–447  ·  view source on GitHub ↗

r"""Compute standard cost matrices of size (`n`, `n`) for OT problems Parameters ---------- n : int Size of the cost matrix. method : str, optional Type of loss matrix chosen from: * 'lin_square' : linear sampling between 0 and `n-1`, quadratic loss Ret

(n, method="lin_square")

Source from the content-addressed store, hash-verified

424
425
426def dist0(n, method="lin_square"):
427 r"""Compute standard cost matrices of size (`n`, `n`) for OT problems
428
429 Parameters
430 ----------
431 n : int
432 Size of the cost matrix.
433 method : str, optional
434 Type of loss matrix chosen from:
435
436 * 'lin_square' : linear sampling between 0 and `n-1`, quadratic loss
437
438 Returns
439 -------
440 M : ndarray, shape (`n1`, `n2`)
441 Distance matrix computed with given metric.
442 """
443 res = 0
444 if method == "lin_square":
445 x = np.arange(n, dtype=np.float64).reshape((n, 1))
446 res = dist(x, x)
447 return res
448
449
450def cost_normalization(C, norm=None, return_value=False, value=None):

Callers

nothing calls this directly

Calls 3

distFunction · 0.70
reshapeMethod · 0.45
arangeMethod · 0.45

Tested by

no test coverage detected