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 /tllfamily). The fitted density lives on anm x mgrid in[0, 1]^2and is evaluated by bilinear interpolation. Non-zero copula rotations are not supported — TLL pair-copulas always haverotation=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 exactly0and1to avoid extrapolation.- valuesTensor, shape (m, m), dtype float
Density values on the tensor-product grid.
- cache_integralsbool, default=True
If
True, precomputecdf/hfunc1/hfunc2/hinv1/hinv2at 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 fromvaluesand are not refreshed afterwards; mutatinginterp_grid.valuesin place on a cached instance is unsupported (rebuild a newTorchBicopinstead).- norm_timesint, default=3
Number of margin-normalization rounds. Matches the
BicopTLL default. Pass0to 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 byfrom_data()whengrid_type="linear"; users normally do not pass it directly.- devicetorch.device or None, default=None
Placement of the underlying tensors.
Nonekeeps them on the input’s device.- dtypetorch.dtype, default=torch.float64
Precision of the underlying tensors.
torch.float64mirrors theBicopevaluation.
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
Bicopinto aTorchBicop.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
njoint samples from the fitted copula.Attributes
TorchBicop exposes the grid/cache internals the batched vine path needs.
Methods
Evaluates the bivariate copula CDF.
Return the copula with its two arguments swapped (
c'(u,v)=c(v,u)).Lifts a fitted
Bicopinto aTorchBicop.Fits a bicop on pseudo-observations and wraps in a
TorchBicop.Evaluates the first h-function.
Evaluates the second h-function.
Inverts hfunc1 w.r.t.
Inverts hfunc2 w.r.t.
Total log-likelihood
sum(log c(u))of the pair atu.Evaluates the bivariate copula density
c(u1, u2).Plot the pair-copula density (contour or 3-D surface).
Draws
njoint samples from the fitted copula.