diff options
author | Rémi Flamary <remi.flamary@gmail.com> | 2017-09-01 15:31:44 +0200 |
---|---|---|
committer | Rémi Flamary <remi.flamary@gmail.com> | 2017-09-01 15:31:44 +0200 |
commit | 062071b20d1d40c64bb619931bd11bd28e780485 (patch) | |
tree | 74bfcd48bb65304c2a5be74c24cdff29bd82ba4b /docs/source/auto_examples/plot_OT_2D_samples.rst | |
parent | 212f3889b1114026765cda0134e02766daa82af2 (diff) |
update example with rst titles
Diffstat (limited to 'docs/source/auto_examples/plot_OT_2D_samples.rst')
-rw-r--r-- | docs/source/auto_examples/plot_OT_2D_samples.rst | 132 |
1 files changed, 98 insertions, 34 deletions
diff --git a/docs/source/auto_examples/plot_OT_2D_samples.rst b/docs/source/auto_examples/plot_OT_2D_samples.rst index c472c6a..f95ffaf 100644 --- a/docs/source/auto_examples/plot_OT_2D_samples.rst +++ b/docs/source/auto_examples/plot_OT_2D_samples.rst @@ -7,58 +7,37 @@ 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. -.. rst-class:: sphx-glr-horizontal - - - * - - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_001.png - :scale: 47 - - * - - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_002.png - :scale: 47 +.. code-block:: python - * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_003.png - :scale: 47 + # Author: Remi Flamary <remi.flamary@unice.fr> + # + # License: MIT License - * + import numpy as np + import matplotlib.pylab as pl + import ot - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_004.png - :scale: 47 - * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_005.png - :scale: 47 - * - .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_006.png - :scale: 47 +Generate data +############################################################################# .. code-block:: python - # Author: Remi Flamary <remi.flamary@unice.fr> - # - # License: MIT License - - import numpy as np - import matplotlib.pylab as pl - import ot - #%% parameters and data generation n = 50 # nb samples @@ -78,6 +57,20 @@ M = ot.dist(xs, xt) M /= M.max() + + + + + + +Plot data +############################################################################# + + + +.. code-block:: python + + #%% plot samples pl.figure(1) @@ -91,6 +84,32 @@ pl.title('Cost matrix M') + + +.. rst-class:: sphx-glr-horizontal + + + * + + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_001.png + :scale: 47 + + * + + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_002.png + :scale: 47 + + + + +Compute EMD +############################################################################# + + + +.. code-block:: python + + #%% EMD G0 = ot.emd(a, b, M) @@ -107,6 +126,33 @@ pl.title('OT matrix with samples') + + + +.. rst-class:: sphx-glr-horizontal + + + * + + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_005.png + :scale: 47 + + * + + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_006.png + :scale: 47 + + + + +Compute Sinkhorn +############################################################################# + + + +.. code-block:: python + + #%% sinkhorn # reg term @@ -127,7 +173,25 @@ pl.show() -**Total running time of the script:** ( 0 minutes 2.908 seconds) + + +.. rst-class:: sphx-glr-horizontal + + + * + + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_009.png + :scale: 47 + + * + + .. image:: /auto_examples/images/sphx_glr_plot_OT_2D_samples_010.png + :scale: 47 + + + + +**Total running time of the script:** ( 0 minutes 1.990 seconds) @@ -146,4 +210,4 @@ .. rst-class:: sphx-glr-signature - `Generated by Sphinx-Gallery <http://sphinx-gallery.readthedocs.io>`_ + `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_ |