Class GaussianCopula

java.lang.Object
com.quantfinlib.risk.GaussianCopula

public final class GaussianCopula extends Object
Gaussian and Student-t copula samplers — dependence separated from marginals, which is the entire point of copula modeling: "these five factors co-move like THIS" (the copula) is a different statement from "each factor's own distribution looks like THAT" (the marginals), and gluing arbitrary marginals to a chosen dependence structure is how joint risk scenarios get built.

Both samplers emit correlated UNIFORMS — feed them through your marginals' inverse CDFs. The Gaussian copula has NO tail dependence: joint extremes are asymptotically independent, the property famously blamed for pre-2008 CDO models. The Student-t copula with few degrees of freedom has strong SYMMETRIC tail dependence — extremes cluster — and converges to the Gaussian as df → ∞; the tests pin both behaviors. Correlation matrices are Cholesky-factored at construction (must be positive-definite — a borderline matrix fails loudly here, not as NaN samples later). Research lane; deterministic per seed via the caller-owned Random.

  • Constructor Summary

    Constructors
    Constructor
    Description
    GaussianCopula(double[][] correlation)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    void
    sample(Random rnd, double[] out, double[] scratch)
    One Gaussian-copula draw: out[i] are correlated uniforms in (0, 1).
    void
    sampleT(Random rnd, int df, double[] out, double[] scratch)
    One Student-t-copula draw with df degrees of freedom: the same correlated Gaussians divided by a shared √(χ²/df) — the SHARED shock is what creates tail dependence (one bad draw drags every factor's tail together).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GaussianCopula

      public GaussianCopula(double[][] correlation)
      Parameters:
      correlation - symmetric positive-definite correlation matrix
  • Method Details

    • sample

      public void sample(Random rnd, double[] out, double[] scratch)
      One Gaussian-copula draw: out[i] are correlated uniforms in (0, 1). Arrays are caller-owned; scratch must be a second array of the same length (kept separate so the sampler allocates nothing per draw).
    • sampleT

      public void sampleT(Random rnd, int df, double[] out, double[] scratch)
      One Student-t-copula draw with df degrees of freedom: the same correlated Gaussians divided by a shared √(χ²/df) — the SHARED shock is what creates tail dependence (one bad draw drags every factor's tail together). Uniforms come from the EXACT t-CDF (MathUtils.tCdf(double, double)); a moment-matched normal approximation here would distort exactly the tail quantiles this sampler exists to model (at df = 3 it puts ~37% excess mass below the 1% level).
    • dimension

      public int dimension()