Skip to main content
Pro Feature. Requires a Pro or Ultra subscription. Get started at api.mathematicalcompany.com
What is this? Correlation only captures linear dependence. Copulas model the full dependence structure between two markets - including whether they crash together (tail dependence) or only co-move in normal times. Use copulas to understand and simulate how pairs of prediction markets behave during extreme events.

Copula Dependence

Horizon implements four bivariate copula families for modeling dependence between prediction markets. Copulas separate the marginal distributions from the dependence structure, allowing you to capture tail dependence, asymmetric co-movement, and non-linear relationships that linear correlation misses. All computation runs in Rust via PyO3.

4 Copula Families

Gaussian, Clayton, Gumbel, and Frank copulas covering symmetric, lower-tail, upper-tail, and no-tail dependence.

Automatic Selection

best_copula() fits all families and selects the one with highest log-likelihood.

Sampling

Generate correlated uniform samples from any fitted copula for Monte Carlo simulation.

Pipeline Integration

hz.copula_dependence() monitors pairwise dependence in real time within hz.run().

Why Copulas?

Linear correlation captures only one dimension of dependence. In prediction markets, outcomes often exhibit:
  • Tail dependence: two markets crash together more often than they rally together (Clayton copula)
  • Upper tail dependence: markets resolve YES simultaneously (Gumbel copula)
  • Symmetric dependence: markets move together uniformly across quantiles (Gaussian copula)
  • No tail dependence: markets are linked but extreme co-movements are rare (Frank copula)
Copulas model all of these patterns. By fitting the right copula family, you get accurate joint probability estimates for risk management, portfolio construction, and arbitrage detection.
All copula functions operate on uniform marginals (values in [0, 1]). Use hz.rank_transform() to convert raw price series to pseudo-uniform observations before fitting.

API

CopulaFamily Enum

hz.rank_transform

Convert raw observation series to pseudo-uniform marginals using the empirical CDF (rank transform).
Returns (list[float], list[float]): pseudo-uniform marginals.

hz.fit_copula

Fit a specific copula family to bivariate uniform data using maximum likelihood estimation.
Returns a CopulaFit.

hz.best_copula

Fit all four copula families and return the one with the lowest AIC (best fit).
Returns a CopulaFit for the best-fitting family.

CopulaFit Type

hz.copula_sample

Generate correlated samples from a fitted copula.
Returns list[(float, float)].

hz.copula_cdf

Evaluate the copula CDF at a given point (u, v).
Returns float: the copula CDF value C(u, v).

Pipeline Integration

hz.copula_dependence

Pipeline function that fits copulas between market pairs each cycle and injects results into ctx.params["copula"].
The ctx.params["copula"] dict contains:

Mathematical Background

Every joint distribution F(x, y) can be decomposed as F(x, y) = C(F_X(x), F_Y(y)) where C is a copula and F_X, F_Y are the marginal CDFs. The copula C captures all dependence information independent of the marginals. This separation allows modeling marginals and dependence separately.
Gaussian: C(u,v) is derived from the bivariate normal distribution with correlation rho. No tail dependence regardless of correlation strength.Clayton: C(u,v) = (u^(-theta) + v^(-theta) - 1)^(-1/theta). Lower tail dependence coefficient = 2^(-1/theta). Suitable for modeling crash co-movement.Gumbel: C(u,v) = exp(-((-log u)^theta + (-log v)^theta)^(1/theta)). Upper tail dependence coefficient = 2 - 2^(1/theta). Suitable for modeling joint resolution events.Frank: C(u,v) involves the debye function. No tail dependence (similar to Gaussian) but with different dependence structure in the body of the distribution.
best_copula() fits all four families by maximum likelihood and selects the one with the lowest AIC (Akaike Information Criterion). AIC = -2 * log_likelihood + 2 * k, where k is the number of parameters (always 1 for these bivariate copulas). Lower AIC indicates a better balance of fit and parsimony.
Each copula family has a closed-form relationship between its parameter and Kendall’s tau:
  • Gaussian: tau = (2/pi) * arcsin(rho)
  • Clayton: tau = theta / (theta + 2)
  • Gumbel: tau = 1 - 1/theta
  • Frank: tau = 1 - 4/theta * (1 - D_1(theta)) where D_1 is the first Debye function
Kendall’s tau provides a copula-invariant measure of dependence strength, making it easier to compare across families.