copul.family.other package

Submodules

copul.family.other.asymmetric_xi_rho_si_copula module

class copul.family.other.asymmetric_xi_rho_si_copula.AsymmetricSICopulaWithXiEqualsRho(*args, **kwargs)[source]

Bases: BivCopula

Singular “band” copula defined implicitly by

\[h_v(t) := \partial_1 C(t,v) \;=\; \mathbf{1}_{\{\,t < v/2\,\}} \;+\; v\,\mathbf{1}_{(\,v/2,\,(v+1)/2\,)}(t),\]

and explicitly by

\[\begin{split}C(u,v) \;=\; \begin{cases} u, & 0 \le u \le v/2,\\[0.6ex] \dfrac{v}{2} + v\!\left(u - \dfrac{v}{2}\right) \;=\; v\,u + \dfrac{v(1-v)}{2}, & v/2 < u \le (v+1)/2,\\[1.0ex] v, & (v+1)/2 < u \le 1. \end{cases}\end{split}\]

This copula is valid (non-symmetric) with an absolutely continuous part of density \(1\) on the strip \(\{(u,v): 2u-1 < v < 2u\}\) and a singular part supported on the boundary line segments \(v=2u\) for \(u\in[0,\tfrac12]\) and \(v=2u-1\) for \(u\in[\tfrac12,1]\).

Basic functionals

  • Chatterjee’s \(\xi(C)=\tfrac12\).

  • Spearman’s footrule \(\psi(C)=\tfrac12\).

Notes

  • This class is parameter-free.

  • The returned PDF corresponds to the absolutely continuous part only.

cdf_vectorized(u, v)[source]

Fast numpy implementation of the piecewise CDF.

chatterjees_xi()[source]

Chatterjee’s rank correlation \(\xi(C)=\tfrac12\).

intervals: dict = {}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = []
spearmans_footrule()[source]

Spearman’s footrule \(\psi(C)=\tfrac12\).

u = u
v = v

copul.family.other.b11 module

class copul.family.other.b11.B11(*args, **kwargs)[source]

Bases: BivCopula

B11 Copula - a special case of the Fréchet copula family.

This is a convex combination of the upper Fréchet bound (min function) and the independence copula: C(u,v) = delta * min(u,v) + (1-delta) * u*v

Parameters:

deltafloat, 0 ≤ delta ≤ 1

Mixing parameter that determines the weight of the upper Fréchet bound. delta = 0 gives the independence copula. delta = 1 gives the upper Fréchet bound.

property cdf

Cumulative distribution function of the copula.

C(u,v) = delta * min(u,v) + (1-delta) * u*v

delta = delta
intervals: dict = {'delta': Interval(0, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau(*args, **kwargs)[source]

Calculate Kendall’s tau for the B11 copula.

For B11, tau = delta/3 * (3 - 2*delta)

property lambda_L

Lower tail dependence coefficient.

For B11, lambda_L = delta if delta = 1, otherwise 0

property lambda_U

Upper tail dependence coefficient.

For B11, lambda_U = delta if delta = 1, otherwise 0

params: list = [delta]
spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the B11 copula.

For B11, rho = delta

copul.family.other.clamped_parabola_copula module

copul.family.other.clamped_parabola_copula.ClampedParabolaCopula

alias of XiNuBoundaryCopula

class copul.family.other.clamped_parabola_copula.XiNuBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Clamped–parabola copula parameterized by \(b=1/\mu>0\):

\[h_v(t) \;=\; \mathrm{clamp}\!\left(b\big((1-t)^2 - q(v)\big),\,0,\,1\right),\]

where \(q(v)\) is uniquely determined by the marginal constraint \(\int_0^1 h_v(t)\,dt=v\).

b = b
blests_nu()[source]

Signed Blest’s ν(b). Under the σ₂ reflection (b<0) the dependence reverses, so ν must satisfy ν(-b) = -ν(b). We therefore return sign(b) * ν(|b|), where ν(|b|) is the closed form in terms of μ = 1/|b|.

property cdf

Evaluate (or partially evaluate) the CDF.

Supports:
  • C(u1,…,ud) via separate scalars or a 1D array

  • partial substitution via kwargs (u1=…, u2=…, u=…, v=…)

  • returns a callable wrapper if variables remain, otherwise a scalar

cdf_vectorized(u, v)[source]

If b >= 0: C(u,v) = C_base(u,v; |b|). If b < 0 : C(u,v) = u - C_base(u, 1-v; |b|) (σ2 reflection).

chatterjees_xi()[source]

Compute Chatterjee’s xi correlation measure.

This method sets the parameters, computes intermediate integrals, and returns the simplified expression for xi.

Returns:

A wrapper around the symbolic expression for Chatterjee’s xi.

Return type:

SymPyFuncWrapper

cond_distr_1()[source]

h(u,v) = ∂_u C(u,v). If b >= 0: h = clamp(|b|((1-u)^2 - q(v)),0,1). If b < 0 : h = 1 - clamp(|b|((1-u)^2 - q(1-v)),0,1). (since C^σ2) NOTE: q(·) will be evaluated with |b| in the lambdify bridge.

dim: int
classmethod from_xi(x_target)[source]

Solve for b from target ξ. Since ξ(μ) is strictly decreasing in μ, we solve for μ and return b=1/μ.

intervals: dict = {'b': Interval.open(0, oo)}
property is_absolutely_continuous: bool

XiNuBoundaryCopula has a density everywhere on (0,1)^2.

params: list = [b]
pdf_vectorized(u, v)[source]

If b >= 0: c(u,v) = c_base(u,v; |b|). If b < 0 : c(u,v) = c_base(u, 1-v; |b|) (chain rule for σ2).

plot_cdf(*, plot_type='3d', log_z=False, **kwargs)[source]

Plot the CDF using the numerical cdf_vectorized() implementation.

plot_cond_distr_1(*, plot_type='3d', log_z=False, **kwargs)[source]

Plot h(u,v) = ∂_u C(u,v). Uses the symbolic expression and injects q(v) so the base lambdify has a valid mapping.

plot_cond_distr_2(*, plot_type='3d', log_z=False, **kwargs)[source]

Not available: q(v) is implicit and prevents a closed form.

plot_pdf(*, plot_type='3d', log_z=False, **kwargs)[source]

Plot the PDF using the numerical pdf_vectorized() implementation.

special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>, oo: <class 'copul.family.frechet.upper_frechet.UpperFrechet'>}
u = u
v = v

copul.family.other.diagonal_band_copula module

class copul.family.other.diagonal_band_copula.DiagonalBandCopula(*args, **kwargs)[source]

Bases: BivCopula

Bojarski-type diagonal band copula (uniform band along \(y=x\)).

A stripe of half-width \(\alpha\) is laid along the main diagonal and wrapped/reflected at the unit square’s borders so that both marginals remain uniform.

Following Bojarski (2002, J. Math. Sci., Eq. (1)) with a constant base density

\[f(z) \;=\; \frac{1}{2\alpha}\,\mathbf{1}\{|z|\le \alpha\}, \quad z\in\mathbb{R},\]

supported on \([-\alpha,\alpha]\). Using a different symmetric base density (e.g., rescaled Beta) is a straightforward extension, but the uniform band already reproduces the classical diagonal-band example discussed in the paper.

Parameters:

alpha (float in (0, 1]) – Half-width of the diagonal band.

alpha = alpha
cond_distr_2(u=None, v=None)[source]

\(F_{U_{-2}\mid U_2}(u_{-2}\mid u_2)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

dim: int
intervals: dict = {'alpha': Interval.Lopen(0, 1)}
property is_absolutely_continuous

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = [alpha]
property pdf

Piecewise density \(g_\alpha(u,v)\) of the diagonal-band construction.

With the base density \(f(z)=\tfrac{1}{2\alpha}\mathbf{1}\{|z|\le \alpha\}\), the copula density is

\[\begin{split}g_\alpha(u,v) \;=\; \begin{cases} f(u-v) + f(u+v), & u+v \le \alpha,\\[0.5ex] f(u-v), & \alpha < u+v < 2-\alpha,\\[0.5ex] f(u-v) + f(u+v-2), & u+v \ge 2-\alpha, \end{cases}\end{split}\]

which enforces uniform margins by wrapping the diagonal band near the corners.

copul.family.other.diagonal_strip_copula module

copul.family.other.diagonal_strip_copula.DiagonalStripCopula

alias of XiPsiApproxLowerBoundaryCopula

class copul.family.other.diagonal_strip_copula.NumericWrapper(func)[source]

Bases: object

A simple wrapper for numeric functions to make them compatible with the plotting utilities that expect a callable object.

class copul.family.other.diagonal_strip_copula.XiPsiApproxLowerBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Two-parameter “diagonal strip” copula with a rectangular hole.

The copula is defined by a transformation variable T and a hole geometry H. C(u,v) = (u*t - Area(Intersection)) / (1 - beta) where t = F_T^{-1}(v).

Parameters:
  • alpha (float) – Controls the horizontal start of the diagonal slope. alpha in [0, 0.5).

  • beta (float) – Controls the vertical thickness of the hole. beta in (0, 1).

alpha = alpha
beta = beta
cdf(u=None, v=None)[source]

Cumulative distribution function C(u,v).

cdf_vectorized(u, v)[source]

Exact numeric Copula CDF.

cond_distr_1(u=None, v=None)[source]

P(V <= v | U = u) = dC/du.

cond_distr_2(u=None, v=None)[source]

P(U <= u | V = v) = dC/dv.

dim: int
intervals: dict = {'alpha': Interval.Lopen(0, 1/2), 'beta': Interval.open(0, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = [alpha, beta]
pdf(u=None, v=None)[source]

Probability Density Function c(u,v).

pdf_vectorized(u, v)[source]

Exact numeric Copula PDF.

special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>}
u = u
v = v

copul.family.other.end_swap_copula module

class copul.family.other.end_swap_copula.EndSwapCopula(*args, **kwargs)[source]

Bases: BivCopula

End–swap copula family tracing the lower boundary of the \((\psi,\nu)\) region (Spearman’s footrule \(\psi\) vs Blest’s \(\nu\)).

Construction:
  • Let \(d \in [0,1/2]\). Define the measure-preserving “end swap” \(S_d\) that mirrors the end blocks and keeps the middle fixed: [

    S_d(t) = begin{cases}

    1 - t, & t in [0,d]cup[1-d,1],\ t, & t in (d, 1-d).

    end{cases}

    ]

  • The extreme-point conditional is \(h(u,v)=\mathbb{1}\{S_d(u)\le v\}\), and the copula is \(C_d(u,v) = \int_0^u h(t,v)\,dt\).

Correct section sets for fixed \(v\):
[

h(u,v)=1 iff begin{cases}

u le v, & u in (d,,1-d),\ u ge 1-v, & u in [0,d]cup[1-d,1].

end{cases}

] Hence [ C_d(u,v) = lambdabig((d,min{u,,min(v,1-d)}] big) + lambdabig([ max(0,1-v), min(u,d)]big) + lambdabig([max(1-d,1-v), min(u,1)]big). ]

Closed-form boundary (lower curve): .. math:

\psi(d) \;=\; 1 - 6(d - d^2),\qquad
\nu(d) \;=\; 1 - 12d + 24d^2 - 16d^3,\qquad d\in[0,1/2].

Inversion (from a given footrule \(\psi\in[-1/2,1]\)): .. math:

d \;=\; \frac{1 - \sqrt{(1+2\psi)/3}}{2} \in [0,1/2].
Special cases:
  • \(d=0\): \(C_d = M\) (upper Fréchet), \((\psi,\nu)=(1,1)\).

  • \(d=1/2\): \(C_d = W\) (lower Fréchet), \((\psi,\nu)=(-1/2,-1)\).

blests_nu()[source]

Blest’s ν: ν(d) = 1 - 12 d + 24 d^2 - 16 d^3.

property cdf

Symbolic CDF based on exact lengths of the three contributing blocks: C(u,v) = L_left + L_mid + L_right where

L_left = max(0, min(u, d) - max(0, 1 - v)), L_mid = max(0, min(u, m) - d) with m := min(v, 1 - d), L_right = max(0, min(u, 1) - max(1 - d, 1 - v)).

cdf_vectorized(u, v)[source]

Vectorized C(u,v) using the length formulas. Shapes of u and v are broadcast.

cond_distr_1(u=None, v=None)[source]

Conditional cdf in u: h(u,v) = ∂₁C(u,v) = 1{S_d(u) ≤ v}.

Implemented directly from the definition:
  • If u ∈ (d, 1-d): h(u,v) = 1{u ≤ v}.

  • If u ∈ [0,d] ∪ [1-d,1]: h(u,v) = 1{u ≥ 1 - v}.

d = d
classmethod from_psi(psi_target: float)[source]

Construct the boundary copula at a given footrule ψ ∈ [-1/2, 1].

Inversion: d = (1 - sqrt((1 + 2 ψ)/3))/2, clamped to [0, 1/2].

intervals: dict = {'d': Interval(0, 1/2)}
params: list = [d]
property pdf

Evaluate (or partially evaluate) the PDF: ∂^d C / ∂u1 … ∂ud

pdf_vectorized(u, v)[source]

Vectorized “density” c(u,v) = ∂²C/∂u∂v via finite difference in v. (The family has singular components; this is for plotting/numerics.)

spearmans_footrule()[source]

Spearman’s footrule: ψ(d) = 1 - 6(d - d^2) on [-1/2, 1].

special_cases = {0: <class 'copul.family.frechet.upper_frechet.UpperFrechet'>, 1/2: <class 'copul.family.frechet.lower_frechet.LowerFrechet'>}
u = u
v = v

copul.family.other.farlie_gumbel_morgenstern module

class copul.family.other.farlie_gumbel_morgenstern.FarlieGumbelMorgenstern(*args, **kwargs)[source]

Bases: BivCopula

Farlie-Gumbel-Morgenstern (FGM) Copula.

The FGM copula is defined as: C(u,v) = u*v + theta*u*v*(1-u)*(1-v)

It has limited dependence range with Spearman’s rho in [-1/3, 1/3] and Kendall’s tau in [-2/9, 2/9].

Parameters:

thetafloat, -1 ≤ theta ≤ 1

Dependence parameter that determines the strength and direction of dependence. theta = 0 gives the independence copula. theta > 0 indicates positive dependence. theta < 0 indicates negative dependence.

blests_nu()[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

property cdf

Cumulative distribution function of the copula.

C(u,v) = u*v + theta*u*v*(1-u)*(1-v)

cond_distr_2(u=None, v=None)[source]

Conditional distribution function with respect to v.

C_{2}(u,v) = u + theta*u*(1-u)*(1-2*v)

dim: int
ginis_gamma()[source]

Calculate Gini’s gamma for the FGM copula.

For FGM, Gini’s gamma = 4*theta/15

hoeffdings_d(*args, **kwargs)[source]

Hoeffding’s \(D\) for the FGM copula.

\[D = 90\,\theta^2 \left[\int_0^1 t^2(1-t)^2\,dt\right]^2 = \frac{\theta^2}{10}\]
intervals: dict = {'theta': Interval(-1, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau(*args, **kwargs)[source]

Calculate Kendall’s tau for the FGM copula.

For FGM, tau = 2*theta/9

lp_concordance(p: int = 2, *args, **kwargs)[source]

\(L_p\) concordance distance for the FGM copula.

\[\delta_p = k(p)\,|\theta|^p \left[\operatorname{B}(p+1,\,p+1)\right]^2\]

where \(\operatorname{B}\) is the beta function.

mutual_information(*args, **kwargs)[source]

Mutual information for the FGM copula (numerical).

The density is \(c(u,v) = 1 + \theta(1-2u)(1-2v)\). No known simple closed form for \(\int c \ln c\); delegates to the base-class numerical quadrature.

params: list = [theta]
property pdf

Probability density function of the copula.

c(u,v) = 1 + theta*(1-2*u)*(1-2*v)

schweizer_wolff_sigma(*args, **kwargs)[source]

Schweizer–Wolff \(\sigma\) for the FGM copula.

Since \(C - \Pi = \theta\,u\,v\,(1-u)(1-v)\) has constant sign (PQD when \(\theta>0\), NQD when \(\theta<0\)):

\[\sigma = 12\,|\theta|\, \left[\int_0^1 t(1-t)\,dt\right]^2 = \frac{|\theta|}{3}\]
spearmans_footrule()[source]
spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the FGM copula.

For FGM, rho = theta/3

theta = theta

copul.family.other.independence_copula module

class copul.family.other.independence_copula.IndependenceCopula(dimension=2, **kwargs)[source]

Bases: Copula, CopulaPlottingMixin

Multivariate Independence Copula implementation.

The independence copula represents statistical independence between random variables: C(u₁, u₂, …, uₙ) = u₁ × u₂ × … × uₙ

This is also a special case of an Archimedean copula with generator φ(t) = -log(t).

Parameters:

dimension (int, optional) – Dimension of the copula (number of variables). Default is 2.

blests_nu(*args, **kwargs)[source]
blomqvists_beta(*args, **kwargs)[source]
property cdf

Compute the cumulative distribution function (CDF) of the independence copula.

For the independence copula, the CDF is the product of all marginals: C(u₁, u₂, …, uₙ) = u₁ × u₂ × … × uₙ

Returns:

A wrapper around the CDF function.

Return type:

CDFWrapper

cdf_vectorized(*args)[source]

Vectorized implementation of the CDF for the independence copula.

Parameters:

*args (array_like) – Arrays of dimension values to evaluate the CDF at.

Returns:

Array of CDF values.

Return type:

numpy.ndarray

cond_distr(i, u=None)[source]

Compute the conditional distribution of the i-th variable.

For the independence copula, the conditional distribution is just the original variable.

Parameters:
  • i (int) – Index of the variable (1-based).

  • u (array_like, optional) – Values at which to evaluate the conditional distribution.

Returns:

The conditional distribution function or its value at u.

Return type:

SymPyFuncWrapper or float

gini_gamma(*args, **kwargs)[source]
hoeffdings_d(*args, **kwargs)[source]
intervals = {}
property is_absolutely_continuous: bool

Check if the copula is absolutely continuous.

The independence copula is absolutely continuous.

Returns:

True

Return type:

bool

property is_symmetric: bool

Check if the copula is symmetric.

The independence copula is symmetric in all its arguments.

Returns:

True

Return type:

bool

kendalls_tau()[source]

Compute Kendall’s tau for the independence copula.

For the independence copula, Kendall’s tau is 0 as there is no dependence.

Returns:

0

Return type:

float

lambda_L()[source]

Compute the lower tail dependence coefficient.

For the independence copula, there is no tail dependence.

Returns:

0

Return type:

float

lambda_U()[source]

Compute the upper tail dependence coefficient.

For the independence copula, there is no tail dependence.

Returns:

0

Return type:

float

lp_concordance(p: int = 2, *args, **kwargs)[source]
mutual_information(*args, **kwargs)[source]
params = []
property pdf

Compute the probability density function (PDF) of the independence copula.

For the independence copula, the PDF is constant 1 on the unit cube.

Returns:

A wrapper around the PDF function.

Return type:

SymPyFuncWrapper

pdf_vectorized(*args)[source]

Vectorized implementation of the PDF for the independence copula.

Parameters:

*args (array_like) – Arrays of dimension values to evaluate the PDF at.

Returns:

Array of PDF values (all 1s).

Return type:

numpy.ndarray

rvs(n=1, random_state=None)[source]

Generate random variates from the independence copula.

For the independence copula, this simply generates independent uniform random variables.

Parameters:
  • n (int, optional) – Number of samples to generate (default is 1).

  • random_state (int or None, optional) – Seed for the random number generator.

Returns:

Array of shape (n, dim) containing independent uniform samples.

Return type:

numpy.ndarray

schweizer_wolff_sigma(*args, **kwargs)[source]
spearman_footrule(*args, **kwargs)[source]
spearmans_rho()[source]

Compute Spearman’s rho for the independence copula.

For the independence copula, Spearman’s rho is 0 as there is no dependence.

Returns:

0

Return type:

float

copul.family.other.median_swap_copula module

class copul.family.other.median_swap_copula.MedianSwapCopula(*args, **kwargs)[source]

Bases: BivCopula

Chevron / median–swap copula family tracing the upper boundary of the \((\beta,\nu)\) region (Blomqvist’s \(\beta\) vs Blest’s \(\nu\)).

Construction:
  • Let \(\delta \in [0,1/2]\). Define the measure-preserving “median swap” \(T_\delta\) that swaps two adjacent blocks of length \(\delta\) around \(t=1/2\).

  • The extreme-point conditional is \(h(u,v)=\mathbb{1}\{T_\delta(u)\le v\}\), and the copula is \(C_\delta(u,v) = \int_0^u h(t,v)\,dt\).

Correct (piecewise) sections in \(u\) for fixed \(v\):

Let \(\tfrac12-\delta<\tfrac12<\tfrac12+\delta\). Define \(A(v)=\{\,t\in[0,1]:T_\delta(t)\le v\,\}\). Then

  • If \(0\le v\le\tfrac12-\delta\): \(A(v)=[0,v]\).

  • If \(\tfrac12-\delta< v\le\tfrac12\): \(A(v)=[0,\tfrac12-\delta]\cup(\tfrac12,\,v+\delta]\).

  • If \(\tfrac12< v\le\tfrac12+\delta\): \(A(v)=[0,\,v-\delta]\cup(\tfrac12,\,\tfrac12+\delta]\).

  • If \(\tfrac12+\delta< v\le 1\): \(A(v)=[0,v]\).

Hence \(C_\delta(u,v)=\lambda(A(v)\cap[0,u])\), which yields a valid copula with uniform margins.

Closed-form boundary (upper curve): .. math:

\beta(\delta) \;=\; 1-4\delta,\qquad
\nu(\delta) \;=\; 1-6\delta^2-8\delta^4,\qquad \delta\in[0,1/2].
Special cases:
  • \(\delta=0\): \(C_\delta = M\) (upper Fréchet), \((\beta,\nu)=(1,1)\).

  • \(\delta=1/2\): \(C_\delta = W\) (lower Fréchet), \((\beta,\nu)=(-1,-1)\).

blests_nu()[source]

Blest’s ν: ν(δ) = 1 - 6 δ^2 - 8 δ^4.

blomqvists_beta()[source]

Blomqvist’s beta: β(δ) = 1 - 4 δ.

property cdf

Correct symbolic CDF from the definition \(C(u,v)=\int_0^u \mathbf 1\{T_\delta(t)\le v\}\,dt\), expressed piecewise in \(v\).

cdf_vectorized(u, v)[source]

Correct vectorized C(u,v) using the piecewise cases. Shapes of u and v are broadcast.

cond_distr_1(u=None, v=None)[source]

Correct \(h(u,v)=\partial_1 C(u,v)=\mathbf 1\{T_\delta(u)\le v\}\). Implemented piecewise in \(v\) using Heaviside indicators.

cond_distr_2(u=None, v=None)[source]

Conditional cdf in v: ∂₂ C(u,v) = F_{U|V=v}(u) for a.e. v.

From the correct piecewise form of C(u,v):

  • Case A: v ≤ 1/2 − δ, C(u,v) = min(u, v)

    ⇒ ∂₂ C(u,v) = 1{u > v} (a.e.)

  • Case B: 1/2 − δ < v ≤ 1/2, C(u,v) is piecewise and depends on v only when u > v + δ

    ⇒ ∂₂ C(u,v) = 1{u > v + δ}

  • Case C: 1/2 < v ≤ 1/2 + δ, C(u,v) is piecewise and depends on v when u > v − δ

    ⇒ ∂₂ C(u,v) = 1{u > v − δ}

  • Case D: v ≥ 1/2 + δ, C(u,v) = min(u, v)

    ⇒ ∂₂ C(u,v) = 1{u > v}

We implement these as Heavisides with H(0)=0 (choice on a null set).

delta = delta
classmethod from_beta(beta_target: float)[source]

Construct the boundary copula at a given Blomqvist’s β ∈ [-1, 1].

Inversion: δ = (1 - β)/4, clamped to [0, 1/2].

intervals: dict = {'delta': Interval(0, 1/2)}
params: list = [delta]
property pdf

Evaluate (or partially evaluate) the PDF: ∂^d C / ∂u1 … ∂ud

pdf_vectorized(u, v)[source]

Vectorized “density” c(u,v) = ∂^2 C/∂u∂v computed via finite difference in v. (The family has singular components; this is for plotting/numerics.)

special_cases = {0: <class 'copul.family.frechet.upper_frechet.UpperFrechet'>, 1/2: <class 'copul.family.frechet.lower_frechet.LowerFrechet'>}
u = u
v = v

copul.family.other.pi_over_sigma_minus_pi module

class copul.family.other.pi_over_sigma_minus_pi.PiOverSigmaMinusPi(*args, **kwargs)[source]

Bases: BivArchimedeanCopula

Implementation of the Pi/(Sigma-Pi) copula.

This copula corresponds to the fixed parameter value theta=1 for the Clayton copula, but is implemented independently from the Clayton class.

Properties: - Generator: (1/t - 1) - Inverse Generator: 1/(1+y) - CDF: C(u,v) = uv/(u+v-uv) - Upper tail dependence coefficient: 0 - Lower tail dependence coefficient: 0.5

property cdf

Cumulative distribution function of the copula C(u,v) = uv/(u+v-uv)

cond_distr_1(u=None, v=None)[source]

First conditional distribution: ∂C(u,v)/∂u

cond_distr_2(u=None, v=None)[source]

Second conditional distribution: ∂C(u,v)/∂v

property is_absolutely_continuous: bool

This copula is absolutely continuous.

kendalls_tau(*args, **kwargs)[source]

Kendall’s tau for this copula is 1/3

lambda_L()[source]

Lower tail dependence coefficient: λ_L = 0.5

lambda_U()[source]

Upper tail dependence coefficient: λ_U = 0

property pdf

Probability density function of the copula c(u,v) = 2(u+v-uv) / (u+v-uv)³

theta = 1

copul.family.other.plackett module

class copul.family.other.plackett.Plackett(*args, **kwargs)[source]

Bases: BivCopula

blests_nu()[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

blomqvist(*args, **kwargs)[source]

Nelsen Exercise 5.18

property cdf

Evaluate (or partially evaluate) the CDF.

Supports:
  • C(u1,…,ud) via separate scalars or a 1D array

  • partial substitution via kwargs (u1=…, u2=…, u=…, v=…)

  • returns a callable wrapper if variables remain, otherwise a scalar

cond_distr_1(u=None, v=None)[source]

\(F_{U_{-1}\mid U_1}(u_{-1}\mid u_1)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

dim: int
get_density_of_density()[source]
get_numerator_double_density()[source]
intervals: dict = {'theta': Interval(0, oo)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = [theta]
property pdf

Evaluate (or partially evaluate) the PDF: ∂^d C / ∂u1 … ∂ud

spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the Plackett copula.

For the Plackett copula, the formula is: rho = (theta + 1) / (theta - 1) - 4 * theta * log(theta) / (theta - 1)^2

Special case: when theta = 1, rho = 0 (independence)

theta = theta

copul.family.other.raftery module

class copul.family.other.raftery.Raftery(*args, **kwargs)[source]

Bases: BivCopula

Raftery Copula.

This copula has a parameter delta controlling the dependence structure. Special cases: - delta = 0: Independence copula - delta = 1: Upper Fréchet bound (perfect positive dependence)

Parameters:

deltafloat, 0 ≤ delta ≤ 1

Dependence parameter

property cdf

Cumulative distribution function of the copula.

The formula has special cases for delta=0 and delta=1 to avoid division by zero.

cdf_vectorized(u, v)[source]

Vectorized implementation of the cumulative distribution function for Raftery copula.

This method evaluates the CDF at multiple points simultaneously, which is more efficient than calling the scalar CDF function repeatedly.

Parameters:
  • u (array_like) – First uniform marginal, should be in [0, 1].

  • v (array_like) – Second uniform marginal, should be in [0, 1].

Returns:

The CDF values at the specified points.

Return type:

numpy.ndarray

Notes

The Raftery copula CDF is: C(u,v) = min(u, v) + (1 - delta) / (1 + delta) * (u * v)^(1/(1-delta)) * (1 - max(u, v)^(-(1+delta)/(1-delta)))

Special cases: - When delta = 0, it’s the Independence copula (u * v) - When delta = 1, it’s the Upper Fréchet bound (min(u, v))

delta = delta
dim: int
intervals: dict = {'delta': Interval(0, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau(*args, **kwargs)[source]

Calculate Kendall’s tau for the Raftery copula.

For Raftery, tau = 2*delta / (3 - delta)

property lambda_L

Lower tail dependence coefficient.

For Raftery, lambda_L = 2*delta / (1 + delta)

property lambda_U

Upper tail dependence coefficient.

For Raftery, lambda_U = 0

params: list = [delta]
property pdf

Probability density function of the copula.

Calculated using the _b function.

spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the Raftery copula.

For Raftery, rho = delta * (4 - 3*delta) / (2 - delta)^2

copul.family.other.v_threshold_copula module

class copul.family.other.v_threshold_copula.VThresholdCopula(*args, **kwargs)[source]

Bases: BivCopula

V–threshold copula family tracing the upper boundary of the \((\rho,\nu)\) region.

Definition (conditional distribution in \(u\)): .. math:

h_\mu(t,v) \;=\; \mathbf{1}\{|t - t_\star|\ge (1-v)/2\},\qquad
t_\star \;=\; 1 - \mu/2,\;\; \mu\in[0,2].

Closed-form rank measures: - For \(0\le \mu\le 1\):

\(\rho(\mu)=1-\mu^3,\;\; \nu(\mu)=1-\tfrac34 \mu^4\).

  • For \(1\le \mu\le 2\): \(\rho(\mu)=-\mu^3+6\mu^2-12\mu+7, \;\; \nu(\mu)=-\tfrac34 \mu^4+4\mu^3-6\mu^2+3\).

blests_nu()[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

property cdf

Evaluate (or partially evaluate) the CDF.

Supports:
  • C(u1,…,ud) via separate scalars or a 1D array

  • partial substitution via kwargs (u1=…, u2=…, u=…, v=…)

  • returns a callable wrapper if variables remain, otherwise a scalar

cdf_vectorized(u, v)[source]
cond_distr_1(u=None, v=None)[source]

\(F_{U_{-1}\mid U_1}(u_{-1}\mid u_1)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

cond_distr_2(u=None, v=None)[source]

\(F_{U_{-2}\mid U_2}(u_{-2}\mid u_2)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

classmethod from_rho(rho_target: float)[source]

Construct boundary copula with target Spearman’s \(\rho\in[-1,1]\).

Inversion: - If \(\rho\in[0,1]\) then \(\mu=(1-\rho)^{1/3}\). - If \(\rho\in[-1,0]\) solve the monotone cubic

\(\rho(\mu)=-\mu^3+6\mu^2-12\mu+7\) on \([1,2]\).

intervals: dict = {'mu': Interval(0, 2)}
mu = mu
params: list = [mu]
property pdf

Evaluate (or partially evaluate) the PDF: ∂^d C / ∂u1 … ∂ud

pdf_vectorized(u, v)[source]

Vectorized density c(u,v) = ∂^2 C/∂u∂v = ∂ h(u,v)/∂v computed by a finite-difference in v.

spearmans_rho()[source]

Compute Spearman’s rho correlation measure.

This method sets the parameters, computes the corresponding integral, and returns the simplified expression for Spearman’s rho.

Returns:

The symbolic expression for Spearman’s rho.

Return type:

sympy.Expr

special_cases = {0: <class 'copul.family.frechet.upper_frechet.UpperFrechet'>, 2: <class 'copul.family.frechet.lower_frechet.LowerFrechet'>}
u = u
v = v

copul.family.other.xi_beta_boundary_copula module

class copul.family.other.xi_beta_boundary_copula.XiBetaBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Lower-boundary family for the exact region between Chatterjee’s xi and Blomqvist’s beta.

This is the symmetric 2x2 checkerboard family with parameter \(b = \beta \in [-1,1]\), determined by the mass matrix

\[\begin{split}\Delta_b = \begin{pmatrix} \frac{1+b}{4} & \frac{1-b}{4} \\ \frac{1-b}{4} & \frac{1+b}{4} \end{pmatrix}.\end{split}\]

The associated density is piecewise constant on the four quadrants:

\[\begin{split}c_b(u,v)= \begin{cases} 1+b, & (u,v)\in[0,\tfrac12]^2 \cup (\tfrac12,1]^2,\\ 1-b, & (u,v)\in[0,\tfrac12]\times(\tfrac12,1] \cup(\tfrac12,1]\times[0,\tfrac12],\\ \end{cases}\end{split}\]

and the copula satisfies

\[\beta(C_b)=b, \qquad \xi(C_b)=\frac{b^2}{2}.\]

Thus this family traces the sharp lower boundary \(\xi = \beta^2/2\) of the exact region.

Special cases: - \(b=0\): independence copula.

b = b
blests_nu(*args, **kwargs)[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

blomqvists_beta()[source]

Closed-form Blomqvist’s beta:

\[\beta(C_b)=b.\]
cdf_vectorized(u, v)[source]
chatterjees_xi()[source]

Closed-form Chatterjee’s xi:

\[\xi(C_b)=\frac{b^2}{2}.\]
classmethod from_beta(beta)[source]
classmethod from_xi(x, positive=True)[source]

Instantiate from xi along one branch of the lower boundary \(\xi = b^2/2\).

Parameters:
  • x (float) – Value in [0, 1/2].

  • positive (bool, default=True) – If True, choose b = +sqrt(2x); otherwise choose b = -sqrt(2x).

intervals: dict = {'b': Interval(-1, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau()[source]

Closed-form Kendall’s tau:

\[\tau(C_b)=\frac{2}{3}b.\]
params: list = [b]
pdf_vectorized(u, v)[source]
spearmans_rho()[source]

Closed-form Spearman’s rho:

\[\rho(C_b)=\frac{3}{4}b.\]
special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>}
u = u
v = v

copul.family.other.xi_counterexample_copula module

class copul.family.other.xi_counterexample_copula.XiCounterexampleCopula(*args, **kwargs)[source]

Bases: BivCopula

Absolutely continuous copula used as a counterexample to the unrestricted checkerboard lower-bound claim for Chatterjee’s xi.

The density is

\[\begin{split}c(u,v)= \begin{cases} f_1(v), & 0 \le u < 1/2,\\ f_2(v), & 1/2 \le u \le 1, \end{cases}\end{split}\]

where

\[\begin{split}f_1(v)= \begin{cases} 1, & 0 \le v < 1/4,\\ 2, & 1/4 \le v < 1/2,\\ 0, & 1/2 \le v < 3/4,\\ 1, & 3/4 \le v \le 1, \end{cases} \qquad f_2(v)=2-f_1(v).\end{split}\]

This copula has uniform marginals and is associated with the checkerboard matrix

\[\begin{split}\Delta = \begin{pmatrix} 3/8 & 1/8\\ 1/8 & 3/8 \end{pmatrix}.\end{split}\]

Its Chatterjee xi is

\[\xi(C)=1/16,\]

while the associated 2x2 checkerboard copula has

\[\xi(C^\Delta_\Pi)=1/8.\]
cdf_vectorized(u, v)[source]
chatterjees_xi()[source]

Compute Chatterjee’s xi correlation measure.

This method sets the parameters, computes intermediate integrals, and returns the simplified expression for xi.

Returns:

A wrapper around the symbolic expression for Chatterjee’s xi.

Return type:

SymPyFuncWrapper

checkerboard_matrix()[source]
checkerboard_xi()[source]

Chatterjee’s xi of the associated 2x2 checkerboard copula.

intervals: dict = {}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau()[source]

Compute Kendall’s tau correlation measure.

This method sets the parameters, computes necessary integrals, and returns the simplified expression for Kendall’s tau.

Returns:

The symbolic expression for Kendall’s tau.

Return type:

sympy.Expr

params: list = []
pdf_vectorized(u, v)[source]
spearmans_rho()[source]

Compute Spearman’s rho correlation measure.

This method sets the parameters, computes the corresponding integral, and returns the simplified expression for Spearman’s rho.

Returns:

The symbolic expression for Spearman’s rho.

Return type:

sympy.Expr

special_cases = {}
u = u
v = v

copul.family.other.xi_psi_lower_jensen_bound module

class copul.family.other.xi_psi_lower_jensen_bound.XiPsiLowerJensenBound(*args, **kwargs)[source]

Bases: BivCopula

A family of copulas tracing the lower boundary of the attainable region for pairs of Chatterjee’s \(\xi\) and Spearman’s footrule \(\psi\). This family is derived by minimizing the functional \(J(C) = \psi(C) + \mu\,\xi(C)\) for a parameter \(\mu \ge 1/2\).

Parameter — \(\mu\)

\(\mu \in [\tfrac12,\infty)\). The special case \(\mu=\tfrac12\) corresponds to the endpoint \((\xi,\psi)=(12\ln 2 - 8,\,-\tfrac12)\). As \(\mu \to \infty\), the copula approaches independence.

Formulas

The copula’s structure is defined by its conditional probability \(h(t,v) = \partial_1 C(t,v)\), which is piecewise constant in \(t\). Let \(v_0 = \dfrac{1}{2\mu+1}\) and \(v_1 = \dfrac{2\mu}{2\mu+1}\). Then \(h(t,v) = h_1(v)\,\mathbf{1}_{\{t\le v\}} + h_2(v)\,\mathbf{1}_{\{t>v\}}\), where

\[\begin{split}\begin{aligned} \text{for } v \in [0,v_0]:\quad & h_1(v)=0,\quad h_2(v)=\frac{v}{1-v},\\ \text{for } v \in (v_0,v_1]:\quad & h_1(v)=v-\frac{1-v}{2\mu},\quad h_2(v)=v+\frac{v}{2\mu},\\ \text{for } v \in (v_1,1]:\quad & h_1(v)=2-\frac{1}{v},\quad h_2(v)=1. \end{aligned}\end{split}\]

The CDF is

\[\begin{split}C(u,v) = \begin{cases} u\,h_1(v), & u \le v,\\ v\,h_1(v) + (u-v)\,h_2(v), & u > v. \end{cases}\end{split}\]

Dependence measures

\[\psi(\mu) = -2v_1^2 + 6v_1 - 5 + \frac{1}{v_1}, \qquad v_1 = \frac{2\mu}{2\mu+1}.\]
\[\xi(\mu) = 4v_1^3 - 18v_1^2 + 36v_1 - 22 - 12\ln(v_1) + \frac{6v_1^2 - 4v_1^3 - 1}{4\mu^2}.\]
cdf_vectorized(u, v)[source]

Vectorized implementation of the cumulative distribution function.

chatterjees_xi()[source]

Closed-form Chatterjee’s \(\xi(\mu)\).

\[\xi(\mu) = 4v_1^3 - 18v_1^2 + 36v_1 - 22 - 12\ln(v_1) + \frac{6v_1^2 - 4v_1^3 - 1}{4\mu^2}, \qquad v_1 = \frac{2\mu}{2\mu+1}.\]
intervals: dict = {'mu': Interval(1/2, oo)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

mu = mu
params: list = [mu]
spearmans_footrule()[source]

Closed-form Spearman’s footrule \(\psi(\mu)\).

\[\psi(\mu) = -2v_1^2 + 6v_1 - 5 + \frac{1}{v_1}, \qquad v_1 = \frac{2\mu}{2\mu+1}.\]
special_cases = {oo: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>}
u = u
v = v

copul.family.other.xi_rho_boundary_copula module

class copul.family.other.xi_rho_boundary_copula.XiRhoBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Optimal–\(\rho\) diagonal–band copula with dependence parameter \(b\in\mathbb{R}\setminus\{0\}\).

For \(b>0\), the copula is the upper/right boundary copula. For \(b<0\), the lower/left boundary copula is obtained by the reflection

\[C_b(u,v) = v - C_{|b|}(1-u,v).\]

Formulas

  1. Maximal Spearman’s \(\rho\) for \(b>0\):

    \[\begin{split}M(b) = \begin{cases} b - \dfrac{3b^2}{10}, & 0<b\le 1,\\[1ex] 1 - \dfrac{1}{2b^2} + \dfrac{1}{5b^3}, & b\ge 1. \end{cases}\end{split}\]
  2. Shift \(s_v(b)\) for \(b>0\):

    \[\begin{split}s_v = \begin{cases} \sqrt{2v/b}, & v \le \frac{1}{2b}\wedge\frac{b}{2},\\[1ex] v + \frac{1}{2b}, & \frac{1}{2b} < v \le 1-\frac{1}{2b},\\[1ex] \frac{v}{b}+\frac12, & \frac{b}{2} < v \le 1-\frac{b}{2},\\[1ex] 1 + \frac1b - \sqrt{2(1-v)/b}, & v > 1 - \left(\frac{1}{2b}\wedge\frac{b}{2}\right). \end{cases}\end{split}\]
  3. Copula CDF for \(b>0\):

    \[\begin{split}a_v = s_v - 1/b, \qquad C_b(u,v) = \begin{cases} u - \dfrac{b}{2}(u-a_v)^2 + \dfrac{b}{2}(a_v\wedge 0)^2, & a_v < u \le s_v,\\[1ex] \min\{u,v\}, & \text{else}. \end{cases}\end{split}\]
b = b
blests_nu(*args, **kwargs)[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

cdf_vectorized(u, v)[source]

Vectorized implementation of the cumulative distribution function. This method allows for efficient computation of the CDF for arrays of points, which is detected by the Checkerboarder for fast approximation.

chatterjees_xi()[source]

Closed-form \(\xi(C_b)\) for the original parameter \(b\).

dim: int
classmethod from_xi(x)[source]

Instantiate from xi. Optimized to use float arithmetic if x is float.

intervals: dict = {'b': Interval(-oo, oo)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau()[source]

Closed-form Kendall’s \(\tau(C_b)\) for the original parameter \(b\).

params: list = [b]
pdf_vectorized(u, v)[source]

Fully vectorized PDF implementation. Computes density c(u,v) = |b| * s’_v(v) inside the band, 0 outside. Replaces symbolic logic for high performance.

spearmans_rho()[source]

Closed-form Spearman’s \(\rho(C_b)\) for the original parameter \(b\).

special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>}
u = u
v = v

Module contents

class copul.family.other.BivIndependenceCopula(*args, **kwargs)[source]

Bases: Frechet, BivArchimedeanCopula

Bivariate Independence Copula implementation.

The independence copula represents statistical independence between random variables: C(u,v) = u*v

This is a special case of both the Frechet family (with alpha=beta=0) and the Archimedean family (with generator -log(t)).

property alpha
property beta
property cdf

C(u,v) = u*v

Type:

CDF of the independence copula

cond_distr_1(u=None, v=None)[source]

Conditional distribution: C_2(v|u) = v

For an independence copula, the conditional distribution of v given u is just v.

cond_distr_2(u=None, v=None)[source]

Conditional distribution: C_1(u|v) = u

For an independence copula, the conditional distribution of u given v is just u.

lambda_L()[source]

Lower tail dependence coefficient (= 0 for independence).

lambda_U()[source]

Upper tail dependence coefficient (= 0 for independence).

property pdf

PDF of the independence copula is constant 1 on the unit square.

property pickands
copul.family.other.ClampedParabolaCopula

alias of XiNuBoundaryCopula

class copul.family.other.DiagonalBandCopula(*args, **kwargs)[source]

Bases: BivCopula

Bojarski-type diagonal band copula (uniform band along \(y=x\)).

A stripe of half-width \(\alpha\) is laid along the main diagonal and wrapped/reflected at the unit square’s borders so that both marginals remain uniform.

Following Bojarski (2002, J. Math. Sci., Eq. (1)) with a constant base density

\[f(z) \;=\; \frac{1}{2\alpha}\,\mathbf{1}\{|z|\le \alpha\}, \quad z\in\mathbb{R},\]

supported on \([-\alpha,\alpha]\). Using a different symmetric base density (e.g., rescaled Beta) is a straightforward extension, but the uniform band already reproduces the classical diagonal-band example discussed in the paper.

Parameters:

alpha (float in (0, 1]) – Half-width of the diagonal band.

alpha = alpha
cond_distr_2(u=None, v=None)[source]

\(F_{U_{-2}\mid U_2}(u_{-2}\mid u_2)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

dim: int
intervals: dict = {'alpha': Interval.Lopen(0, 1)}
property is_absolutely_continuous

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = [alpha]
property pdf

Piecewise density \(g_\alpha(u,v)\) of the diagonal-band construction.

With the base density \(f(z)=\tfrac{1}{2\alpha}\mathbf{1}\{|z|\le \alpha\}\), the copula density is

\[\begin{split}g_\alpha(u,v) \;=\; \begin{cases} f(u-v) + f(u+v), & u+v \le \alpha,\\[0.5ex] f(u-v), & \alpha < u+v < 2-\alpha,\\[0.5ex] f(u-v) + f(u+v-2), & u+v \ge 2-\alpha, \end{cases}\end{split}\]

which enforces uniform margins by wrapping the diagonal band near the corners.

copul.family.other.DiagonalStripCopula

alias of XiPsiApproxLowerBoundaryCopula

class copul.family.other.FarlieGumbelMorgenstern(*args, **kwargs)[source]

Bases: BivCopula

Farlie-Gumbel-Morgenstern (FGM) Copula.

The FGM copula is defined as: C(u,v) = u*v + theta*u*v*(1-u)*(1-v)

It has limited dependence range with Spearman’s rho in [-1/3, 1/3] and Kendall’s tau in [-2/9, 2/9].

Parameters:

thetafloat, -1 ≤ theta ≤ 1

Dependence parameter that determines the strength and direction of dependence. theta = 0 gives the independence copula. theta > 0 indicates positive dependence. theta < 0 indicates negative dependence.

blests_nu()[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

property cdf

Cumulative distribution function of the copula.

C(u,v) = u*v + theta*u*v*(1-u)*(1-v)

cond_distr_2(u=None, v=None)[source]

Conditional distribution function with respect to v.

C_{2}(u,v) = u + theta*u*(1-u)*(1-2*v)

dim: int
ginis_gamma()[source]

Calculate Gini’s gamma for the FGM copula.

For FGM, Gini’s gamma = 4*theta/15

hoeffdings_d(*args, **kwargs)[source]

Hoeffding’s \(D\) for the FGM copula.

\[D = 90\,\theta^2 \left[\int_0^1 t^2(1-t)^2\,dt\right]^2 = \frac{\theta^2}{10}\]
intervals: dict = {'theta': Interval(-1, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau(*args, **kwargs)[source]

Calculate Kendall’s tau for the FGM copula.

For FGM, tau = 2*theta/9

lp_concordance(p: int = 2, *args, **kwargs)[source]

\(L_p\) concordance distance for the FGM copula.

\[\delta_p = k(p)\,|\theta|^p \left[\operatorname{B}(p+1,\,p+1)\right]^2\]

where \(\operatorname{B}\) is the beta function.

mutual_information(*args, **kwargs)[source]

Mutual information for the FGM copula (numerical).

The density is \(c(u,v) = 1 + \theta(1-2u)(1-2v)\). No known simple closed form for \(\int c \ln c\); delegates to the base-class numerical quadrature.

params: list = [theta]
property pdf

Probability density function of the copula.

c(u,v) = 1 + theta*(1-2*u)*(1-2*v)

schweizer_wolff_sigma(*args, **kwargs)[source]

Schweizer–Wolff \(\sigma\) for the FGM copula.

Since \(C - \Pi = \theta\,u\,v\,(1-u)(1-v)\) has constant sign (PQD when \(\theta>0\), NQD when \(\theta<0\)):

\[\sigma = 12\,|\theta|\, \left[\int_0^1 t(1-t)\,dt\right]^2 = \frac{|\theta|}{3}\]
spearmans_footrule()[source]
spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the FGM copula.

For FGM, rho = theta/3

theta = theta
class copul.family.other.Frechet(*args, **kwargs)[source]

Bases: BivCopula

Bivariate Fréchet copula (a convex combination of the upper/lower Fréchet bounds and independence).

Parameters:
  • alpha (\(\alpha \in [0,1]\)) – Weight of the upper Fréchet bound \(\min(u,v)\).

  • beta (\(\beta \in [0,1]\)) – Weight of the lower Fréchet bound \(\max(u+v-1,0)\).

Notes

The CDF is

\[C(u,v) \;=\; \alpha\,\min(u,v) \;+\; (1-\alpha-\beta)\,u\,v \;+\; \beta\,\max(u+v-1,0).\]

The parameter domain must satisfy \(\alpha\ge 0\), \(\beta\ge 0\) and \(\alpha+\beta \le 1\).

The copula is absolutely continuous iff \(\alpha=\beta=0\).

property alpha
property beta
blests_nu(*args, **kwargs)[source]

Blest’s measure of rank correlation ν. For the Fréchet copula: ν = α − β.

property cdf

Cumulative distribution function

\[C(u,v) \;=\; \alpha\,\min(u,v) \;+\; (1-\alpha-\beta)\,u\,v \;+\; \beta\,\max(u+v-1,0).\]
cdf_vectorized(u, v)[source]

Vectorized CDF on many points.

Parameters:
  • u (array_like) – Uniform marginals in \([0,1]\).

  • v (array_like) – Uniform marginals in \([0,1]\).

Returns:

Values of \(C(u,v)\).

Return type:

numpy.ndarray

Notes

Uses NumPy broadcasting; implements the same formula as above.

chatterjees_xi(*args, **kwargs)[source]

Compute Chatterjee’s xi correlation measure.

This method sets the parameters, computes intermediate integrals, and returns the simplified expression for xi.

Returns:

A wrapper around the symbolic expression for Chatterjee’s xi.

Return type:

SymPyFuncWrapper

cond_distr_1(u=None, v=None)[source]

\(F_{U_{-1}\mid U_1}(u_{-1}\mid u_1)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

cond_distr_2(u=None, v=None)[source]

\(F_{U_{-2}\mid U_2}(u_{-2}\mid u_2)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

dim: int
ginis_gamma(*args, **kwargs)[source]

Gini’s gamma \(\gamma\).

For the Fréchet copula,

\[\gamma \;=\; \alpha \;-\; \beta,\]

which coincides with Spearman’s \(\rho_S\) for this family.

intervals: dict = {'alpha': Interval(0, 1), 'beta': Interval(0, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether \(C(u,v)=C(v,u)\) (always True for this family).

kendalls_tau(*args, **kwargs)[source]

Kendall’s \(\tau\)

\[\tau \;=\; \frac{(\alpha-\beta)\,\bigl(2+\alpha+\beta\bigr)}{3}.\]
property lambda_L

Compute the lower tail dependence coefficient.

Returns:

The symbolic expression for the lower tail dependence.

Return type:

sympy.Expr

property lambda_U

Compute the upper tail dependence coefficient.

Returns:

The simplified symbolic expression for the upper tail dependence.

Return type:

sympy.Expr

params: list = [alpha, beta]
property pdf

Evaluate (or partially evaluate) the PDF: ∂^d C / ∂u1 … ∂ud

spearmans_footrule(*args, **kwargs)[source]

Spearman’s footrule \(\psi \;=\; \mathbb{E}\,\lvert U-V\rvert\).

Closed form:

\[\psi \;=\; \alpha \;-\; \tfrac{1}{2}\,\beta.\]
spearmans_rho(*args, **kwargs)[source]

Spearman’s rank correlation

\[\rho_S \;=\; \alpha \;-\; \beta.\]
class copul.family.other.IndependenceCopula(dimension=2, **kwargs)[source]

Bases: Copula, CopulaPlottingMixin

Multivariate Independence Copula implementation.

The independence copula represents statistical independence between random variables: C(u₁, u₂, …, uₙ) = u₁ × u₂ × … × uₙ

This is also a special case of an Archimedean copula with generator φ(t) = -log(t).

Parameters:

dimension (int, optional) – Dimension of the copula (number of variables). Default is 2.

blests_nu(*args, **kwargs)[source]
blomqvists_beta(*args, **kwargs)[source]
property cdf

Compute the cumulative distribution function (CDF) of the independence copula.

For the independence copula, the CDF is the product of all marginals: C(u₁, u₂, …, uₙ) = u₁ × u₂ × … × uₙ

Returns:

A wrapper around the CDF function.

Return type:

CDFWrapper

cdf_vectorized(*args)[source]

Vectorized implementation of the CDF for the independence copula.

Parameters:

*args (array_like) – Arrays of dimension values to evaluate the CDF at.

Returns:

Array of CDF values.

Return type:

numpy.ndarray

cond_distr(i, u=None)[source]

Compute the conditional distribution of the i-th variable.

For the independence copula, the conditional distribution is just the original variable.

Parameters:
  • i (int) – Index of the variable (1-based).

  • u (array_like, optional) – Values at which to evaluate the conditional distribution.

Returns:

The conditional distribution function or its value at u.

Return type:

SymPyFuncWrapper or float

dim: int
gini_gamma(*args, **kwargs)[source]
hoeffdings_d(*args, **kwargs)[source]
intervals = {}
property is_absolutely_continuous: bool

Check if the copula is absolutely continuous.

The independence copula is absolutely continuous.

Returns:

True

Return type:

bool

property is_symmetric: bool

Check if the copula is symmetric.

The independence copula is symmetric in all its arguments.

Returns:

True

Return type:

bool

kendalls_tau()[source]

Compute Kendall’s tau for the independence copula.

For the independence copula, Kendall’s tau is 0 as there is no dependence.

Returns:

0

Return type:

float

lambda_L()[source]

Compute the lower tail dependence coefficient.

For the independence copula, there is no tail dependence.

Returns:

0

Return type:

float

lambda_U()[source]

Compute the upper tail dependence coefficient.

For the independence copula, there is no tail dependence.

Returns:

0

Return type:

float

lp_concordance(p: int = 2, *args, **kwargs)[source]
mutual_information(*args, **kwargs)[source]
params = []
property pdf

Compute the probability density function (PDF) of the independence copula.

For the independence copula, the PDF is constant 1 on the unit cube.

Returns:

A wrapper around the PDF function.

Return type:

SymPyFuncWrapper

pdf_vectorized(*args)[source]

Vectorized implementation of the PDF for the independence copula.

Parameters:

*args (array_like) – Arrays of dimension values to evaluate the PDF at.

Returns:

Array of PDF values (all 1s).

Return type:

numpy.ndarray

rvs(n=1, random_state=None)[source]

Generate random variates from the independence copula.

For the independence copula, this simply generates independent uniform random variables.

Parameters:
  • n (int, optional) – Number of samples to generate (default is 1).

  • random_state (int or None, optional) – Seed for the random number generator.

Returns:

Array of shape (n, dim) containing independent uniform samples.

Return type:

numpy.ndarray

schweizer_wolff_sigma(*args, **kwargs)[source]
spearman_footrule(*args, **kwargs)[source]
spearmans_rho()[source]

Compute Spearman’s rho for the independence copula.

For the independence copula, Spearman’s rho is 0 as there is no dependence.

Returns:

0

Return type:

float

class copul.family.other.LowerFrechet(*args, **kwargs)[source]

Bases: Frechet

property alpha
property beta
class copul.family.other.Mardia(*args, **kwargs)[source]

Bases: BivCopula

Mardia Copula.

A convex mixture of the Fréchet bounds and the independence copula.

C(u,v) = theta^2 * (1 + theta) / 2 * min(u,v) +

(1 - theta^2) * u*v + theta^2 * (1 - theta) / 2 * max(u+v-1, 0)

Parameters:

thetafloat, -1 ≤ theta ≤ 1

Dependence parameter

property cdf

Cumulative distribution function of the copula.

C(u,v) = theta^2 * (1 + theta) / 2 * min(u,v) +

(1 - theta^2) * u*v + theta^2 * (1 - theta) / 2 * max(u+v-1, 0)

chatterjees_xi(*args, **kwargs)[source]

Calculate Chatterjee’s xi for the Mardia copula.

For Mardia, xi = theta^4 * (3*theta^2 + 1) / 4

dim: int
intervals: dict = {'theta': Interval(-1, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau(*args, **kwargs)[source]

Calculate Kendall’s tau for the Mardia copula.

For Mardia, tau = theta^3 * (theta^2 + 2) / 3

property lambda_L

Lower tail dependence coefficient.

For Mardia, lambda_L = theta^2 * (1 + theta) / 2

When theta = 1, this equals 1 When theta = -1, this equals 0

property lambda_U

Upper tail dependence coefficient.

For Mardia, lambda_U = theta^2 * (1 + theta) / 2

When theta = 1, this equals 1 When theta = -1, this equals 0

params: list = [theta]
property pdf

Probability density function of the copula.

The Mardia copula does not have a PDF due to its singular components.

spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the Mardia copula.

For Mardia, rho = theta^3

theta = theta
class copul.family.other.Plackett(*args, **kwargs)[source]

Bases: BivCopula

blests_nu()[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

blomqvist(*args, **kwargs)[source]

Nelsen Exercise 5.18

property cdf

Evaluate (or partially evaluate) the CDF.

Supports:
  • C(u1,…,ud) via separate scalars or a 1D array

  • partial substitution via kwargs (u1=…, u2=…, u=…, v=…)

  • returns a callable wrapper if variables remain, otherwise a scalar

cond_distr_1(u=None, v=None)[source]

\(F_{U_{-1}\mid U_1}(u_{-1}\mid u_1)\).

Parameters:
  • *args – See cond_distr().

  • **kwargs – See cond_distr().

dim: int
get_density_of_density()[source]
get_numerator_double_density()[source]
intervals: dict = {'theta': Interval(0, oo)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = [theta]
property pdf

Evaluate (or partially evaluate) the PDF: ∂^d C / ∂u1 … ∂ud

spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the Plackett copula.

For the Plackett copula, the formula is: rho = (theta + 1) / (theta - 1) - 4 * theta * log(theta) / (theta - 1)^2

Special case: when theta = 1, rho = 0 (independence)

theta = theta
class copul.family.other.Raftery(*args, **kwargs)[source]

Bases: BivCopula

Raftery Copula.

This copula has a parameter delta controlling the dependence structure. Special cases: - delta = 0: Independence copula - delta = 1: Upper Fréchet bound (perfect positive dependence)

Parameters:

deltafloat, 0 ≤ delta ≤ 1

Dependence parameter

property cdf

Cumulative distribution function of the copula.

The formula has special cases for delta=0 and delta=1 to avoid division by zero.

cdf_vectorized(u, v)[source]

Vectorized implementation of the cumulative distribution function for Raftery copula.

This method evaluates the CDF at multiple points simultaneously, which is more efficient than calling the scalar CDF function repeatedly.

Parameters:
  • u (array_like) – First uniform marginal, should be in [0, 1].

  • v (array_like) – Second uniform marginal, should be in [0, 1].

Returns:

The CDF values at the specified points.

Return type:

numpy.ndarray

Notes

The Raftery copula CDF is: C(u,v) = min(u, v) + (1 - delta) / (1 + delta) * (u * v)^(1/(1-delta)) * (1 - max(u, v)^(-(1+delta)/(1-delta)))

Special cases: - When delta = 0, it’s the Independence copula (u * v) - When delta = 1, it’s the Upper Fréchet bound (min(u, v))

delta = delta
dim: int
intervals: dict = {'delta': Interval(0, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau(*args, **kwargs)[source]

Calculate Kendall’s tau for the Raftery copula.

For Raftery, tau = 2*delta / (3 - delta)

property lambda_L

Lower tail dependence coefficient.

For Raftery, lambda_L = 2*delta / (1 + delta)

property lambda_U

Upper tail dependence coefficient.

For Raftery, lambda_U = 0

params: list = [delta]
property pdf

Probability density function of the copula.

Calculated using the _b function.

spearmans_rho(*args, **kwargs)[source]

Calculate Spearman’s rho for the Raftery copula.

For Raftery, rho = delta * (4 - 3*delta) / (2 - delta)^2

class copul.family.other.UpperFrechet(*args, **kwargs)[source]

Bases: Frechet

property alpha
property beta
dim: int
property pickands
t = t
class copul.family.other.XiNuBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Clamped–parabola copula parameterized by \(b=1/\mu>0\):

\[h_v(t) \;=\; \mathrm{clamp}\!\left(b\big((1-t)^2 - q(v)\big),\,0,\,1\right),\]

where \(q(v)\) is uniquely determined by the marginal constraint \(\int_0^1 h_v(t)\,dt=v\).

b = b
blests_nu()[source]

Signed Blest’s ν(b). Under the σ₂ reflection (b<0) the dependence reverses, so ν must satisfy ν(-b) = -ν(b). We therefore return sign(b) * ν(|b|), where ν(|b|) is the closed form in terms of μ = 1/|b|.

property cdf

Evaluate (or partially evaluate) the CDF.

Supports:
  • C(u1,…,ud) via separate scalars or a 1D array

  • partial substitution via kwargs (u1=…, u2=…, u=…, v=…)

  • returns a callable wrapper if variables remain, otherwise a scalar

cdf_vectorized(u, v)[source]

If b >= 0: C(u,v) = C_base(u,v; |b|). If b < 0 : C(u,v) = u - C_base(u, 1-v; |b|) (σ2 reflection).

chatterjees_xi()[source]

Compute Chatterjee’s xi correlation measure.

This method sets the parameters, computes intermediate integrals, and returns the simplified expression for xi.

Returns:

A wrapper around the symbolic expression for Chatterjee’s xi.

Return type:

SymPyFuncWrapper

cond_distr_1()[source]

h(u,v) = ∂_u C(u,v). If b >= 0: h = clamp(|b|((1-u)^2 - q(v)),0,1). If b < 0 : h = 1 - clamp(|b|((1-u)^2 - q(1-v)),0,1). (since C^σ2) NOTE: q(·) will be evaluated with |b| in the lambdify bridge.

dim: int
classmethod from_xi(x_target)[source]

Solve for b from target ξ. Since ξ(μ) is strictly decreasing in μ, we solve for μ and return b=1/μ.

intervals: dict = {'b': Interval.open(0, oo)}
property is_absolutely_continuous: bool

XiNuBoundaryCopula has a density everywhere on (0,1)^2.

params: list = [b]
pdf_vectorized(u, v)[source]

If b >= 0: c(u,v) = c_base(u,v; |b|). If b < 0 : c(u,v) = c_base(u, 1-v; |b|) (chain rule for σ2).

plot_cdf(*, plot_type='3d', log_z=False, **kwargs)[source]

Plot the CDF using the numerical cdf_vectorized() implementation.

plot_cond_distr_1(*, plot_type='3d', log_z=False, **kwargs)[source]

Plot h(u,v) = ∂_u C(u,v). Uses the symbolic expression and injects q(v) so the base lambdify has a valid mapping.

plot_cond_distr_2(*, plot_type='3d', log_z=False, **kwargs)[source]

Not available: q(v) is implicit and prevents a closed form.

plot_pdf(*, plot_type='3d', log_z=False, **kwargs)[source]

Plot the PDF using the numerical pdf_vectorized() implementation.

special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>, oo: <class 'copul.family.frechet.upper_frechet.UpperFrechet'>}
u = u
v = v
class copul.family.other.XiPsiApproxLowerBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Two-parameter “diagonal strip” copula with a rectangular hole.

The copula is defined by a transformation variable T and a hole geometry H. C(u,v) = (u*t - Area(Intersection)) / (1 - beta) where t = F_T^{-1}(v).

Parameters:
  • alpha (float) – Controls the horizontal start of the diagonal slope. alpha in [0, 0.5).

  • beta (float) – Controls the vertical thickness of the hole. beta in (0, 1).

alpha = alpha
beta = beta
cdf(u=None, v=None)[source]

Cumulative distribution function C(u,v).

cdf_vectorized(u, v)[source]

Exact numeric Copula CDF.

cond_distr_1(u=None, v=None)[source]

P(V <= v | U = u) = dC/du.

cond_distr_2(u=None, v=None)[source]

P(U <= u | V = v) = dC/dv.

dim: int
intervals: dict = {'alpha': Interval.Lopen(0, 1/2), 'beta': Interval.open(0, 1)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

params: list = [alpha, beta]
pdf(u=None, v=None)[source]

Probability Density Function c(u,v).

pdf_vectorized(u, v)[source]

Exact numeric Copula PDF.

special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>}
u = u
v = v
class copul.family.other.XiRhoBoundaryCopula(*args, **kwargs)[source]

Bases: BivCopula

Optimal–\(\rho\) diagonal–band copula with dependence parameter \(b\in\mathbb{R}\setminus\{0\}\).

For \(b>0\), the copula is the upper/right boundary copula. For \(b<0\), the lower/left boundary copula is obtained by the reflection

\[C_b(u,v) = v - C_{|b|}(1-u,v).\]

Formulas

  1. Maximal Spearman’s \(\rho\) for \(b>0\):

    \[\begin{split}M(b) = \begin{cases} b - \dfrac{3b^2}{10}, & 0<b\le 1,\\[1ex] 1 - \dfrac{1}{2b^2} + \dfrac{1}{5b^3}, & b\ge 1. \end{cases}\end{split}\]
  2. Shift \(s_v(b)\) for \(b>0\):

    \[\begin{split}s_v = \begin{cases} \sqrt{2v/b}, & v \le \frac{1}{2b}\wedge\frac{b}{2},\\[1ex] v + \frac{1}{2b}, & \frac{1}{2b} < v \le 1-\frac{1}{2b},\\[1ex] \frac{v}{b}+\frac12, & \frac{b}{2} < v \le 1-\frac{b}{2},\\[1ex] 1 + \frac1b - \sqrt{2(1-v)/b}, & v > 1 - \left(\frac{1}{2b}\wedge\frac{b}{2}\right). \end{cases}\end{split}\]
  3. Copula CDF for \(b>0\):

    \[\begin{split}a_v = s_v - 1/b, \qquad C_b(u,v) = \begin{cases} u - \dfrac{b}{2}(u-a_v)^2 + \dfrac{b}{2}(a_v\wedge 0)^2, & a_v < u \le s_v,\\[1ex] \min\{u,v\}, & \text{else}. \end{cases}\end{split}\]
b = b
blests_nu(*args, **kwargs)[source]

Compute Blest’s rank correlation ν.

Uses the copula form

ν(C) = 24 ∫_0^1 ∫_0^1 (1 - u) C(u, v) du dv - 2

which is linear in C and generally symbolic-friendly.

Returns:

The symbolic expression for Blest’s ν.

Return type:

sympy.Expr

cdf_vectorized(u, v)[source]

Vectorized implementation of the cumulative distribution function. This method allows for efficient computation of the CDF for arrays of points, which is detected by the Checkerboarder for fast approximation.

chatterjees_xi()[source]

Closed-form \(\xi(C_b)\) for the original parameter \(b\).

dim: int
classmethod from_xi(x)[source]

Instantiate from xi. Optimized to use float arithmetic if x is float.

intervals: dict = {'b': Interval(-oo, oo)}
property is_absolutely_continuous: bool

Whether the copula is absolutely continuous.

Returns:

True if the copula has a density a.e. on \([0,1]^d\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

property is_symmetric: bool

Whether the copula is exchangeable (symmetric under coordinate permutations).

Returns:

True if \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwise False.

Return type:

bool

Notes

Subclasses must override this property.

kendalls_tau()[source]

Closed-form Kendall’s \(\tau(C_b)\) for the original parameter \(b\).

params: list = [b]
pdf_vectorized(u, v)[source]

Fully vectorized PDF implementation. Computes density c(u,v) = |b| * s’_v(v) inside the band, 0 outside. Replaces symbolic logic for high performance.

spearmans_rho()[source]

Closed-form Spearman’s \(\rho(C_b)\) for the original parameter \(b\).

special_cases = {0: <class 'copul.family.frechet.biv_independence_copula.BivIndependenceCopula'>}
u = u
v = v