TorchBicop

class TorchBicop(grid_points=None, values=None, cache_integrals=True, norm_times=3, is_linear=False, device=None, dtype=torch.float64)

PyTorch evaluator for a bivariate copula stored as a density grid.

Torch counterpart of the non-parametric pair-copula path in Bicop (the Transformed Local Likelihood / tll family). The fitted density lives on an m x m grid in [0, 1]^2 and is evaluated by bilinear interpolation. Non-zero copula rotations are not supported — TLL pair-copulas always have rotation=0.

Parameters:
grid_pointsTensor, shape (m,), dtype float

Strictly increasing 1-D tensor of grid points on [0, 1] (the same grid is used along both axes). Endpoints are clipped to exactly 0 and 1 to avoid extrapolation.

valuesTensor, shape (m, m), dtype float

Density values on the tensor-product grid.

cache_integralsbool, default=True

If True, precompute cdf / hfunc1 / hfunc2 / hinv1 / hinv2 at every grid node so subsequent calls are a single bilinear lookup (~80–300x faster with a ~1e-3 mean IAE cost relative to the on-the-fly trapezoidal + bisection path). The caches are built once at construction from values and are not refreshed afterwards; mutating interp_grid.values in place on a cached instance is unsupported (rebuild a new TorchBicop instead).

norm_timesint, default=3

Number of margin-normalization rounds. Matches the Bicop TLL default. Pass 0 to skip when the grid already integrates to uniform margins.

is_linearbool, default=False

Internal flag selecting the linear-grid fast-path in the underlying InterpolationGrid2D. Set by from_data() when grid_type="linear"; users normally do not pass it directly.

devicetorch.device or None, default=None

Placement of the underlying tensors. None keeps them on the input’s device.

dtypetorch.dtype, default=torch.float64

Precision of the underlying tensors. torch.float64 mirrors the Bicop evaluation.

Methods

cdf(u[, x])

Evaluates the bivariate copula CDF.

flip()

Return the copula with its two arguments swapped (c'(u,v)=c(v,u)).

from_bicop(cop[, cache_integrals, device, dtype])

Lifts a fitted Bicop into a TorchBicop.

from_data(u[, controls, cache_integrals, ...])

Fits a bicop on pseudo-observations and wraps in a TorchBicop.

hfunc1(u[, x])

Evaluates the first h-function.

hfunc2(u[, x])

Evaluates the second h-function.

hinv1(u[, x])

Inverts hfunc1 w.r.t.

hinv2(u[, x])

Inverts hfunc2 w.r.t.

pdf(u[, x])

Evaluates the bivariate copula density c(u1, u2).

simulate([n, x, qrng, seeds])

Draws n joint samples from the fitted copula.

Attributes

call_super_init

dump_patches

supports_batched

TorchBicop exposes the grid/cache internals the batched vine path needs.

is_indep

training

Methods

__init__

cdf

Evaluates the bivariate copula CDF.

flip

Return the copula with its two arguments swapped (c'(u,v)=c(v,u)).

from_bicop

Lifts a fitted Bicop into a TorchBicop.

from_data

Fits a bicop on pseudo-observations and wraps in a TorchBicop.

hfunc1

Evaluates the first h-function.

hfunc2

Evaluates the second h-function.

hinv1

Inverts hfunc1 w.r.t.

hinv2

Inverts hfunc2 w.r.t.

loglik

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

pdf

Evaluates the bivariate copula density c(u1, u2).

plot

Plot the pair-copula density (contour or 3-D surface).

simulate

Draws n joint samples from the fitted copula.