BicopLike
- class BicopLike(*args, **kwargs)
Contract for a bivariate (optionally conditional) pair copula.
A pair copula maps pseudo-observations
uof shape(n, 2)(in the unit square, clamped to[1e-10, 1 - 1e-10]) to a density (pdf), a distribution (cdf), the two conditional distributionshfunc1(u) = P(U2 <= u2 | U1 = u1)/hfunc2(u) = P(U1 <= u1 | U2 = u2)and their inverses (hinv1/hinv2, inverting in the second / first argument), plus a sampler (simulate). The optionalxof shape(n, k)carries conditioning variables: a conditional copula reads them, an unconditional one ignores them.The easy way to satisfy this contract is to subclass
BicopBase, which supplieshinv1/hinv2(numerical inversion) andsimulateon top ofpdf/hfunc1/hfunc2.pyvinecopulib.core.Bicopandpyvinecopulib.torch.TorchBicopare the reference implementations.Methods
cdf(u[, x])Pair-copula distribution
C(u)at each observation.flip()Return the pair copula with its two arguments swapped.
hfunc1(u[, x])First h-function
P(U2 <= u2 | U1 = u1).hfunc2(u[, x])Second h-function
P(U1 <= u1 | U2 = u2).hinv1(u[, x])Inverse of
hfunc1()in its second argument.hinv2(u[, x])Inverse of
hfunc2()in its first argument.pdf(u[, x])Pair-copula density
c(u)at each observation.simulate(n, *[, x, qrng, seeds])Draw
nsamples from the pair copula.See also
pyvinecopulib.core.BicopBaseCanonical partial implementation to subclass.
pyvinecopulib.core.BicopThe reference pair copula.
VinecopLikeThe vine-level evaluator contract.
Examples
A minimal independence pair on NumPy — implement only the three primitives and inherit
hinv1/hinv2/simulate/loglik/plot/__repr__fromBicopBase:import numpy as np from pyvinecopulib.core import BicopBase class Independence(BicopBase[np.ndarray]): def pdf(self, u, x=None): return np.ones(u.shape[0]) def hfunc1(self, u, x=None): return u[:, 1] def hfunc2(self, u, x=None): return u[:, 0] cop = Independence() cop.hinv1(np.array([[0.3, 0.7]])) # -> array([0.7]) (numerical inverse)
Methods
Pair-copula distribution
C(u)at each observation.Return the pair copula with its two arguments swapped.
First h-function
P(U2 <= u2 | U1 = u1).Second h-function
P(U1 <= u1 | U2 = u2).Inverse of
hfunc1()in its second argument.Inverse of
hfunc2()in its first argument.Pair-copula density
c(u)at each observation.Draw
nsamples from the pair copula.