BicopLike

class BicopLike(*args, **kwargs)

Contract for a bivariate (optionally conditional) pair copula.

A pair copula maps pseudo-observations u of shape (n, 2) (in the unit square, clamped to [1e-10, 1 - 1e-10]) to a density (pdf), a distribution (cdf), the two conditional distributions hfunc1(u) = P(U2 <= u2 | U1 = u1) / hfunc2(u) = P(U1 <= u1 | U2 = u2) and their inverses (hinv1 / hinv2, inverting in the second / first argument), plus a sampler (simulate). The optional x of shape (n, k) carries conditioning variables: a conditional copula reads them, an unconditional one ignores them.

The easy way to satisfy this contract is to subclass BicopBase, which supplies hinv1 / hinv2 (numerical inversion) and simulate on top of pdf / hfunc1 / hfunc2. pyvinecopulib.core.Bicop and pyvinecopulib.torch.TorchBicop are the reference implementations.

Methods

cdf(u[, x])

Pair-copula distribution C(u) at each observation.

flip()

Return the pair copula with its two arguments swapped.

hfunc1(u[, x])

First h-function P(U2 <= u2 | U1 = u1).

hfunc2(u[, x])

Second h-function P(U1 <= u1 | U2 = u2).

hinv1(u[, x])

Inverse of hfunc1() in its second argument.

hinv2(u[, x])

Inverse of hfunc2() in its first argument.

pdf(u[, x])

Pair-copula density c(u) at each observation.

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

Draw n samples from the pair copula.

See also

pyvinecopulib.core.BicopBase

Canonical partial implementation to subclass.

pyvinecopulib.core.Bicop

The reference pair copula.

VinecopLike

The vine-level evaluator contract.

Examples

A minimal independence pair on NumPy — implement only the three primitives and inherit hinv1 / hinv2 / simulate / loglik / plot / __repr__ from BicopBase:

import numpy as np
from pyvinecopulib.core import BicopBase

class Independence(BicopBase[np.ndarray]):
  def pdf(self, u, x=None):
    return np.ones(u.shape[0])

  def hfunc1(self, u, x=None):
    return u[:, 1]

  def hfunc2(self, u, x=None):
    return u[:, 0]

cop = Independence()
cop.hinv1(np.array([[0.3, 0.7]]))   # -> array([0.7]) (numerical inverse)

Methods

__init__

cdf

Pair-copula distribution C(u) at each observation.

flip

Return the pair copula with its two arguments swapped.

hfunc1

First h-function P(U2 <= u2 | U1 = u1).

hfunc2

Second h-function P(U1 <= u1 | U2 = u2).

hinv1

Inverse of hfunc1() in its second argument.

hinv2

Inverse of hfunc2() in its first argument.

pdf

Pair-copula density c(u) at each observation.

simulate

Draw n samples from the pair copula.