stochastic-rs

Copulas

Bivariate (Clayton, Frank, Gumbel, independence) and multivariate (Gaussian, tree, vine) copulas with the BivariateExt / MultivariateExt traits.

Copulas

The stochastic-rs-copulas crate ships bivariate and multivariate copulas plus correlation utilities and an empirical copula.

Bivariate (BivariateExt<T>)

Archimedean and elliptical:

CopulaFamilyTail dependence
ClaytonArchimedeanLower only
FrankArchimedeanNone (symmetric)
GumbelArchimedeanUpper only
IndependenceTrivialNone

The bivariate samplers are consolidated under BivariateExt; the v1.x NCopula2DExt was removed in v2.0.

Multivariate (MultivariateExt<T>)

CopulaFamilyNotes
GaussianEllipticalCholesky-based
TreeVine, simplifiedTree-structured Pair-copula
VineVine, fullR-vine / D-vine / C-vine

Multivariate copulas require the openblas feature for the Cholesky factorisation. See Feature flags.

Examples

Clayton — lower-tail dependence

θ>0\theta > 0 produces lower-tail dependence, useful for modelling joint crashes in equity returns.

use stochastic_rs::copulas::bivariate::clayton::Clayton;
use stochastic_rs::traits::BivariateExt;

let mut cop = Clayton::new();
cop.set_tau(0.5);                            // τ ⇒ θ via Kendall inversion
let _ = cop.compute_theta();
let uv = cop.sample_with_seed(10_000, 42)?;  // Array2<f64>, shape (10_000, 2)
let (u, v) = (uv.column(0), uv.column(1));   // both in [0, 1]

let tau_hat = stochastic_rs::stats::tail_index::kendall_tau(u, v);
println!("τ̂ = {:.3}", tau_hat);
import stochastic_rs as srs

cop = srs.Clayton(theta=2.0)
uv = cop.sample(10_000, seed=42)             # shape (10_000, 2)
u, v = uv[:, 0], uv[:, 1]
print("Kendall's tau ≈", srs.kendall_tau(u, v))   # ≈ 0.5

Gaussian copula — multivariate sampling

use stochastic_rs::copulas::multivariate::gaussian::GaussianMultivariate;
use stochastic_rs::traits::MultivariateExt;
use ndarray::array;

let corr = array![
    [1.0, 0.7, 0.3],
    [0.7, 1.0, 0.5],
    [0.3, 0.5, 1.0],
];
let cop = GaussianMultivariate::new_with_corr(corr)?;
let samples = cop.sample(10_000)?;           // Array2<f64>, shape (10_000, 3)

The multivariate Gaussian copula depends on ndarray-linalg (the openblas feature) for the Cholesky factorisation, so it is not wrapped for Python — use the Rust API directly.

Adding a copula

See the copula-bivariate SKILL — file-by-file recipe for Clayton / Frank / Gumbel / Joe / Plackett / FGM / extreme-value families.

On this page