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 factored at construction with PsdMatrices.choleskyPsd(double[][]): a positive semi-definite matrix (including a rank-deficient one) is accepted, an indefinite one fails here rather than as NaN samples later; repair an estimated matrix with PsdMatrices.nearestCorrelation(double[][]) first. Deterministic per seed via the caller-owned RandomGenerator.

  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    int
     
    void
    sample(RandomGenerator rnd, double[] out, double[] scratch)
    One Gaussian-copula draw: out[i] are correlated uniforms in (0, 1).
    void
    sampleT(RandomGenerator 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 Object

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

    • GaussianCopula

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

    • sample

      public void sample(RandomGenerator 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(RandomGenerator 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 (SpecialFunctions.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()