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

Function test_unmix

test/test_bregman.py:1082–1113  ·  view source on GitHub ↗
(nx)

Source from the content-addressed store, hash-verified

1080
1081
1082def test_unmix(nx):
1083 n_bins = 50 # nb bins
1084
1085 # Gaussian distributions
1086 a1 = ot.datasets.make_1D_gauss(n_bins, m=20, s=10) # m= mean, s= std
1087 a2 = ot.datasets.make_1D_gauss(n_bins, m=40, s=10)
1088
1089 a = ot.datasets.make_1D_gauss(n_bins, m=30, s=10)
1090
1091 # creating matrix A containing all distributions
1092 D = np.vstack((a1, a2)).T
1093
1094 # loss matrix + normalization
1095 M = ot.utils.dist0(n_bins)
1096 M /= M.max()
1097
1098 M0 = ot.utils.dist0(2)
1099 M0 /= M0.max()
1100 h0 = ot.unif(2)
1101
1102 ab, Db, M_nx, M0b, h0b = nx.from_numpy(a, D, M, M0, h0)
1103
1104 # wasserstein
1105 reg = 1e-3
1106 um_np = ot.bregman.unmix(a, D, M, M0, h0, reg, 1, alpha=0.01)
1107 um = nx.to_numpy(ot.bregman.unmix(ab, Db, M_nx, M0b, h0b, reg, 1, alpha=0.01))
1108
1109 np.testing.assert_allclose(1, np.sum(um), rtol=1e-03, atol=1e-03)
1110 np.testing.assert_allclose([0.5, 0.5], um, rtol=1e-03, atol=1e-03)
1111 np.testing.assert_allclose(um, um_np)
1112
1113 ot.bregman.unmix(ab, Db, M_nx, M0b, h0b, reg, 1, alpha=0.01, log=True, verbose=True)
1114
1115
1116def test_empirical_sinkhorn(nx):

Callers

nothing calls this directly

Calls 4

from_numpyMethod · 0.80
to_numpyMethod · 0.80
maxMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected