Copula Distributions
Copula distributions: elliptical and Archimedean families.
Copula Base
The universal abstract base class shared by every copula family (Mean-Variance, Archimedean).
CopulAX shared copula base class.
Houses CopulaBase, the universal abstract base for every
copula family in copulax (Archimedean, mean-variance, future
extensions). It carries the Sklar / marginal-fitting / sampling
machinery common to all copulas.
Mean-variance copulas (Gaussian, Student-T, GH, Skewed-T) live in
_mv_copulas.py; Archimedean copulas live in _archimedean.py.
- class copulax._src.copulas._distributions.CopulaBase(name)[source]
Base class for all copula distributions.
Provides Sklar’s theorem implementations for the joint distribution, common marginal-fitting logic, and sampling via inverse-transform of copula samples.
- Parameters:
name (str)
- abstractmethod copula_logpdf(u, params=None, **kwargs)[source]
Log-density of the copula (subclasses must implement).
- abstractmethod copula_rvs(size, params, key=None)[source]
Generate random samples from the copula (subclasses must implement).
- logpdf(x, params=None, **kwargs)[source]
Joint log-PDF via Sklar’s theorem.
log f(x) = log c(F_1(x_1),…,F_d(x_d)) + sum log f_i(x_i)
- rvs(size, params=None, key=None, brent=False, nodes=100)[source]
Sample from the joint distribution.
Sample u from copula
Transform u to x via marginal PPFs
- Parameters:
size (
Union[float,int,Array,ndarray,bool,number,bool,complex]) – Number of samples.params (
dict) – Distribution parameters.key (
Array) – JAX random key.brent (
bool) – Forwarded to the marginalUnivariate.ppf().False(default) uses the analytical inverse CDF when available and otherwise the Chebyshev cubic spline;Trueforces per-quantile Brent root-finding (slower but machine-epsilon accurate).nodes (
int) – Number of Chebyshev-Lobatto nodes when the cubic path is used. Ignored for analytical marginals and whenbrent=True.
- Return type:
- Returns:
Array of shape (size, d).
- fit_marginals(x, univariate_fitter_options=None)[source]
Fit univariate marginal distributions to each dimension.
- Parameters:
- Return type:
Note
Not jitable.
- fit(x, univariate_fitter_options=None, name=None, **kwargs)[source]
Fit marginals and copula to the data.
Equivalent to calling fit_marginals then fit_copula.
- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – Input data of shape (n, d).univariate_fitter_options (
tuple[dict] |dict) – Options for marginal fitting.name (
str) – Optional custom name for the fitted instance.**kwargs – Additional arguments forwarded to
fit_copula(method,lr,maxiter,tol,patience).
- Return type:
Note
Not jitable.
Mean-Variance Copulas
Copulas derived from normal mixture distributions (McNeil, Frey,
Embrechts 2005, §3.2). MeanVarianceCopulaBase is the umbrella;
EllipticalCopula covers normal variance mixtures
(Gaussian, Student-T; γ=0, strictly elliptical); MeanVarianceCopula
covers normal mean-variance mixtures (GH, Skewed-T; γ≠0).
CopulAX implementation of mean-variance (normal-mixture) copulas.
Houses the umbrella MeanVarianceCopulaBase plus its two
taxonomic sub-bases — EllipticalCopula (γ=0; pure normal
variance mixtures: Gaussian, Student-T) and
MeanVarianceCopula (γ≠0; normal mean-variance mixtures:
GH, Skewed-T) — and all four concrete copula classes.
The shared CopulaBase (Sklar / marginal fitting / sampling
machinery used by every copula family, including Archimedean) lives
in _distributions.py and is imported here.
- Reference:
McNeil, Frey, Embrechts (2005) Quantitative Risk Management, §3.2.1 (variance mixtures), §3.2.2 (mean-variance mixtures), §3.2.4 Algorithm 3.14 (EM / ECME for GH).
- class copulax._src.copulas._mv_copulas.MeanVarianceCopulaBase(name, mvt, uvt, *, marginals=None, copula=None)[source]
Umbrella base class for normal-mixture copula distributions.
Holds the shared
fit_copuladispatcher,_METHOD_KWARGSvalidation, correlation estimation, and other machinery common to both normal variance mixture copulas (true elliptical, γ=0; seeEllipticalCopula) and normal mean-variance mixture copulas (with skewness γ; seeMeanVarianceCopula).- Reference:
McNeil, Frey, Embrechts (2005) Quantitative Risk Management, §3.2.1 (variance mixtures) and §3.2.2 (mean-variance mixtures).
- Parameters:
mvt (Multivariate)
uvt (Univariate)
- example_params(dim=3, *args, **kwargs)[source]
Example parameters for the copula distribution.
Generates example marginal and copula parameters for the overall joint distribution.
- Parameters:
dim (
int) – int, number of dimensions of the copula distribution. Default is 3.
- get_x_dash(u, params, brent=False, nodes=100)[source]
Computes x’ values, which represent the mappings of the independent marginal cdf values (U) to the domain of the joint multivariate distribution.
Routes through
Univariate.ppf(), so distributions with an analytical inverse CDF (Normal, Gamma, LogNormal, IG, Uniform, Gen-Normal) use the closed-form path automatically and ignorenodes.Note
If you intend to jit wrap this function, both
brentandnodesmust be static arguments.- Parameters:
u (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – The independent univariate marginal cdf values (U) for each dimension, shape(n, d).params (
dict) – The copula and marginal distribution parameters.brent (
bool) – IfFalse(default), use the analytical inverse CDF when available and otherwise the Chebyshev-node cubic spline approximation. IfTrue, force per-quantile Brent root-finding (machine-epsilon accurate, slower).nodes (
int) – Number of Chebyshev-Lobatto nodes used by the cubic spline path. Ignored for analytical marginals and whenbrent=True.
- Return type:
- Returns:
x'values of shape(n, d).
- copula_logpdf(u, params=None, brent=False, nodes=100)[source]
Computes the log-pdf of the copula distribution.
Note
If you intend to jit wrap this function, both
brentandnodesmust be static arguments.- Parameters:
u (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – The independent univariate marginal cdf values (u) for each dimension.params (
dict) – The copula and marginal distribution parameters.brent (
bool) – Forwarded toget_x_dash().False(default) uses the analytical inverse CDF when available and otherwise the Chebyshev cubic spline;Trueforces per-quantile Brent root-finding.nodes (
int) – Number of Chebyshev-Lobatto nodes used by the cubic spline path. Ignored for analytical marginals and whenbrent=True.
- Returns:
- The log-pdf values of the copula
distribution.
- Return type:
- copula_rvs(size, params=None, key=None)[source]
Generates random samples from the copula distribution.
Note
If you intend to jit wrap this function, ensure that ‘size’ is a static argument.
- Parameters:
size (
Union[float,int,Array,ndarray,bool,number,bool,complex]) – size (Scalar): The size / shape of the generated output array of random numbers. Must be scalar. Generates an (size, d) array of random numbers, where d is the number of dimensions inferred from the provided distribution parameters.params (
dict) – The copula and marginal distribution parameters.key (
Array) – The Key for random number generation.
- Return type:
- fit_copula(u, corr_method='rm_pp_kendall', method='fc_mle', **kwargs)[source]
Fit copula parameters from pseudo-observations.
Two-stage estimation following McNeil, Frey & Embrechts (2005), Section 5.5:
Stage 1 — Estimate the copula correlation matrix P from the pseudo-observations u using rank correlation. The default
rm_pp_kendallcomputes Kendall’s tau, applies the inversion \(\hat\rho_{ij} = \sin(\tfrac{\pi}{2}\,\hat\tau_{ij})\) (Proposition 5.37), and ensures positive semi-definiteness via eigenvalue clamping.Stage 2 — Estimate remaining parameters (e.g. ν, γ) by maximising the copula log-likelihood, with P either held fixed at the Stage 1 estimate or jointly re-optimised, depending on
method.- Parameters:
u (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – Pseudo-observations of shape(n, d)in[0, 1].corr_method (
str) – Correlation estimation method for Stage 1. Default'rm_pp_kendall'. Seecopulax.multivariate.corrfor all methods.method (
str) – Fitting algorithm for Stage 2. One of:'fc_mle'— Fixed-Correlation MLE: shape parameters optimised via projected gradient with Σ held at the Stage 1 Kendall-τ estimate. Available for every concrete subclass.'mle'— Full joint MLE: all parameters (shape + Σ off-diagonals) optimised together via Adam, with Σ tanh-parameterised onto the correlation manifold. Mean-variance subclasses (GH, SkewedT) only.'ecme'— Inner EM updates (P, γ); outer gradient descent on the copula log-likelihood for the remaining shape parameters (McNeil §3.2.4 ECME variant). Mean-variance subclasses only.'ecme_double_gamma'— Likeecmebut γ is additionally re-optimised in the outer numerical M-step (so γ is updated twice per outer iteration). Mean-variance subclasses only.'ecme_outer_gamma'— Inner EM updates Σ only (γ frozen); outer MLE on all shape parameters including γ. Mean-variance subclasses only.**kwargs – Method-specific keyword arguments. Each
methodaccepts only its own set of kwargs; Common kwargs:lr(float, all methods),maxiter(int, all),brent(bool, all exceptfc_mle),nodes(int, all exceptfc_mle).
- Return type:
- Returns:
dict with key
'copula'containing fitted parameters.- Raises:
ValueError – If
methodis not accepted by this subclass, or ifkwargscontains a key not accepted by the chosen method.
- class copulax._src.copulas._mv_copulas.EllipticalCopula(name, mvt, uvt, *, marginals=None, copula=None)[source]
True elliptical copulas (normal variance mixtures, γ=0).
Concrete subclasses (
GaussianCopula,StudentTCopula) only support the'fc_mle'Stage 2 fitting method.- Reference:
McNeil, Frey, Embrechts (2005) Quantitative Risk Management, §3.2.1 Normal Variance Mixtures.
- Parameters:
mvt (Multivariate)
uvt (Univariate)
- class copulax._src.copulas._mv_copulas.MeanVarianceCopula(name, mvt, uvt, *, marginals=None, copula=None)[source]
Normal mean-variance mixture copulas with skewness γ.
Concrete subclasses (
GHCopula,SkewedTCopula) additionally implement γ-aware fitting methods (mle,ecme,ecme_double_gamma,ecme_outer_gamma) on top offc_mle.Note
MeanVarianceCopulaBaseis the broader umbrella covering this class andEllipticalCopula(the γ=0 special case). This class is the proper γ≠0 specialisation.- Reference:
McNeil, Frey, Embrechts (2005) Quantitative Risk Management, §3.2.2 Normal Mean-Variance Mixtures, §3.2.4 Algorithm 3.14.
- Parameters:
mvt (Multivariate)
uvt (Univariate)
- class copulax._src.copulas._mv_copulas.GaussianCopula(name, mvt, uvt, *, marginals=None, copula=None)[source]
The Gaussian Copula is a copula that uses the multivariate normal distribution to model the dependencies between random variables.
The copula is parameterised by the correlation matrix P only. Fitting estimates P from pseudo-observations via rank correlation (McNeil et al. 2005, Example 5.58).
https://en.wikipedia.org/wiki/Copula_(statistics)
- Parameters:
mvt (Multivariate)
uvt (Univariate)
- class copulax._src.copulas._mv_copulas.StudentTCopula(name, mvt, uvt, *, marginals=None, copula=None)[source]
The Student-T Copula is a copula that uses the multivariate Student-T distribution to model the dependencies between random variables.
The copula is parameterised by degrees of freedom ν and correlation matrix P. Fitting estimates P via Kendall’s tau inversion and ν by maximising the copula log-likelihood (McNeil et al. 2005, Examples 5.54 and 5.59).
https://en.wikipedia.org/wiki/Copula_(statistics)
- Parameters:
mvt (Multivariate)
uvt (Univariate)
- class copulax._src.copulas._mv_copulas.GHCopula(name, mvt, uvt, *, marginals=None, copula=None)[source]
The GH Copula is a copula that uses the multivariate generalized hyperbolic (GH) distribution to model the dependencies between random variables.
The copula is parameterised by (λ, χ, ψ, γ) and correlation matrix P. Fitting estimates P via Kendall’s tau inversion and the remaining parameters via ML or EM (McNeil et al. 2005, Section 5.5).
https://en.wikipedia.org/wiki/Copula_(statistics)
- Parameters:
mvt (Multivariate)
uvt (Univariate)
- class copulax._src.copulas._mv_copulas.SkewedTCopula(name, mvt, uvt, *, marginals=None, copula=None)[source]
The Skewed-T Copula is a copula that uses the multivariate skewed-T distribution to model the dependencies between random variables.
The copula is parameterised by degrees of freedom ν, skewness vector γ, and correlation matrix P. Fitting estimates P via Kendall’s tau inversion and (ν, γ) via ML or EM (McNeil et al. 2005, Section 5.5).
https://en.wikipedia.org/wiki/Copula_(statistics)
- Parameters:
mvt (Multivariate)
uvt (Univariate)
Archimedean Copulas
Copulas defined by a generator function φ and its inverse ψ.
CopulAX implementation of Archimedean copula distributions.
An Archimedean copula is defined by a generator function φ: [0,1] → [0,∞) with φ(1) = 0, and its pseudo-inverse ψ = φ⁻¹:
C(u₁,…,u_d) = ψ(φ(u₁) + … + φ(u_d))
References
- Nelsen, R. B. (2006). An Introduction to Copulas, 2nd ed.
Springer Series in Statistics.
- McNeil, A. J., Frey, R., & Embrechts, P. (2005).
Quantitative Risk Management. Princeton University Press.
- McNeil, A. J. & Nešlehová, J. (2009). Multivariate Archimedean
copulas, d-monotone functions and l₁-norm symmetric distributions. Annals of Statistics, 37(5B), 3059-3097.
- Hofert, M. (2011). Efficiently Sampling Nested Archimedean
Copulas. Computational Statistics & Data Analysis, 55(1), 57-70.
- class copulax._src.copulas._archimedean.ArchimedeanCopula(name, *, marginals=None, copula=None)[source]
Base class for Archimedean copula distributions.
An Archimedean copula is defined by a generator function φ: [0,1] → [0,∞) with φ(1) = 0, and its pseudo-inverse ψ = φ⁻¹:
C(u₁,…,u_d) = ψ(φ(u₁) + … + φ(u_d))
The copula density is:
\[c(u) = \bigl|\psi^{(d)}\bigl(\textstyle\sum_i \phi(u_i)\bigr)\bigr| \cdot \prod_i \bigl|\phi'(u_i)\bigr|\]where \(\psi^{(d)}\) is the d-th derivative of the inverse generator.
References
- Nelsen, R. B. (2006). An Introduction to Copulas, 2nd ed.
Springer Series in Statistics.
- McNeil, A. J. & Nešlehová, J. (2009). Multivariate Archimedean
copulas, d-monotone functions and l₁-norm symmetric distributions. Annals of Statistics, 37(5B), 3059-3097.
- generator(t, theta)[source]
Generator function φ(t; θ).
Must satisfy φ(1) = 0, φ is strictly decreasing and convex.
- generator_inv(s, theta)[source]
Inverse generator ψ(s; θ) = φ⁻¹(s; θ).
Also known as the Laplace-Stieltjes transform.
- example_params(dim=3, *args, **kwargs)[source]
Example parameters for the Archimedean copula distribution.
- copula_logpdf(u, params=None, **kwargs)[source]
Copula log-density via generator derivatives.
- Uses the formula:
log c(u) = log|ψ⁽ᵈ⁾(∑ φ(uᵢ))| + ∑ log|φ’(uᵢ)|
where ψ⁽ᵈ⁾ is computed via d nested applications of jax.grad.
- copula_rvs(size, params=None, key=None)[source]
Sample from the copula using the Marshall-Olkin algorithm.
- Algorithm (Marshall & Olkin, 1988):
Sample V ~ frailty distribution F_θ
Sample E₁,…,E_d iid ~ Exp(1)
Uᵢ = ψ(Eᵢ / V)
- Parameters:
- Return type:
- Returns:
Array of shape (size, d) with values in (0, 1).
- fit_copula(u, method='kendall', **kwargs)[source]
Fit the copula parameter θ.
- Parameters:
- Returns:
fitted_theta}.
- Return type:
- Raises:
ValueError – If
methodis not'kendall', or ifkwargscontains any keys (the Kendall method takes no tuning parameters).
- class copulax._src.copulas._archimedean.ClaytonCopula(name, *, marginals=None, copula=None)[source]
Clayton copula with generator φ(t) = t^{-θ} - 1.
- Parameters:
∈ (θ)
- Properties:
Lower tail dependence: λ_L = 2^{-1/θ}
Upper tail dependence: λ_U = 0
Kendall’s tau: τ = θ/(θ+2)
References
- Clayton, D. G. (1978). A model for association in bivariate
life tables and its application in epidemiological studies of familial tendency in chronic disease incidence. Biometrika, 65(1), 141-151.
Nelsen (2006), Example 4.2.
- generator(t, theta)[source]
Generator function φ(t; θ).
Must satisfy φ(1) = 0, φ is strictly decreasing and convex.
- class copulax._src.copulas._archimedean.FrankCopula(name, *, marginals=None, copula=None)[source]
Frank copula with generator φ(t) = -ln((e^{-θt}-1)/(e^{-θ}-1)).
- Parameters:
{0} (θ ∈ ℝ)
- Properties:
No tail dependence: λ_L = λ_U = 0
Allows negative dependence (θ < 0)
Kendall’s tau: τ = 1 - 4/θ · (1 - D₁(θ)) where D₁ is the first Debye function
References
- Frank, M. J. (1979). On the simultaneous associativity of
F(x,y) and x + y - F(x,y). Aequationes Mathematicae, 19, 194-226.
Nelsen (2006), Example 4.5.
- class copulax._src.copulas._archimedean.GumbelCopula(name, *, marginals=None, copula=None)[source]
Gumbel copula with generator φ(t) = (-ln t)^θ.
- Parameters:
[1 (θ ∈)
∞)
- Properties:
No lower tail dependence: λ_L = 0
Upper tail dependence: λ_U = 2 - 2^{1/θ}
Kendall’s tau: τ = 1 - 1/θ
θ = 1 gives the independence copula
References
- Gumbel, E. J. (1960). Distributions des valeurs extrêmes en
plusieurs dimensions. Publications de l’Institut de Statistique de l’Université de Paris, 9, 171-173.
Nelsen (2006), Example 4.4.
- class copulax._src.copulas._archimedean.JoeCopula(name, *, marginals=None, copula=None)[source]
Joe copula with generator φ(t) = -ln(1 - (1-t)^θ).
- Parameters:
[1 (θ ∈)
∞)
- Properties:
No lower tail dependence: λ_L = 0
Upper tail dependence: λ_U = 2 - 2^{1/θ}
Kendall’s tau: τ = 1 - 4·∑_{k=1}^∞ 1/(k(kθ+2)((k-2)θ+2))
References
- Joe, H. (1993). Parametric families of multivariate
distributions with given margins. Journal of Multivariate Analysis, 46(2), 262-282.
Nelsen (2006), Example 4.10.
- class copulax._src.copulas._archimedean.AMHCopula(name, *, marginals=None, copula=None)[source]
Ali-Mikhail-Haq copula with generator φ(t) = ln((1-θ(1-t))/t).
- Parameters:
[-1 (θ ∈)
1)
- Properties:
Only valid for dimension d ≤ 2
Weak dependence: τ ∈ [-0.1817, 1/3)
No tail dependence: λ_L = λ_U = 0
Note
The AMH generator is only completely monotone (hence valid for all dimensions) when θ ∈ [0, 1). For θ ∈ [-1, 0), the copula is only valid for d = 2 (2-monotone but not completely monotone). The Marshall-Olkin sampling uses a Geometric frailty distribution which requires θ ∈ [0, 1). For θ < 0, frailty V is set to 1, providing approximate sampling.
References
- Ali, M. M., Mikhail, N. N., & Haq, M. S. (1978). A class
of bivariate distributions including the bivariate logistic. Journal of Multivariate Analysis, 8(3), 405-412.
Nelsen (2006), Example 4.8.
- generator(t, theta)[source]
Generator function φ(t; θ).
Must satisfy φ(1) = 0, φ is strictly decreasing and convex.
- generator_inv(s, theta)[source]
Inverse generator ψ(s; θ) = φ⁻¹(s; θ).
Also known as the Laplace-Stieltjes transform.
- example_params(dim=2, *args, **kwargs)[source]
Example parameters for AMH copula (d=2 only).
- Parameters:
dim (
int) – Must be 2 for AMH copula.- Raises:
ValueError – If dim != 2.
- Return type:
- class copulax._src.copulas._archimedean.IndependenceCopula(name, *, marginals=None, copula=None)[source]
Independence copula (product copula) C(u₁,…,u_d) = ∏ uᵢ.
The independence copula corresponds to the Archimedean generator φ(t) = −ln(t) with inverse ψ(s) = e^{−s}. It has no free parameters and represents the case of stochastically independent margins.
- Properties:
No tail dependence: λ_L = λ_U = 0
Kendall’s tau: τ = 0
Copula density: c(u) = 1 for all u ∈ (0,1)^d
No parameters to fit
Valid for any dimension d ≥ 2
The independence copula is useful as a null / benchmark model for comparing against parametric copula fits.
References
- Nelsen, R. B. (2006). An Introduction to Copulas, 2nd ed.
Springer Series in Statistics, Section 2.5.
- generator(t, theta)[source]
Generator function φ(t; θ).
Must satisfy φ(1) = 0, φ is strictly decreasing and convex.
- generator_inv(s, theta)[source]
Inverse generator ψ(s; θ) = φ⁻¹(s; θ).
Also known as the Laplace-Stieltjes transform.
- copula_cdf(u, params=None, **kwargs)[source]
Independence copula CDF: C(u₁,…,u_d) = ∏ uᵢ.
- Parameters:
u – Uniform marginal values of shape (n, d).
params – Ignored (no copula parameters).
- Returns:
Array of shape (n, 1).
- copula_logpdf(u, params=None, **kwargs)[source]
Independence copula log-density: log c(u) = 0.
- Parameters:
u – Uniform marginal values of shape (n, d).
params – Ignored (no copula parameters).
- Returns:
Array of zeros with shape (n, 1).
- copula_rvs(size, params=None, key=None)[source]
Sample independent uniform margins.
- Parameters:
size – Number of samples to generate.
params – Must contain ‘marginals’ (for dimension inference).
key – JAX random key.
- Returns:
Array of shape (size, d) with iid Uniform(0,1) entries.
- fit_copula(u, method='kendall', **kwargs)[source]
No parameters to fit for the independence copula.
Validates
method(only'kendall'is accepted) and rejects any kwargs for parity with the rest of the family, then returns an empty copula-params dict.- Returns:
dict with key ‘copula’ → {} (empty).
- Parameters:
method (str)