copul.family.frechet package
Submodules
copul.family.frechet.biv_independence_copula module
- class copul.family.frechet.biv_independence_copula.BivIndependenceCopula(*args, **kwargs)[source]
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.
- property pdf
PDF of the independence copula is constant 1 on the unit square.
- property pickands
copul.family.frechet.frechet module
- class copul.family.frechet.frechet.Frechet(*args, **kwargs)[source]
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: ν = α − β.
- blomqvists_beta(*args, **kwargs)[source]
Blomqvist’s \(\beta = \alpha - \beta\) (affine in the weights).
- blum_kiefer_rosenblatt(*args, **kwargs)[source]
Blum-Kiefer-Rosenblatt coefficient for the Fr'echet copula:
\[B = \tfrac13\bigl(\alpha^2(1+2\alpha)+\beta^2(1+2\beta)\bigr) - \tfrac12\,\alpha\beta(\alpha+\beta) - \tfrac{7}{12}\,\alpha\beta\,,\]with \(B(M)=B(W)=1\), obtained by integrating the squared deviation against the mixture measure \(\alpha\,\mathrm{d}M+(1-\alpha-\beta)\,\mathrm{d}\Pi+\beta\,\mathrm{d}W\).
- 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:
- 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
- gini_gamma(*args, **kwargs)[source]
Compute Gini’s gamma concordance coefficient.
\[\gamma(C) = 4\!\left[\int_0^1 C(t,t)\,dt + \int_0^1 C(t,1-t)\,dt\right] - 2\]Range: \([-1, 1]\). \(\gamma = 1\) for the upper Fréchet bound (comonotonic), \(\gamma = -1\) for the lower Fréchet bound (countermonotonic), \(\gamma = 0\) for independence.
- Returns:
The symbolic expression for Gini’s gamma.
- Return type:
sympy.Expr
- 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.
- hoeffdings_d(*args, **kwargs)[source]
Hoeffding’s dependence index for the Fr'echet copula:
\[\Phi^2 = \alpha^2 + \beta^2 - \tfrac{7}{4}\,\alpha\beta\,,\]using \(90\!\iint(M-\Pi)^2 = 90\!\iint(W-\Pi)^2 = 1\) and \(90\!\iint(M-\Pi)(W-\Pi) = -\tfrac{7}{8}\).
- intervals: dict = {'alpha': Interval(0, 1), 'beta': Interval(0, 1)}
- property is_absolutely_continuous: bool
Whether the copula is absolutely continuous.
- Returns:
Trueif the copula has a density a.e. on \([0,1]^d\), otherwiseFalse.- Return type:
bool
Notes
Subclasses must override this property.
- property is_symmetric: bool
Whether \(C(u,v)=C(v,u)\) (always
Truefor 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
- spearman_footrule(*args, **kwargs)[source]
Compute Spearman’s footrule coefficient \(\psi\).
\[\psi(C) = 6 \int_0^1 C(t,t)\,dt - 2\]Equivalently, \(\psi(C) = 6\,\mathbb{E}[\min(U,V)] - 2\) where \((U,V) \sim C\).
Range: \([-\tfrac{1}{2}, 1]\). \(\psi = 1\) for the upper Fréchet bound, \(\psi = -\tfrac{1}{2}\) for the lower Fréchet bound, \(\psi = 0\) for independence.
- Returns:
The symbolic expression for Spearman’s footrule coefficient.
- Return type:
sympy.Expr
copul.family.frechet.frechet_multi module
- class copul.family.frechet.frechet_multi.MVFrechet(dimension, *args, **kwargs)[source]
Multivariate Fréchet family for arbitrary dimension d >= 2.
- Usage:
C = MVFrechet(dimension=3, alpha=0.4) # beta auto-forced to 0 C = MVFrechet(dimension=2, alpha=0.3, beta=0.2)
Notes
Intervals for alpha/beta are auto-tightened based on (dimension, other parameter).
In d≥3, attempting to set beta!=0 raises ValueError.
copul.family.frechet.lower_frechet module
copul.family.frechet.mardia module
- class copul.family.frechet.mardia.Mardia(*args, **kwargs)[source]
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
- blests_nu(*args, **kwargs)[source]
Blest’s \(\nu = \theta^3\); the Mardia copula is radially symmetric, so \(\nu\) coincides with Spearman’s \(\rho\).
- blum_kiefer_rosenblatt(*args, **kwargs)[source]
Blum-Kiefer-Rosenblatt coefficient \(B = \theta^4(2\theta^2+1)(15\theta^2+1)/48\) for the Mardia copula, obtained from the Fr'echet-copula formula by substituting the Mardia weights.
- 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
- hoeffdings_d(*args, **kwargs)[source]
Hoeffding’s dependence index \(\Phi^2 = \theta^4(1+15\theta^2)/16\), obtained from the Fr'echet-copula formula by substituting the Mardia weights.
- intervals: dict = {'theta': Interval(-1, 1)}
- property is_absolutely_continuous: bool
Whether the copula is absolutely continuous.
- Returns:
Trueif the copula has a density a.e. on \([0,1]^d\), otherwiseFalse.- Return type:
bool
Notes
Subclasses must override this property.
- property is_symmetric: bool
Whether the copula is exchangeable (symmetric under coordinate permutations).
- Returns:
Trueif \(C(u_{\pi(1)},\ldots,u_{\pi(d)}) = C(u_1,\ldots,u_d)\) for all permutations \(\pi\), otherwiseFalse.- 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
copul.family.frechet.rho_d_lower_boundary module
- class copul.family.frechet.rho_d_lower_boundary.RhoDLowerBoundary(*args, **kwargs)[source]
One-parameter family attaining the lower boundary of the (rho, D) region:
C = (1 - |rho|) * Pi + |rho| * B_rho,
where B_rho = M if rho >= 0 and B_rho = W if rho < 0.
This can be encoded as the Frechet mixture with:
alpha(rho) = max(rho, 0), beta(rho) = max(-rho, 0), independence weight = 1 - |rho|.
- Parameters:
rho (sympy symbol or float in [-1, 1]) – Target Spearman’s rho. For this family, rho(C) = rho.
Notes
We expose only the single parameter ‘rho’ and compute alpha, beta piecewise via sympy.Max to keep expressions symbolic when needed.
- property alpha
- property beta
- property cdf
Symbolic CDF of the lower-boundary family:
C(u,v) = alpha * min(u,v) + (1 - alpha - beta) * u v + beta * max(u+v-1, 0), where 1 - alpha - beta = 1 - |rho|.
- intervals: dict = {'rho': Interval(-1, 1)}
- params: list = [rho]
- property rho
copul.family.frechet.rho_d_upper_boundary module
- class copul.family.frechet.rho_d_upper_boundary.RhoDUpperBoundary(*args, **kwargs)[source]
One-parameter family attaining the upper boundary of the (rho, D) region:
C = alpha * M + (1 - alpha) * W, with alpha = (1 + rho)/2.
Hence the independence weight is zero and beta = 1 - alpha = (1 - rho)/2. This family satisfies Spearman’s rho(C) = rho.
- Parameters:
rho (sympy symbol or float in [-1, 1]) – Target Spearman’s rho.
Notes
We implement this as a Frechet subclass but expose only the single parameter ‘rho’. Internally:
alpha(rho) = (1 + rho)/2, beta(rho) = (1 - rho)/2.
- property alpha
- property beta
- property cdf
C(u,v) = alpha * min(u,v) + (1 - alpha - beta) * u v + beta * max(u+v-1, 0) = alpha * M + beta * W (since 1 - alpha - beta = 0 in this family).
- intervals: dict = {'rho': Interval(-1, 1)}
- params: list = [rho]
- property rho