Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
WithGaussianConstraints.cpp
Go to the documentation of this file.
2
4 std::shared_ptr<ILikelihood> base,
5 std::shared_ptr<JointDistribution> constraints_dist,
6 std::vector<std::size_t> constrained_params)
7 : base(std::move(base)),
8 constraints_dist(std::move(constraints_dist)),
9 constrained_params(std::move(constrained_params))
10{}
11
12double WithGaussianConstraints::nll(const std::vector<double> &theta) const {
13 double base_nll = this->base->nll(theta);
14
15 std::vector<double> constrained_vals;
16 for (std::size_t i : this->constrained_params) {
17 constrained_vals.emplace_back(theta[i]);
18 }
19
20 double constraint_nll = -this->constraints_dist->logpdf(constrained_vals);
21
22 return base_nll + constraint_nll;
23}
24
25std::vector<fit_app::ParameterDefinition> WithGaussianConstraints::get_param_defs() const {
26 return base->get_param_defs();
27}
28
29std::size_t WithGaussianConstraints::dim() const {
30 return this->base->dim();
31}
Likelihood decorator adding an external Gaussian constraint term.
WithGaussianConstraints(std::shared_ptr< ILikelihood > base, std::shared_ptr< JointDistribution > constraints_dist, std::vector< std::size_t > constrained_params)
Constructs a constrained likelihood wrapper.
double nll(const std::vector< double > &theta) const override
Evaluates the constrained negative log-likelihood.
std::vector< fit_app::ParameterDefinition > get_param_defs() const override
Returns the metadata describing the likelihood parameters.
std::size_t dim() const override
Returns the total dimension of the parameter vector.
Hash specialization for SymbolId<Tag>.
Definition BlockName.h:353