Skip to content

[WIP] HD Gaussian empirical bures#814

Open
marcogenni wants to merge 21 commits into
PythonOT:masterfrom
marcogenni:my-feature
Open

[WIP] HD Gaussian empirical bures#814
marcogenni wants to merge 21 commits into
PythonOT:masterfrom
marcogenni:my-feature

Conversation

@marcogenni

@marcogenni marcogenni commented May 20, 2026

Copy link
Copy Markdown

Types of changes

Add of the function ot.gaussian.empirical_bures_wasserstein_hd to compute the OT map between HD Gaussian distributions. A new function ot.datasets.make_gauss_hd was created to simulate form two HD Gaussian distributions and a test was implemented (test_bures_wasserstein_mapping_hd) in module test_gaussian.py

Motivation and context / Related issue

The changes are aimed to introduce in POT the OT map and Wasserstein distance estimators in the HD Gaussian case, as described Bouveyron and Corneli, Scaling optimal transport to high-dimensional gaussian distributions, Statistics and Computing, 2026

How has this been tested (if it applies)

PR checklist

  • [ x] I have read the CONTRIBUTING document.
  • [ x] The documentation is up-to-date with the changes I made (check build artifacts).
  • [ x] All tests passed, and additional code has been covered with new tests.
  • I have added the PR and Issue fix to the RELEASES.md file.

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.67442% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.82%. Comparing base (3e10dd6) to head (59ae74f).

Additional details and impacted files
@@           Coverage Diff            @@
##           master     #814    +/-   ##
========================================
  Coverage   96.81%   96.82%            
========================================
  Files         124      124            
  Lines       24276    24532   +256     
========================================
+ Hits        23503    23753   +250     
- Misses        773      779     +6     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rflamary rflamary changed the title HD Gaussian empirical bures [WIP] HD Gaussian empirical bures Jun 2, 2026

@rflamary rflamary left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @marcogenni ,

Below are a few comment about API (using only one parameter for intrisic dim, debug documentation, run tests on data from all backend). Fee free to ask questions on slack if unclear.

Comment thread ot/gaussian.py

\Sigma_s^{1/2} &=\sigma_s I_p + U_s C_s U_s^T \\

C_s &=\diag(\sqrt{l_{s1} + \sigma_s^2} - \sigma_s, \dots, \sqrt{l_{sd_s} + \sigma_s^2} - \sigma_s) \\

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ALL \diag by \text{diag} in al functions to avaoid this:
Image

Comment thread ot/gaussian.py
samples in the source domain
xt : array-like (nt,p)
samples in the target domain
ds : array-like (1,)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use integer here, array is weird API

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can pass a d interger or that can be alist/array to have different d fro source target.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d_intrisic is also a better name because d in not very clear

Comment thread ot/gaussian.py
the residual variance of the source distribution
sigma_t^2 : array-like (1,)
the residual variance of the target distribution
ds : array-like (1,)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread ot/gaussian.py
samples in the source domain
xt : array-like (nt,p)
samples in the target domain
ds : array-like (1,)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment thread ot/gaussian.py

"""

xs, xt, ds, dt = list_to_array(xs, xt, ds, dt)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
xs, xt, ds, dt = list_to_array(xs, xt, ds, dt)

remove list_to_array, it's there for old compatibility but no used fro new function. do that for all unctions please

Comment thread test/test_gaussian.py
nt = 100

Xs, Xt, ll = make_gauss_hd(ns, nt, p=50, dim=10, m_diff=5, a=(7, 7), b=(1, 1))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Xs, Xt = nx.from_numpy(Xs, Xt)

run the functins for aery from all existing backends (probably need to convert also all the arrays below)

Comment thread test/test_gaussian.py

@pytest.mark.parametrize("bias", [True, False])
def test_empirical_bures_wasserstein_distance_hd(nx, bias):
ns = 100000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use less data test must be very fast

Comment thread test/test_gaussian.py

@pytest.mark.parametrize("bias", [True, False])
def test_empirical_bures_wasserstein_mapping_hd(nx, bias):
ns = 100000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use less data here to speedup tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants