Skip to main content

Copula, multivariate and univariate distribution fitting using JAX in python.

Project description

CopulAX logo

PyPI - Python Version   PyPI - Package Version   MIT license   build   build   coverage   maintained

mac os windows windows

CopulAX is an open-source library for probability distribution fitting, written in JAX with an emphasis on 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

Documentation

Installation

CopulAX is available on PyPI and can be installed by running:

pip install copulax

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

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)

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:

Testing

Tests are comprehensive, but some suites can be slow. A practical workflow is:

  1. Run only affected tests first.
  2. Run individual test functions while iterating.
  3. Keep a timestamped test log while debugging.
# Specific function
pytest copulax/tests/copulas/test_copulas.py::TestFitting::test_fit -v

# Affected file/family only
pytest copulax/tests/copulas/test_copulas.py -v
# Append test output to a running log (PowerShell)
pytest copulax/tests/copulas/test_copulas.py::TestFitting::test_fit -v *>&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.

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

copulax-2.0.0.tar.gz (572.9 kB view details)

Uploaded Source

Built Distribution

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

copulax-2.0.0-py3-none-any.whl (129.9 kB view details)

Uploaded Python 3

File details

Details for the file copulax-2.0.0.tar.gz.

File metadata

  • Download URL: copulax-2.0.0.tar.gz
  • Upload date:
  • Size: 572.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for copulax-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1cee19e161e195a63b322372d40e292ba7115fcdc888c21d7b20593f3047acfe
MD5 04662a94cc20cad63ae5f48c3fb4da3a
BLAKE2b-256 a6232f82ef014e0fa850aedd93b4d900ac9443ee02dc24b1caaed13d59dde512

See more details on using hashes here.

File details

Details for the file copulax-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: copulax-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 129.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for copulax-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 363caff53d04628c0202e97892a15aa67f45843aa25736311d69b6955482b867
MD5 386c9399a4d945610d9eefcfc7def2ec
BLAKE2b-256 39712874efb70e3e7924465136c35c1b7da7cee460788e1ce7f646ab98fccc8b

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