Optimal transport with factored couplings

Note

Example added in release: 0.8.2.

Illustration of the factored coupling OT between 2D empirical distributions

# Author: Remi Flamary <remi.flamary@polytechnique.edu>
#
# License: MIT License

# sphinx_gallery_thumbnail_number = 2

import numpy as np
import matplotlib.pylab as pl
import ot
import ot.plot

Generate data an plot it

# parameters and data generation

np.random.seed(42)

n = 100  # nb samples

xs = np.random.rand(n, 2) - 0.5

xs = xs + np.sign(xs)

xt = np.random.rand(n, 2) - 0.5

a, b = ot.unif(n), ot.unif(n)  # uniform distribution on samples
pl.figure(1)
pl.plot(xs[:, 0], xs[:, 1], "+b", label="Source samples")
pl.plot(xt[:, 0], xt[:, 1], "xr", label="Target samples")
pl.legend(loc=0)
pl.title("Source and target distributions")