diff options
Diffstat (limited to 'docs/source/auto_examples/plot_OT_2D_samples.py')
-rw-r--r-- | docs/source/auto_examples/plot_OT_2D_samples.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/source/auto_examples/plot_OT_2D_samples.py b/docs/source/auto_examples/plot_OT_2D_samples.py index 2a42dc0..f57d631 100644 --- a/docs/source/auto_examples/plot_OT_2D_samples.py +++ b/docs/source/auto_examples/plot_OT_2D_samples.py @@ -4,6 +4,9 @@ 2D Optimal transport between empirical distributions ==================================================== +Illustration of 2D optimal transport between discributions that are weighted +sum of diracs. The OT matrix is plotted with the samples. + """ # Author: Remi Flamary <remi.flamary@unice.fr> @@ -14,6 +17,10 @@ import numpy as np import matplotlib.pylab as pl import ot +############################################################################## +# Generate data +############################################################################## + #%% parameters and data generation n = 50 # nb samples @@ -33,6 +40,10 @@ a, b = np.ones((n,)) / n, np.ones((n,)) / n # uniform distribution on samples M = ot.dist(xs, xt) M /= M.max() +############################################################################## +# Plot data +############################################################################## + #%% plot samples pl.figure(1) @@ -45,6 +56,9 @@ pl.figure(2) pl.imshow(M, interpolation='nearest') pl.title('Cost matrix M') +############################################################################## +# Compute EMD +############################################################################## #%% EMD @@ -62,6 +76,10 @@ pl.legend(loc=0) pl.title('OT matrix with samples') +############################################################################## +# Compute Sinkhorn +############################################################################## + #%% sinkhorn # reg term |