couplingsmontecarlo icon indicating copy to clipboard operation
couplingsmontecarlo copied to clipboard

Python conversion of current R code

Open guilgautier opened this issue 4 years ago • 0 comments

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.

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

guilgautier avatar Apr 01 '20 17:04 guilgautier