Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
StudentTCopula Class Reference

Student-t copula with correlation matrix and degrees of freedom. More...

#include <StudentTCopula.h>

Inheritance diagram for StudentTCopula:
Collaboration diagram for StudentTCopula:

Public Member Functions

 StudentTCopula (unsigned int seed, RealMatrix R, int nu)
 Constructs a Student-t copula.
 
std::vector< std::vector< double > > sample_u (std::size_t n) override
 Draws multiple samples from the copula.
 
std::vector< double > sample_u () override
 Draws a single sample from the copula.
 
double log_density (std::vector< double > u) override
 Evaluates the log-density of the copula at a point in the unit cube.
 
RealMatrix dlog_density (std::vector< double > u) override
 Computes the gradient of the Student-t copula log-density.
 
RealMatrix ddlog_density (std::vector< double > u) override
 Computes the Hessian of the Student-t copula log-density.
 
LogDensityDiff log_c_dc_ddc (std::vector< double > u) override
 Computes the log-density and derivative bundle.
 
- Public Member Functions inherited from GenericCopula
 GenericCopula (unsigned int seed=std::random_device{}())
 Constructs the copula base with a seeded random engine.
 
- Public Member Functions inherited from ICopula
virtual ~ICopula ()=default
 Virtual destructor.
 

Additional Inherited Members

- Protected Attributes inherited from GenericCopula
const gsl_rng_type * rng_tp {gsl_rng_mt19937}
 
gsl_rng_sptr eng_ {nullptr, &gsl_rng_free}
 GSL RNG type used by the copula.
 

Detailed Description

Student-t copula with correlation matrix and degrees of freedom.

Internally, the copula stores:

  • a PSD-corrected correlation matrix,
  • its inverse,
  • its Cholesky factor,
  • its log-determinant,
  • and the number of degrees of freedom nu.

Sampling:

  • draw a multivariate Gaussian latent vector,
  • correlate it,
  • rescale by a chi-square variable to obtain a Student-t latent vector,
  • apply the univariate Student-t CDF component-wise.

Density evaluation uses the usual Student-t copula formula based on:

  • the multivariate Student-t density,
  • divided by the product of marginal Student-t densities.

Definition at line 62 of file StudentTCopula.h.

Constructor & Destructor Documentation

◆ StudentTCopula()

StudentTCopula::StudentTCopula ( unsigned int  seed,
RealMatrix  R,
int  nu 
)
explicit

Constructs a Student-t copula.

The correlation matrix is projected to the nearest PSD correlation matrix.

Parameters
seedSeed for the RNG.
RCorrelation matrix.
nuDegrees of freedom. Must be at least 2.
Exceptions
std::invalid_argumentif nu < 2.

Definition at line 3 of file StudentTCopula.cpp.

Member Function Documentation

◆ ddlog_density()

RealMatrix StudentTCopula::ddlog_density ( std::vector< double >  u)
overridevirtual

Computes the Hessian of the Student-t copula log-density.

Parameters
uUniform vector in $(0,1)^d$.
Returns
Matrix containing second derivatives with respect to u.

Implements ICopula.

Definition at line 70 of file StudentTCopula.cpp.

◆ dlog_density()

RealMatrix StudentTCopula::dlog_density ( std::vector< double >  u)
overridevirtual

Computes the gradient of the Student-t copula log-density.

Parameters
uUniform vector in $(0,1)^d$.
Returns
Column matrix containing $\nabla_u \log c(u)$.

Implements ICopula.

Definition at line 64 of file StudentTCopula.cpp.

◆ log_c_dc_ddc()

LogDensityDiff StudentTCopula::log_c_dc_ddc ( std::vector< double >  u)
inlineoverridevirtual

Computes the log-density and derivative bundle.

Parameters
uUniform vector in $(0,1)^d$.
Returns
Aggregated log-density derivative information. The current inline implementation returns a default-constructed LogDensityDiff.
Todo:
Implement the combined Student-t copula derivative evaluation.

Implements ICopula.

Definition at line 123 of file StudentTCopula.h.

◆ log_density()

double StudentTCopula::log_density ( std::vector< double >  u)
overridevirtual

Evaluates the log-density of the copula at a point in the unit cube.

Parameters
uPoint in $[0,1]^d$.
Returns
$\log c(u)$, where $c$ is the copula density.

The implementation:

  • transforms $u_i$ to Student-t quantiles,
  • evaluates the multivariate Student-t log-density,
  • subtracts the sum of marginal log-densities, yielding the copula log-density.

Implements ICopula.

Definition at line 44 of file StudentTCopula.cpp.

◆ sample_u() [1/2]

std::vector< double > StudentTCopula::sample_u ( )
overridevirtual

Draws a single sample from the copula.

Returns
One dependent uniform sample in $[0,1]^d$.

Implements ICopula.

Definition at line 24 of file StudentTCopula.cpp.

◆ sample_u() [2/2]

std::vector< std::vector< double > > StudentTCopula::sample_u ( std::size_t  n)
overridevirtual

Draws multiple samples from the copula.

Each sample is a vector of uniform variates on $[0,1]$ whose dependence is governed by the copula.

Parameters
nNumber of samples to generate.
Returns
A vector of samples, each of dimension equal to the copula dimension.

Implements ICopula.

Definition at line 14 of file StudentTCopula.cpp.


The documentation for this class was generated from the following files: