copul.family.frechet package
Submodules
copul.family.frechet.biv_independence_copula module
- class copul.family.frechet.biv_independence_copula.BivIndependenceCopula(*args, **kwargs)[source]
Bases:
Frechet,BivArchimedeanCopulaBivariate 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]
Bases:
BivCopulaBivariate 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:
- 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:
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
copul.family.frechet.frechet_multi module
- class copul.family.frechet.frechet_multi.MVFrechet(dimension, *args, **kwargs)[source]
Bases:
_FrechetMultiMixin,CopulaMultivariate 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]
Bases:
BivCopulaMardia 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:
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]
Bases:
Frechet- One-parameter family attaining the lower boundary of the (rho, D) region:
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
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]
Bases:
Frechet- 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