VinecopBase
- class VinecopBase(*args, **kwargs)
Canonical array-agnostic vine cascades (numpy / torch).
Concrete subclasses implement
_get_pair_copula(and optionally override_prep/_simulate_uniform/ the batched-path hooks) and call_bind_vineonce; they then inherit the whole evaluator surface —pdf/cdf/rosenblatt/inverse_rosenblatt/simulate,loglik/plot/__repr__, thedim/trunc_lvl/orderaccessors, and thefit()/select()engines. Not annn.Module, so it composes with any pair-copula implementation (including non-torch ones).Methods
cdf(u, *[, N, qrng, num_threads, seeds, x, ...])Evaluate the joint CDF at each query row via quasi-Monte-Carlo.
fit(structure, u, fit_edge, *[, context, x])Fit pair copulas tree-by-tree along a fixed structure (returns them).
get_pair_copula(tree, edge)Return the pair copula at
(tree, edge).inverse_rosenblatt(u, *[, num_threads, x, ...])Inverse Rosenblatt transform: independent uniforms to dependent uniforms.
loglik(u, *[, x])Total log-likelihood
sum(log c(u))of the vine atu.pdf(u, *[, num_threads, x, batched])Evaluate the vine-copula density
c(u_1, ..., u_d).plot([tree, add_edge_labels, layout, vars_names])Plot the vine tree structure with networkx.
rosenblatt(u, *[, num_threads, x, batched])Rosenblatt transform: dependent uniforms to independent uniforms.
select(u, fit_edge, *[, trunc_lvl, ...])Select an R-vine structure from data (array-agnostic Dissmann).
simulate(n, *[, qrng, num_threads, seeds, x])Simulate
nsamples from the fitted copula.See also
pyvinecopulib.core.VinecopLikeThe contract this implements.
pyvinecopulib.core.VinecopThe reference vine.
pyvinecopulib.core.ConditioningContextPer-edge conditioning policy.
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
Number of variables in the vine.
R-vine structure matrix (from
structure).Methods
Evaluate the joint CDF at each query row via quasi-Monte-Carlo.
Fit pair copulas tree-by-tree along a fixed structure (returns them).
Return the pair copula at
(tree, edge).Inverse Rosenblatt transform: independent uniforms to dependent uniforms.
Total log-likelihood
sum(log c(u))of the vine atu.Evaluate the vine-copula density
c(u_1, ..., u_d).Plot the vine tree structure with networkx.
Rosenblatt transform: dependent uniforms to independent uniforms.
Select an R-vine structure from data (array-agnostic Dissmann).
Simulate
nsamples from the fitted copula.