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.3.tar.gz (100.3 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.3-cp310-abi3-win_amd64.whl (533.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

rscopulas-0.2.3-cp310-abi3-musllinux_1_2_x86_64.whl (834.7 kB view details)

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

rscopulas-0.2.3-cp310-abi3-musllinux_1_2_aarch64.whl (770.9 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

rscopulas-0.2.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (626.2 kB view details)

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

rscopulas-0.2.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (594.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

rscopulas-0.2.3-cp310-abi3-macosx_11_0_arm64.whl (571.9 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

rscopulas-0.2.3-cp310-abi3-macosx_10_12_x86_64.whl (592.5 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: rscopulas-0.2.3.tar.gz
  • Upload date:
  • Size: 100.3 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.3.tar.gz
Algorithm Hash digest
SHA256 2060855df64d7acd09bb1e4145dfb3da92ad6a8570215e991eb641dfeb800bc2
MD5 2b85e16a84a1b819b41d28cfefac2fbb
BLAKE2b-256 9849efa47d24c36607b21fae110b1f5a0f82ddb005c2c8d0780f5a7c9779f6bc

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rscopulas-0.2.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 533.1 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.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 81868dd67509f3b356499ed1bf4900e9ca005cb27a557a946d4f62dfd4d753b6
MD5 f562c8a5ee9c78d9e4c6254eab225a0f
BLAKE2b-256 db37d10af6c58ee79ebefc8d9e163ba71f2078aadfa97960d3a7b9ad50f9bb85

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rscopulas-0.2.3-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4b99781c5fc69f43281c50db4914d30744f98e6291d5e594fa34b622b96c3705
MD5 004e860b368198f3e1169691a602067f
BLAKE2b-256 f88e7644703fad4ed39a791f1a7451ef4e30a0508046110a7337d39c675a47e2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rscopulas-0.2.3-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 923a3da9b826a2c6afed9ba8af1012e9c6bcae77409e6036161c6feca199e5c6
MD5 a2eb4bc245d424ab2f6e0e1638fb93a0
BLAKE2b-256 633fa7c0922147c117134da4a7b53d27ac30fbc6a972aa6df977efe84465760f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rscopulas-0.2.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 488cb5bcf0f560be7b5caeebe920948483d3df8a60e8c9347b8619be0ce5a144
MD5 7ebe6f46138431137084264cc391f98a
BLAKE2b-256 626203f26739b968006009f1de5e9bb3a54359307abbea8b4e3dceadf296f8d5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rscopulas-0.2.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4f3e08a4f87a81b889c35e8e895cd5dbc93bc4ff67bee3cfc461e3210ab84a62
MD5 f895befbca5a418a610e41cb95a96ef8
BLAKE2b-256 6e7a6f6fe9374628f7c1d4784d2ddb8ecfab8560cf23f84b6cf55654b0470f0d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rscopulas-0.2.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 991803f92378f71bfee49dff9e70189fc4c65377e10e8d153377935206048343
MD5 92e904a5befbb40b5b144e6497f3d361
BLAKE2b-256 4c8fd2806401921f723d46904dfb7dc5ee85699526ca0889bf3d976b8d6fe416

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rscopulas-0.2.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 23879aa7fdba3a42132cc550d99b6c15c2535355785ed74990d3e3f13da6ffda
MD5 6df366f8344424066f8d7ca3da9c477d
BLAKE2b-256 a0e94a20741dd0f3ae8e8e5450beb97cd069e77385d5607e0909e3fbb6d36fbd

See more details on using hashes here.

Provenance

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