Skip to main content

PNOT: Python Nested Optimal Transport 🪆

This library implements very fast C++ and Python solver for the nested (adapted) optimal transport problem. In particular, it calculates the adapted Wasserstein distance quickly and accurately. We provide both C++ and Python implementations, and a wrapper to use the fast C++ solver from Python. It is very easy to use. Just feed two path samples into the solver—the rest (empirical measures, quantization, nested computation) happens automatically and swiftly.

Installation 📦

Preparation for macOS Users

Make sure you have Apple’s Xcode command-line tools installed:

$ xcode-select --install

Install LLVM and OpenMP support via Homebrew:

$ brew install llvm libomp

Installation

  • Stable release via PyPI:
    $ pip install pnot
    
  • Latest GitHub version:
    $ pip install git+https://github.com/justinhou95/NestedOT.git
    
  • Developer mode (clone and install editable):
    $ git clone https://github.com/justinhou95/NestedOT.git
    $ cd NestedOT
    $ pip install -e .
    

Notebooks

  • demo.ipynb — Quickstart and basic usage
  • solver_explain.ipynb — How conditional distributions are estimated and nested computations performed
  • example_of_use.ipynb — Approach similar to that described in Backhoff et al. 2021 for estimating adapted Wasserstein distance with continuous measures
  • convergence_gaussian.ipynb - Consistency experiments tested on Gaussian processes

Performance Comparison:

We compare PNOT’s C++ nested_ot solver against the only publicly available alternative—solve_dynamic from AOTNumerics (Eckstein & Pammer 2023). For both markovian and non-markovian solver, we obtain more than 3000× speed improvement and the gap widens with larger samples.

Timing vs. Sample Size for Full-History OT

Convergence Analysis:

We test the consistency of our solver as number of samples increases. By choosing the grid size $\Delta_N = N^{-\frac{1}{dT}}$, the adapted 2-Wasserstein distance between adapted empirical measures converge to the theoretical adapted 2-Wasserstein distance between underlying measures, namely $\mathcal{A}\mathcal{W}_2(\hat{\mu}^N, \hat{\nu}^N) \to \mathcal{A}\mathcal{W}_2(\mu, \nu)$. This numerically confirm Theorem 2.7 in [1].

Convergence

Reference

  • [1] Acciaio, B., & Hou, S. (2024). Convergence of adapted empirical measures on R d. The Annals of Applied Probability, 34(5), 4799-4835. (PDF)
  • [2] Eckstein, S., & Pammer, G. (2024). Computational methods for adapted optimal transport. The Annals of Applied Probability, 34(1A), 675-713. (PDF) — only other public solver (solve_dynamic)
  • [3] Backhoff, J., Bartl, D., Beiglböck, M., & Wiesel, J. (2022). Estimating processes in adapted Wasserstein distance. The Annals of Applied Probability, 32(1), 529-550. (PDF) — continuous-measure discretization strategy
  • Fast Transport (Network Simplex)
  • Python Optimal Transport (POT)
  • Entropic Adapted Wasserstein on Gaussians

Metadata

Release files for pnot 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pnot 1.0.0
File Size Uploaded Provenance Actions
pnot-1.0.0.tar.gz 1.2 MB Without provenance Details for pnot-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pnot 1.0.0
File Interpreter ABI Platform Actions
pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl CPython 3.9 CPython 3.9 macOS 10.14+ universal2 (ARM64, x86-64) Details for pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl

Total release size: 1.5 MB

Release files / pnot-1.0.0.tar.gz

Download URL pnot-1.0.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
7e4e2582b5ac10ee2fa56446ca28aac3cccc538da67de35f128c657e260142b4
BLAKE2b-256 checksum
How to use checksums
5d1451e8890fe09efdbe3438241a7b7f6d9729ea1d522b3224a274acef53880d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl

Download URL pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl
Size 230.6 kB
Tags CPython 3.9 macOS 10.14+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
bc2877fe90dcf592c3c2068e5c8597f6fdc021cf96438d4e22e657668291bfd4
BLAKE2b-256 checksum
How to use checksums
5e65f58729b1b15c93f2983c201116b90d27beb3e3927114283c069eecc3f189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Security for pnot 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page