Skip to main content

Python package for nested optimal transport

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pnot-1.0.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl (230.6 kB view details)

Uploaded CPython 3.9macOS 10.14+ universal2 (ARM64, x86-64)

File details

Details for the file pnot-1.0.0.tar.gz.

File metadata

  • Download URL: pnot-1.0.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pnot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7e4e2582b5ac10ee2fa56446ca28aac3cccc538da67de35f128c657e260142b4
MD5 d2eb8744c07b57f82c439630a964d91c
BLAKE2b-256 5d1451e8890fe09efdbe3438241a7b7f6d9729ea1d522b3224a274acef53880d

See more details on using hashes here.

File details

Details for the file pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl.

File metadata

  • Download URL: pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl
  • Upload date:
  • Size: 230.6 kB
  • Tags: CPython 3.9, macOS 10.14+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for pnot-1.0.0-cp39-cp39-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 bc2877fe90dcf592c3c2068e5c8597f6fdc021cf96438d4e22e657668291bfd4
MD5 ae95ef2fa6534575f61e5be1d0795ee3
BLAKE2b-256 5e65f58729b1b15c93f2983c201116b90d27beb3e3927114283c069eecc3f189

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page