TorchVinecop

class TorchVinecop(pair_copulas, structure, *, context=None)

PyTorch R-vine copula evaluator built on TorchBicop.

Mirrors the public surface of Vinecoppdf / 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 a TorchVinecop via from_data() (pure-torch TLL fit) or from_vinecop() (lifts a fitted Vinecop).

The cascade is a dense (n, d)-scratch port of the Vinecop evaluator, byte-for-byte parity with Vinecop. pdf / rosenblatt accept batched=True to fire a single batched bicop call per tree level. inverse_rosenblatt(batched=True) raises (cross-tree deps in the inverse cascade). The default batched=None resolves to True on CUDA (3–7x faster) and False on CPU.

Parameters:
pair_copulaslist of list of TorchBicop

Indexed [tree][edge] and shaped like Vinecop’s pair-copula layout: tree 0 has d - 1 edges, tree 1 has d - 2, etc., up to trunc_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 x per edge. None uses SimplifiedContext (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 TorchVinecop from a structure (or matrix) and pair-copulas.

from_vinecop(cop[, cache_integrals, device, ...])

Lifts a fitted Vinecop into a TorchVinecop.

Attributes

call_super_init

dim

Number of variables in the vine.

dump_patches

matrix

R-vine structure matrix (from structure).

d

trunc_lvl

pair_copulas

structure

order

inverse_order

training

Methods

__init__

cdf

Evaluate the joint CDF at each query row via quasi-Monte-Carlo.

fit

Fit pair copulas tree-by-tree along a fixed structure (returns them).

from_data

Fit a pure-PyTorch TLL vine on u.

from_structure

Builds a TorchVinecop from a structure (or matrix) and pair-copulas.

from_vinecop

Lifts a fitted Vinecop into a TorchVinecop.

get_pair_copula

Return the pair copula at (tree, edge).

inverse_rosenblatt

Inverse Rosenblatt transform: independent uniforms to dependent uniforms.

loglik

Total log-likelihood sum(log c(u)) of the vine at u.

pdf

Evaluate the vine-copula density c(u_1, ..., u_d).

plot

Plot the vine tree structure with networkx.

rosenblatt

Rosenblatt transform: dependent uniforms to independent uniforms.

select

Select an R-vine structure from data (array-agnostic Dissmann).

simulate

Simulate n samples from the fitted copula.