Skip to content

WIP: Add normalize parameter to sliced_wasserstein_distance#808

Open
Harguna wants to merge 1 commit intoPythonOT:masterfrom
Harguna:feature/normalize-sliced-wasserstein
Open

WIP: Add normalize parameter to sliced_wasserstein_distance#808
Harguna wants to merge 1 commit intoPythonOT:masterfrom
Harguna:feature/normalize-sliced-wasserstein

Conversation

@Harguna
Copy link
Copy Markdown

@Harguna Harguna commented Apr 29, 2026

Types of changes

  • New Feature

Motivation and context / Related issue

Addresses #807.

Sliced Wasserstein Distance is sensitive to feature scale: features with larger numerical ranges dominate the random projections, drowning out meaningful differences in smaller-scale features. Users often don't realize this is happening and, when they do, the manual fix (preprocessing inputs with a scaler) is verbose and easy to get wrong — fitting each distribution independently silently corrupts the distance.

This PR adds optional normalize and normalize_mode parameters to sliced_wasserstein_distance and max_sliced_wasserstein_distance to handle this cleanly inside the function. Default behavior (normalize=None) is unchanged, so the change is fully backward-compatible.

This is a [WIP] skeleton PR - it establishes the API surface, signatures, docstrings, and a helper function so the design can be reviewed before the full implementation lands. The actual normalization math, edge case handling, behavioral tests, and example script will follow in subsequent commits on this same branch.

How has this been tested (if it applies)

In this skeleton:

  • Existing test/test_sliced.py test suite continues to pass (verifies the new keyword parameters didn't break anything).
  • pre-commit run --all-files passes locally.

Tests related to the new feature will be added with the full implementation in the subsequent commits.

PR checklist

  • I have read the CONTRIBUTING document.
  • The documentation is up-to-date with the changes I made (check build artifacts).
  • 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.

@rflamary
Copy link
Copy Markdown
Collaborator

Thanks for this PR, we are a bit busy at te moement and will have more time to give some feedback after the neurips deadline in two weeks.

@Harguna
Copy link
Copy Markdown
Author

Harguna commented May 3, 2026

Sounds good, best of luck with the NeurIPS.

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