summaryrefslogtreecommitdiff
path: root/docs/source/auto_examples/plot_OT_2D_samples.py
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2017-09-01 15:31:44 +0200
committerRémi Flamary <remi.flamary@gmail.com>2017-09-01 15:31:44 +0200
commit062071b20d1d40c64bb619931bd11bd28e780485 (patch)
tree74bfcd48bb65304c2a5be74c24cdff29bd82ba4b /docs/source/auto_examples/plot_OT_2D_samples.py
parent212f3889b1114026765cda0134e02766daa82af2 (diff)
update example with rst titles
Diffstat (limited to 'docs/source/auto_examples/plot_OT_2D_samples.py')
-rw-r--r--docs/source/auto_examples/plot_OT_2D_samples.py18
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