TorchVinecop
- class TorchVinecop(pair_copulas, structure, *, context=None)
PyTorch R-vine copula evaluator built on
TorchBicop.Mirrors the public surface of
Vinecop—pdf/rosenblatt/inverse_rosenblatt/simulate— but keeps the entire evaluation chain in PyTorch so the vine can move to GPU with.to(device)and compose with autograd-aware downstream code. Continuous variables only, single batch, no threading. Build aTorchVinecopviafrom_data()(pure-torch TLL fit) orfrom_vinecop()(lifts a fittedVinecop).The cascade is a dense
(n, d)-scratch port of theVinecopevaluator, byte-for-byte parity withVinecop.pdf/rosenblattacceptbatched=Trueto fire a single batched bicop call per tree level.inverse_rosenblatt(batched=True)raises (cross-tree deps in the inverse cascade). The defaultbatched=Noneresolves toTrueon CUDA (3–7x faster) andFalseon CPU.- Parameters:
- pair_copulaslist of list of TorchBicop
Indexed
[tree][edge]and shaped likeVinecop’s pair-copula layout: tree 0 hasd - 1edges, tree 1 hasd - 2, etc., up totrunc_lvl. May also be passed as a torch.nn.ModuleList of torch.nn.ModuleList.- structureRVineStructure
Vine structure whose accessors (
min_array,struct_array,needed_hfunc1/needed_hfunc2) describe how to walk the trees.- contextConditioningContext or None, default=None
Conditioning-context policy that assembles each pair copula’s
xper edge.NoneusesSimplifiedContext(an unconditional / simplified vine).
Methods
from_data(u[, structure, controls, var_types])Fit a pure-PyTorch TLL vine on
u.from_structure([structure, matrix, ...])Builds a
TorchVinecopfrom a structure (or matrix) and pair-copulas.from_vinecop(cop[, cache_integrals, device, ...])Lifts a fitted
Vinecopinto aTorchVinecop.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).
Fit a pure-PyTorch TLL vine on
u.Builds a
TorchVinecopfrom a structure (or matrix) and pair-copulas.Lifts a fitted
Vinecopinto aTorchVinecop.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.