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.4.tar.gz (108.4 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.4-cp310-abi3-win_amd64.whl (541.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

rscopulas-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl (838.8 kB view details)

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

rscopulas-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl (773.8 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

rscopulas-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (630.9 kB view details)

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

rscopulas-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (597.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

rscopulas-0.2.4-cp310-abi3-macosx_11_0_arm64.whl (576.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

rscopulas-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl (595.5 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: rscopulas-0.2.4.tar.gz
  • Upload date:
  • Size: 108.4 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.4.tar.gz
Algorithm Hash digest
SHA256 c2b89b3938b79cf4f9d38c3c684d5b9b820057a37830135ea9f4160679e5f799
MD5 b998d678ba822503bc2e3876806fa1a9
BLAKE2b-256 cf5d52b32a50579fea269f52a22020854d7be9486b11cab48951af46e47017d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4.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.4-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rscopulas-0.2.4-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 541.6 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.4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e429edb32d51bf2a8d5dcbe611eb3f216abed14b3a871450f7fd10ab67d94080
MD5 2c052727cce5a972234052b1860c46a9
BLAKE2b-256 35f11afb0c5ea5014a7c073c869422da3fcb8952cc1e3511fae284a20ff93b61

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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.4-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.4-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e3e194564a0e74ba1c7f6a210ee593302eab662dc4e8e6925f04b17def61da27
MD5 d16aca4040369c68cab0d7ab45dae166
BLAKE2b-256 42204ac384fc6bd14e7afe563c9493887e0d2b0a2fb5a074b8065dee8cdf53ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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.4-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.4-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5b34c4139cf0bbe444a1dd1d6df29708a82ea3a0b51707813349471d0dd6d9cc
MD5 bce5b25ac79432216ca3fc4cb9398ec0
BLAKE2b-256 9adff416f667ed6c40953be1c1c883c174c329ca108cef4a7547c8fc30226a3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 973298c9b8af2f0f5d1ee1cb89ed45552642d015122799d074d3190430fc5147
MD5 56b130d60d55c474ab596ce4d4f7446c
BLAKE2b-256 6669aff04485ba45ae6b9bb875b0ff99042940e4cd09e5d943ca27a1f91a2ad6

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ee6f1f634e3684ecf3da163f75692105e1a70b5bbbde23d1cf8dcf5c7f96f000
MD5 4f58e67851ff8364d04e17695360c9b1
BLAKE2b-256 adf64e6fe93b37e5a19fc4a4098e3bc8eebe420bbda15b2e630a0bca4b59dddb

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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.4-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb047be72dffef07e48f427eb0b6bc087fcfbb662362f5c84487f2ed6f671f92
MD5 9b9de6909d787cd3839086f15a3f0f11
BLAKE2b-256 45c3fd3bd3d58f895efe01d507fe22c672b6e9451985e4b406dc974ff19940b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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.4-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rscopulas-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 53affbed32291c78a560a53f04df973471b641c833b5f7d1fd9736085877a4dd
MD5 20eed2b01a40ce44163b495e6798bd10
BLAKE2b-256 6bdbc6d253829f410cf6fde7a39dab6f795cec0a7e20f9f1e1175d6061a2d999

See more details on using hashes here.

Provenance

The following attestation bundles were made for rscopulas-0.2.4-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