CopulAX is an open-source library for probability distribution fitting, written in JAX with an emphasis on speed and low-dimensional optimization. It is the spiritual successor to SklarPy and provides univariate, multivariate and copula distribution objects with JIT compilation and automatic differentiation support.
This library is designed for use cases ranging from machine learning to finance.
Table of contents
- Table of contents
- Documentation
- Installation
- Quick Start
- Saving and Loading
- Low-Dimensional Optimization
- Development Status
- Implemented Distributions
- Testing
- Examples
Documentation
- Read the Docs: https://copulax.readthedocs.io/en/latest/
- API reference: https://copulax.readthedocs.io/en/latest/api/index.html
Installation
CopulAX is available on PyPI and can be installed by running:
pip install copulax
A pinned uv.lock is also committed for reproducible development environments — clone the repo and run uv sync to install the exact dependency set used by maintainers.
Quick Start
import jax.random as jr
from copulax.univariate import normal, univariate_fitter
from copulax.multivariate import mvt_normal
from copulax.copulas import gaussian_copula
from copulax.preprocessing import DataScaler
key = jr.PRNGKey(0)
k1, k2, k3 = jr.split(key, 3)
# Univariate fitting
x_uni = jr.normal(k1, shape=(500,))
fitted_uni = normal.fit(x_uni)
best_idx, candidates = univariate_fitter(x_uni)
# Multivariate fitting
x_mvt = jr.normal(k2, shape=(500, 3))
fitted_mvt = mvt_normal.fit(x_mvt)
# Copula fitting
x_cop = jr.normal(k3, shape=(500, 3))
fitted_cop = gaussian_copula.fit(x_cop)
# Preprocessing — jittable z-score / min-max / robust / max-abs scaler
scaler, x_scaled = DataScaler("zscore").fit_transform(x_mvt)
x_original = scaler.inverse_transform(x_scaled)
Saving and Loading
Fitted distributions and fitted DataScaler preprocessors can be saved to disk and loaded back in a later session. All distribution types (univariate, multivariate, and copula) are supported, as are DataScaler instances. Files use the .cpx format and are cross-platform.
import copulax
# Save a fitted distribution
fitted_uni.save("my_model.cpx")
# Load it back (in the same or a different session)
loaded = copulax.load("my_model.cpx")
loaded.logpdf(x_uni) # identical to fitted_uni.logpdf(x_uni)
# DataScaler uses the same save/load entry points
scaler.save("my_scaler.cpx")
loaded_scaler = copulax.load("my_scaler.cpx")
Low-Dimensional Optimization
In many settings, sample sizes are limited. Probabilistic modeling can help generate additional data with similar statistical structure, but multivariate and copula models often require shape/covariance/correlation parameters that grow as O($d^2$). CopulAX reduces this burden where possible by using analytical relationships between these matrices and other parameters. Estimating location and shape robustly outside the optimization loop can materially reduce the number of numerically optimized parameters.
Development Status
CopulAX is under active development. Current coverage includes:
- Continuous univariate distributions.
- Multivariate normal-mixture families.
- Elliptical and Archimedean copulas.
- JIT/autodiff-compatible fitting workflows and utility functions.
Near-term roadmap:
- Additional univariate distributions (including discrete support).
- Additional multivariate and copula families.
- Broader CDF coverage for multivariate and elliptical copula objects.
- Empirical distribution support with multiple fitting methods.
Implemented Distributions
A list of all implemented distributions can be found here:
- Univariate implemented distributions
- Multivariate implemented distributions
- Copula implemented distributions
- Preprocessing utilities
Testing
Tests are comprehensive, but some suites can be slow. A practical workflow is:
- Run only affected tests first.
- Run individual test functions while iterating.
- Keep a timestamped test log while debugging.
# Default iteration: exclude slow tests (what CI runs)
pytest copulax/tests/ -v -m "not slow"
# Specific test file (e.g. multivariate copulas)
pytest copulax/tests/test_copulas_mv.py -v -m "not slow"
# Specific test function
pytest copulax/tests/test_copulas_mv.py::TestCopulaFitting::test_fit_returns_valid_params -v
# Append test output to a running log (PowerShell)
pytest copulax/tests/test_copulas_mv.py -v -m "not slow" *>&1 `
| Tee-Object -FilePath copula_test_results.txt -Append
Examples
We have provided jupyter notebooks containing example code for using univariate, multivariate and copula distribution objects.
Metadata
Release files for copulax 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| copulax-3.0.0.tar.gz | 251.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| copulax-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 432.1 kB
Release files / copulax-3.0.0.tar.gz
| Download URL | copulax-3.0.0.tar.gz |
|---|---|
| Size | 251.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bebddd7fb748ac92a33d7c33cacb832d3bd4198becea831ba2d685f5cb7f7e7b
|
|
BLAKE2b-256 checksum How to use checksums |
e8b91d0739f41eedc6d9f131eae596ef6ac73f08e60b4336ac65632c573961c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / copulax-3.0.0-py3-none-any.whl
| Download URL | copulax-3.0.0-py3-none-any.whl |
|---|---|
| Size | 180.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0684767c4980182f1d948243db43200f48038905186dcad50c50cf88dc5d5f5e
|
|
BLAKE2b-256 checksum How to use checksums |
6cb26714d51e84bfb938389dd2be4b0501d19470a359b1ea1a9462a1118ddf27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|