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

Multivariate distribution represented through marginals and a copula. More...

#include <JointDistribution.h>

Public Member Functions

 JointDistribution (std::unique_ptr< IMarginalDistribution > dist, std::unique_ptr< IDecomposition > decomp)
 
Vector generate (const Matrix &correlation) const
 
 JointDistribution (std::vector< std::unique_ptr< IMarginalDistribution > > marginals, std::unique_ptr< ICopula > copula)
 Constructs a joint distribution from marginals and a copula.
 
std::vector< std::vector< double > > sample (std::size_t n) const
 Draws multiple samples from the joint distribution.
 
std::vector< double > sample () const
 Draws a single sample from the joint distribution.
 
double logpdf (std::vector< double > x) const
 Evaluates the joint log-density at a given point.
 
RealMatrix curvature (std::vector< double > x) const
 Computes the negative Hessian of the joint log-density.
 
std::size_t dim ()
 Returns the dimension of the random vector.
 
std::vector< double > get_stds ()
 Returns the standard deviations of all marginals.
 

Public Attributes

 MarginalConfig
 
 CopulaConfig = Union[GaussianCopulaConfig, StudentTCopulaConfig]
 

Detailed Description

Multivariate distribution represented through marginals and a copula.

The class owns one marginal distribution per dimension and a copula defining the dependence structure between dimensions. Samples are generated by drawing correlated uniforms from the copula and mapping them through each marginal inverse CDF. Density evaluation combines marginal log-densities and the copula log-density.

Definition at line 145 of file correlated_rng.cpp.

Constructor & Destructor Documentation

◆ JointDistribution() [1/2]

JointDistribution::JointDistribution ( std::unique_ptr< IMarginalDistribution dist,
std::unique_ptr< IDecomposition decomp 
)
inline

Definition at line 147 of file correlated_rng.cpp.

◆ JointDistribution() [2/2]

JointDistribution::JointDistribution ( std::vector< std::unique_ptr< IMarginalDistribution > >  marginals,
std::unique_ptr< ICopula copula 
)

Constructs a joint distribution from marginals and a copula.

Ownership of all marginal distributions and the copula is transferred to the constructed object.

Parameters
marginalsMarginal distributions, one per random-vector component.
copulaCopula encoding the dependence structure.

Definition at line 19 of file JointDistribution.cpp.

Member Function Documentation

◆ curvature()

RealMatrix JointDistribution::curvature ( std::vector< double >  x) const

Computes the negative Hessian of the joint log-density.

The returned matrix corresponds to the local curvature matrix $-\nabla_x^2 \log f_X(x)$. Internally, marginal derivatives and copula derivatives are combined through the copula transformation.

Parameters
xPoint at which the curvature is evaluated.
Returns
Curvature matrix in the original variable space.
Exceptions
std::invalid_argumentif x does not match the distribution dimension.
std::runtime_errorif a non-finite intermediate value is detected.

Definition at line 64 of file JointDistribution.cpp.

◆ dim()

std::size_t JointDistribution::dim ( )

Returns the dimension of the random vector.

Returns
Number of marginal distributions.

Definition at line 169 of file JointDistribution.cpp.

◆ generate()

Vector JointDistribution::generate ( const Matrix correlation) const
inline

Definition at line 152 of file correlated_rng.cpp.

◆ get_stds()

std::vector< double > JointDistribution::get_stds ( )

Returns the standard deviations of all marginals.

Returns
Vector containing one standard deviation per marginal distribution.

Definition at line 173 of file JointDistribution.cpp.

◆ logpdf()

double JointDistribution::logpdf ( std::vector< double >  x) const

Evaluates the joint log-density at a given point.

The value is computed as the sum of marginal log-densities plus the copula log-density evaluated at the marginal CDF values:

\[
  \log f_X(x) = \sum_i \log f_i(x_i) + \log c(F_1(x_1), \ldots, F_d(x_d)).
\]

Parameters
xPoint at which the log-density is evaluated.
Returns
Joint log-density value.
Exceptions
std::invalid_argumentif x does not match the distribution dimension.

Definition at line 49 of file JointDistribution.cpp.

◆ sample() [1/2]

std::vector< double > JointDistribution::sample ( ) const

Draws a single sample from the joint distribution.

Returns
Random vector sampled from the distribution.

Definition at line 38 of file JointDistribution.cpp.

◆ sample() [2/2]

std::vector< std::vector< double > > JointDistribution::sample ( std::size_t  n) const

Draws multiple samples from the joint distribution.

Parameters
nNumber of samples to generate.
Returns
Matrix-like vector containing n samples, one sample per row.

Definition at line 25 of file JointDistribution.cpp.

Member Data Documentation

◆ CopulaConfig

JointDistribution.CopulaConfig = Union[GaussianCopulaConfig, StudentTCopulaConfig]

Definition at line 33 of file JointDistribution.py.

◆ MarginalConfig

JointDistribution.MarginalConfig
Initial value:
= Union[
FlatMarginalConfig,
GaussianMarginalConfig,
SplitGaussianMarginalConfig,
LikelihoodMarginalConfig,
]

Definition at line 27 of file JointDistribution.py.


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