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

Global chi-square likelihood with no explicit nuisance parameters. More...

#include <ChiSquaredLikelihood.h>

Inheritance diagram for ChiSquaredLikelihood:
Collaboration diagram for ChiSquaredLikelihood:

Public Member Functions

 ChiSquaredLikelihood (const ModelFn &model, std::shared_ptr< LikelihoodContext > ctx, std::size_t p_dim, RealMatrix covariance_inv)
 Constructs a chi-square likelihood.
 
double nll (const std::vector< double > &theta) const override
 Evaluates the chi-square negative log-likelihood.
 
std::size_t dim () const override
 Returns the total optimization dimension.
 
RealMatrix observable_curvature (const std::vector< double > &r) const override
 Returns the observable-space curvature matrix.
 
RealMatrix nuisance_curvature (const std::vector< double > &eta) const override
 Returns the nuisance-space curvature matrix.
 
- Public Member Functions inherited from BaseLikelihood
 BaseLikelihood (const ModelFn &model, std::shared_ptr< LikelihoodContext > ctx, size_t p_dim)
 Constructs a likelihood from a model and statistical context.
 
std::vector< fit_app::ParameterDefinitionget_param_defs () const override
 Returns all parameter definitions in likelihood-vector order.
 
void enable_debug_trace (std::size_t max_evals=25)
 Enables debug tracing for likelihood evaluations.
 
void disable_debug_trace ()
 Disables debug tracing of likelihood evaluations.
 
std::size_t p_dimension () const override
 Returns the dimension of the fitted-parameter block.
 
std::size_t eta_dimension () const override
 Returns the dimension of the nuisance-parameter block.
 
std::vector< double > central_p () const override
 Returns the central values of the fitted parameters.
 
std::vector< double > central_eta () const override
 Returns the central values of the nuisance parameters.
 
std::vector< double > predict (const std::vector< double > &p, const std::vector< double > &eta) const override
 
std::vector< double > residuals (const std::vector< double > &p, const std::vector< double > &eta) const override
 
double nll_from_split (const std::vector< double > &p, const std::vector< double > &eta) const override
 
- Public Member Functions inherited from ILikelihood
virtual ~ILikelihood ()=default
 Virtual destructor for safe polymorphic deletion.
 

Additional Inherited Members

- Protected Attributes inherited from BaseLikelihood
std::shared_ptr< LikelihoodContextctx
 Shared statistical context used by the likelihood.
 
ModelFn model
 Model function evaluated by the likelihood.
 
std::size_t p_dim
 Dimension of the fitted-parameter block.
 
bool debug_trace_enabled_ = false
 Whether evaluation debug tracing is enabled.
 
std::size_t debug_trace_max_evals_ = 0
 Maximum number of traced evaluations.
 
std::size_t debug_eval_count_ = 0
 Number of evaluations already traced.
 
bool debug_have_ref_theta_ = false
 Whether the debug reference parameter vector is set.
 
bool debug_have_ref_res_ = false
 Whether the debug reference residual vector is set.
 
std::vector< double > debug_ref_theta_
 First traced parameter vector used as debug reference.
 
std::vector< double > debug_ref_res_
 First traced residual vector used as debug reference.
 

Detailed Description

Global chi-square likelihood with no explicit nuisance parameters.

The optimization vector is interpreted as the parameter vector $p$ and the nuisance vector $\eta$ is always empty. The negative log-likelihood is evaluated as

\[
  \mathrm{NLL}(p)
  = \frac{1}{2}
    \left(f(p, \emptyset) - O_{\mathrm{exp}}\right)^\top
    C^{-1}
    \left(f(p, \emptyset) - O_{\mathrm{exp}}\right),
\]

where $f(p, \emptyset)$ is the model prediction, $O_{\mathrm{exp}}$ is the vector of experimental observations and $C^{-1}$ is the supplied inverse covariance matrix.

Note
This class derives from BaseLikelihood for API compatibility, but overrides the likelihood evaluation and reports a zero-dimensional nuisance space.

Definition at line 48 of file ChiSquaredLikelihood.h.

Constructor & Destructor Documentation

◆ ChiSquaredLikelihood()

ChiSquaredLikelihood::ChiSquaredLikelihood ( const ModelFn model,
std::shared_ptr< LikelihoodContext ctx,
std::size_t  p_dim,
RealMatrix  covariance_inv 
)

Constructs a chi-square likelihood.

Parameters
modelModel function mapping $(p, \eta)$ to observable predictions. For this likelihood, eta is expected to be empty.
ctxShared likelihood context containing observations and parameter definitions.
p_dimNumber of parameters of interest.
covariance_invInverse covariance matrix used in the quadratic form.

Definition at line 5 of file ChiSquaredLikelihood.cpp.

Member Function Documentation

◆ dim()

std::size_t ChiSquaredLikelihood::dim ( ) const
overridevirtual

Returns the total optimization dimension.

For this class, the dimension is equal to the number of parameters of interest because no nuisance parameters are explicitly represented.

Returns
Parameter-space dimension.

Reimplemented from BaseLikelihood.

Definition at line 63 of file ChiSquaredLikelihood.cpp.

◆ nll()

double ChiSquaredLikelihood::nll ( const std::vector< double > &  theta) const
overridevirtual

Evaluates the chi-square negative log-likelihood.

Parameters
thetaParameter vector. Its size must be exactly p_dim.
Returns
Finite NLL value when the model and covariance are valid; a large penalty value is returned when non-finite numerical values are encountered.
Exceptions
std::invalid_argumentif theta does not have dimension p_dim.

Reimplemented from BaseLikelihood.

Definition at line 15 of file ChiSquaredLikelihood.cpp.

◆ nuisance_curvature()

RealMatrix ChiSquaredLikelihood::nuisance_curvature ( const std::vector< double > &  eta) const
overridevirtual

Returns the nuisance-space curvature matrix.

Parameters
etaNuisance vector. Must be empty for this likelihood.
Returns
An empty $0 \times 0$ matrix.
Exceptions
std::invalid_argumentif eta is not empty.

Reimplemented from BaseLikelihood.

Definition at line 73 of file ChiSquaredLikelihood.cpp.

◆ observable_curvature()

RealMatrix ChiSquaredLikelihood::observable_curvature ( const std::vector< double > &  r) const
overridevirtual

Returns the observable-space curvature matrix.

Parameters
rResidual vector. The argument is accepted for interface compatibility and is not used because the curvature is constant.
Returns
The inverse covariance matrix supplied at construction.

Reimplemented from BaseLikelihood.

Definition at line 67 of file ChiSquaredLikelihood.cpp.


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