VinecopLike
- class VinecopLike(*args, **kwargs)
Contract for a post-fit vine-copula evaluator.
A vine evaluator exposes the joint
pdf/cdf, therosenblattandinverse_rosenblatttransforms, and asimulatesampler, plus astructureattribute (theRVineStructureit was built on). The optional keyword-onlyxcovariate matrix (row-aligned withu) is the conditional extension — leftNonefor the usual (unconditional) case. SubclassVinecopBaseto get every method from a small set of hooks;pyvinecopulib.core.Vinecopandpyvinecopulib.torch.TorchVinecopare the reference implementations.Methods
cdf(u, *[, x, N, num_threads, seeds])Joint vine-copula distribution
C(u)via Monte-Carlo.inverse_rosenblatt(u, *[, x, num_threads])Inverse Rosenblatt transform: independent uniforms to dependent uniforms.
pdf(u, *[, x, num_threads])Joint vine-copula density
c(u_1, ..., u_d)at each observation.rosenblatt(u, *[, x, num_threads])Rosenblatt transform: dependent uniforms to independent uniforms.
simulate(n, *[, x, qrng, num_threads, seeds])Draw
nsamples from the fitted vine copula.See also
pyvinecopulib.core.VinecopBaseCanonical partial implementation to subclass.
pyvinecopulib.core.VinecopThe reference vine.
BicopLikeThe pair-copula contract.
Examples
Host copulas in a vine by subclassing
VinecopBase; the only required hook is_get_pair_copula. Under the defaultSimplifiedContextit is a classic (unconditional, simplified) vine, and hostingBicoppairs reproducesfrom_structure():import numpy as np import pyvinecopulib as pv from pyvinecopulib.core import VinecopBase class ListVinecop(VinecopBase[np.ndarray]): def __init__(self, pairs, structure): self._pairs = pairs self._bind_vine(structure) # SimplifiedContext by default def _get_pair_copula(self, tree, edge): return self._pairs[tree][edge] struct = pv.RVineStructure.from_order([1, 2, 3]) g = pv.families.gaussian pairs = [ [pv.Bicop(family=g, parameters=np.array([[0.5]])), pv.Bicop(family=g, parameters=np.array([[0.4]]))], [pv.Bicop(family=g, parameters=np.array([[0.2]]))], ] vine = ListVinecop(pairs, struct) ref = pv.Vinecop.from_structure(structure=struct, pair_copulas=pairs) u = np.random.default_rng(0).uniform(size=(4, 3)) np.allclose(vine.pdf(u), ref.pdf(u)) # -> True
Attributes
Methods
Joint vine-copula distribution
C(u)via Monte-Carlo.Inverse Rosenblatt transform: independent uniforms to dependent uniforms.
Joint vine-copula density
c(u_1, ..., u_d)at each observation.Rosenblatt transform: dependent uniforms to independent uniforms.
Draw
nsamples from the fitted vine copula.