Metadata-Version: 2.4
Name: levymmd
Version: 0.1.0
Summary: Expected signature kernels and maximum mean discrepancies for inhomogeneous Lévy processes
Author: Paul P. Hager
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/hagerpa/levymmd
Project-URL: Repository, https://github.com/hagerpa/levymmd
Project-URL: Issues, https://github.com/hagerpa/levymmd/issues
Project-URL: Paper, https://arxiv.org/abs/2509.07893
Keywords: levy,signature,kernel,mmd,stochastic-processes
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: chaospy>=4.3
Requires-Dist: jax>=0.7
Requires-Dist: tensordev>=0.0.3
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: matplotlib>=3.8; extra == "test"
Requires-Dist: notebook>=7; extra == "test"
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff>=0.5; extra == "dev"
Dynamic: license-file

# levymmd

Expected signature kernels and maximum mean discrepancies for inhomogeneous
Lévy processes.

Companion code for P. K. Friz and P. P. Hager, *Expected Signature Kernels for
Lévy Rough Paths*, [arXiv:2509.07893](https://arxiv.org/abs/2509.07893).

The expected signature of an inhomogeneous Lévy process is the development of
an absolutely continuous path in the extended tensor algebra, driven by the
characteristic velocities of the process. The kernel between two such laws
therefore solves a PDE system — a Goursat problem in the Gaussian martingale
case — and can be evaluated directly, without simulating either process. This
package implements that evaluation and the MMD statistics built on it.

## Installation

```bash
pip install -e .          # add [test] for the test dependencies
```

Tensor arithmetic comes from [`tensordev`](https://github.com/hagerpa/tensordev),
installed from PyPI.

## The package

**`levymmd.levy`** builds a process from its characteristic triplet.
`LevyProcess` composes a drift, a diffusion and a jump part — each available in
homogeneous, separable and general time dependence — and each part reports its
characteristic velocities as well as simulating. `MixtureProcess` and
`SwitchingProcess` compose whole processes. The worked examples of the paper,
such as `sin_cos_gaussian_martingale` and `covariance_loop_martingale`, are
constructors in `levymmd.levy.examples`.

**`levymmd.mmd`** turns laws and observed paths into kernels. Three families
cover the combinations of the two argument types:

|  | against a path sample | against a Lévy law |
|---|---|---|
| **path sample** | `path_path_kernel` | `path_levy_kernel` |
| **Lévy law** | — | `levy_levy_kernel` |

each with a `_gram` form for many pairs at once and an `_mmd` form for the
squared discrepancy. Paths enter as `Sample`, laws as `Law`, and
`inner_products` evaluates any requested blocks of the resulting Gram matrix in
a single pass, so several statistics on the same data cost one computation
rather than one each. `finite_grid_statistics` contracts those blocks into the
signature and quadratic-variation statistics the paper compares.

## Reproducing the paper

Each experiment is a notebook that runs top to bottom. Open it, run all cells,
and that part of the paper reappears.

| Notebook | Produces |
|---|---|
| `notebooks/gof/gof.ipynb` | Figure `fig:gof_power`, Table `tab:gof_size_variance` |
| `notebooks/validation/mc_validation.ipynb` | Figures `fig:numerics_gaussian_irregular`, `fig:numerics_gaussian_paths` |
| `notebooks/truncation/truncation_analysis.ipynb` | Figure `fig:trunc_circle` |

The Monte Carlo sample pools are not distributed, so a first run computes them
— hours for the goodness-of-fit study, less for the other two. They are then
kept locally and git-ignored, and each notebook reuses what it finds: an
interrupted study resumes where it stopped, and redrawing a figure never reruns
a simulation. Each experiment's `REPORT.md` records its results and how they
were obtained.

## Tests

```bash
pytest tests
```
