Skip to main content

Copula modeling for Python (NumPy) and Rust: vines, pair copulas, and reference-tested pseudo-observation workflows

Project description

rscopulas

rscopulas

rscopulas is a Python package for fitting, evaluating, and sampling copula models on validated pseudo-observations, backed by a Rust core built with PyO3 and maturin.

Install

With uv, in a uv project (recommended):

uv add rscopulas

Optional plotting helpers (viz extra):

uv add "rscopulas[viz]"

If you are not using a uv project, install the same packages as with pip:

uv pip install rscopulas
uv pip install "rscopulas[viz]"

Included models

  • Gaussian and Student t copulas
  • Archimedean families including Clayton, Frank, and Gumbel
  • Pair copulas, including Khoudraji constructions
  • C-vine, D-vine, and R-vine copulas
  • Hierarchical Archimedean copulas

Python example

import numpy as np
from rscopulas import GaussianCopula

data = np.array(
    [
        [0.12, 0.18],
        [0.21, 0.25],
        [0.82, 0.79],
    ],
    dtype=np.float64,
)

fit = GaussianCopula.fit(data)
print("AIC:", fit.diagnostics.aic)
print("sample:\n", fit.model.sample(4, seed=7))

Sampling example

from rscopulas import GumbelCopula

model = GumbelCopula.from_params(2, 2.1)
samples = model.sample(5, seed=11)

print("family:", model.family)
print("samples:\n", samples)
print("log_pdf:\n", model.log_pdf(samples))

Advanced example: fit an R-vine

import numpy as np
from rscopulas import VineCopula

data = np.array(
    [
        [0.10, 0.14, 0.18, 0.22],
        [0.18, 0.21, 0.24, 0.27],
        [0.24, 0.29, 0.33, 0.31],
        [0.33, 0.30, 0.38, 0.41],
        [0.47, 0.45, 0.43, 0.49],
        [0.52, 0.58, 0.55, 0.53],
        [0.69, 0.63, 0.67, 0.71],
        [0.81, 0.78, 0.74, 0.76],
    ],
    dtype=np.float64,
)

fit = VineCopula.fit_r(
    data,
    family_set=["independence", "gaussian", "clayton", "frank", "gumbel"],
    truncation_level=2,
    max_iter=200,
)

print("structure kind:", fit.model.structure_kind)
print("order:", fit.model.order)
print("first-tree families:", [edge.family for edge in fit.model.trees[0].edges])
print("sample:\n", fit.model.sample(4, seed=13))

Project links

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

rscopulas-0.2.2.tar.gz (95.6 kB view details)

Uploaded Source

Built Distributions

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

rscopulas-0.2.2-cp310-abi3-win_amd64.whl (531.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

rscopulas-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl (833.5 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

rscopulas-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl (770.7 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

rscopulas-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (624.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

rscopulas-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (594.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

rscopulas-0.2.2-cp310-abi3-macosx_11_0_arm64.whl (570.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

rscopulas-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl (590.7 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file rscopulas-0.2.2.tar.gz.

File metadata

  • Download URL: rscopulas-0.2.2.tar.gz
  • Upload date:
  • Size: 95.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rscopulas-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8cbbc1d43cf771c80aa494ab0c282874455142e7d6d676aa3245e74b1793f6ca
MD5 65252444429e4aba4b31df6865c547bc
BLAKE2b-256 8580d7dea0a98c1ceb00c0aa06b9cbb784f752ed8f9f9fb900f1636e37201d40

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2.tar.gz:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rscopulas-0.2.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 531.5 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f5a2f92b798579cb86631d654e1509dd7bfa2ecbb9a44b80927c8b224f1e39a9
MD5 1050960e3cfab89bf44958f6df75a7ed
BLAKE2b-256 b573aaa7ca47ab1ffabfeca4cdfb9221b009bfa59285e2875eb1b632160158c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-win_amd64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e34af8cd3a5df8bbe677093dab351b5d272be63213f9e70f7df50f5c8c41a681
MD5 f8618272b2a3ccfa0afdbe464ecbb86c
BLAKE2b-256 f847839b212dde338575a03f2c893d1eb95264f939c1e6882b7467538065259d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d7e5446dba2f081519588c17db702acf4e5694c2d934f6e88cc6fde13b98b472
MD5 650d26cc85865cfba9f11571363b8f59
BLAKE2b-256 2228cca8de10ff7cde8d592889eeffad323ee99b905cac31b92179f3e3ff9881

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c22163dce5d662473f400e4443889cb19caca958b8bbd2e140bc7c505ad05725
MD5 77d81a52746498213258f546546b9f15
BLAKE2b-256 135809715d1905b00606685dda303a117eba2f1902e3d2577ab672c1369038fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4858607f938a657baabf9fc86b8d731641201301381433381737fb1bab91381a
MD5 2a4a6e83c59e5b5c16a1761a38eb49f9
BLAKE2b-256 8c08ded532caf70b83cc9aa89bd414b64e17be15f0dd9b2869a2f00a47aba513

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 533820ccfd0878c4943826ffaca201d308706fed1f9b7d35a92858c3fe412bfc
MD5 95327bd7fd87a3d6bd5e3a4ed481dd3a
BLAKE2b-256 bee92fcafcaa51538f32b0412de74a345d0fcf54db86c957bf1ee765f28bc96d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rscopulas-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6c3a881c81781a3b05cb2232b222ca50e5324fec653c8babfc40ff8d097a47c2
MD5 fcd1a961ffc8685c564caadbe0b430e4
BLAKE2b-256 b28fded2910b320b275afefd014ff27901053e9968616e579cb9eab6388cf1ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.2-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on alexwox/rscopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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