summaryrefslogtreecommitdiff
path: root/examples/plot_barycenter_1D.py
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2017-09-15 14:54:21 +0200
committerGitHub <noreply@github.com>2017-09-15 14:54:21 +0200
commit81b2796226f3abde29fc024752728444da77509a (patch)
treec52cec3c38552f9f8c15361758aa9a80c30c3ef3 /examples/plot_barycenter_1D.py
parente70d5420204db78691af2d0fbe04cc3d4416a8f4 (diff)
parent7fea2cd3e8ad29bf3fa442d7642bae124ee2bab0 (diff)
Merge pull request #27 from rflamary/autonb
auto notebooks + release update (fixes #16)
Diffstat (limited to 'examples/plot_barycenter_1D.py')
-rw-r--r--examples/plot_barycenter_1D.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/plot_barycenter_1D.py b/examples/plot_barycenter_1D.py
index 875f44c..620936b 100644
--- a/examples/plot_barycenter_1D.py
+++ b/examples/plot_barycenter_1D.py
@@ -4,6 +4,14 @@
1D Wasserstein barycenter demo
==============================
+This example illustrates the computation of regularized Wassersyein Barycenter
+as proposed in [3].
+
+
+[3] Benamou, J. D., Carlier, G., Cuturi, M., Nenna, L., & Peyré, G. (2015).
+Iterative Bregman projections for regularized transportation problems
+SIAM Journal on Scientific Computing, 37(2), A1111-A1138.
+
"""
# Author: Remi Flamary <remi.flamary@unice.fr>
@@ -17,6 +25,9 @@ import ot
from mpl_toolkits.mplot3d import Axes3D # noqa
from matplotlib.collections import PolyCollection
+##############################################################################
+# Generate data
+# -------------
#%% parameters
@@ -37,6 +48,10 @@ n_distributions = A.shape[1]
M = ot.utils.dist0(n)
M /= M.max()
+##############################################################################
+# Plot data
+# ---------
+
#%% plot the distributions
pl.figure(1, figsize=(6.4, 3))
@@ -45,6 +60,10 @@ for i in range(n_distributions):
pl.title('Distributions')
pl.tight_layout()
+##############################################################################
+# Barycenter computation
+# ----------------------
+
#%% barycenter computation
alpha = 0.2 # 0<=alpha<=1
@@ -71,6 +90,10 @@ pl.legend()
pl.title('Barycenters')
pl.tight_layout()
+##############################################################################
+# Barycentric interpolation
+# -------------------------
+
#%% barycenter interpolation
n_alpha = 11