couplingsmontecarlo
couplingsmontecarlo copied to clipboard
Python conversion of current R code
Hi @pierrejacob!
In line with #1, this PR collects a Python conversion of the current state of the R code. That was a lot of fun, I learned so many things about couplings and optimal transport! Thanks again for your great lecture notes and references therein.
-
The python code is stored in the
python
folder. Some methods/classes are documented, but not all... -
The output plots are located in the
python/plots
folder.
To reproduce the figures one can simply run
$ python <the_corresponding_file>.py
Feedback is welcome 😃
Btw, I've tried to implement generalized versions of some of the methods already available in the R code. For example, in couplings_core.py
:
-
maximal_coupling_reflexion_two_gaussians
, -
optimal_transport_two_gaussians
.
For the latter, I followed Remark 2.31 of Peyré & Cuturi to compute the (linear) optimal transport mapping.
In particular, I used the matrix square root instead of the Cholesky factor of the covariance matrices to ensure that the scaling matrix is indeed symmetric.
Note that in the current R implementation (cf 2normals.R
), the use of the Cholesky factors results in a lower triangular scaling matrix.
This may produce a non optimal transport map; further investigations might be required.
Cheers,
Guillaume