Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
MarginalFactory.cpp
Go to the documentation of this file.
1#include "MarginalFactory.h"
2
3std::unique_ptr<IMarginalDistribution> make(unsigned int seed, MarginalConfig cfg) {
4 return std::visit([seed](auto&& c) -> std::unique_ptr<IMarginalDistribution> {
5 using T = std::decay_t<decltype(c)>;
6 if constexpr (std::is_same_v<T, FlatMarginalCfg>)
7 return std::make_unique<FlatMarginal>(c.a, c.b, seed);
8 else if constexpr (std::is_same_v<T, GaussianMarginalCfg>)
9 return std::make_unique<GaussianMarginal>(c.mu, c.sigma, seed);
10 else if constexpr (std::is_same_v<T, SplitGaussianMarginalCfg>)
11 return std::make_unique<SplitGaussianMarginal>(c.mu, c.sigma_p, c.sigma_m, seed);
12 else if constexpr (std::is_same_v<T, LikelihoodMarginalCfg>)
13 return std::make_unique<LikelihoodMarginal>(c.values, c.weights, seed, true);
14 }, cfg);
15}
16
17std::unique_ptr<IMarginalDistribution> MarginalFactory::create(MarginalType name, MarginalConfig cfg, unsigned int seed) {
18 switch (name) {
20 return make(seed, cfg);
22 return make(seed, cfg);
24 return make(seed, cfg);
26 // MAJ
27 throw std::invalid_argument("LIKELIHOOD needs data (values, weights). Use createLikelihood(...).");
28 return make(seed, cfg);
29 default:
30 throw std::invalid_argument("Unknown distribution.");
31 }
32}
std::unique_ptr< ICopula > make(unsigned int seed, CopulaConfig cfg)
Internal helper constructing a copula from the active variant alternative.
std::unique_ptr< IMarginalDistribution > make(unsigned int seed, MarginalConfig cfg)
Factory for instantiating concrete marginal distributions.
MarginalType
Supported marginal-distribution families.
@ GAUSSIAN
Symmetric Gaussian marginal.
@ HALF_GAUSSIAN
Asymmetric / half-Gaussian-like marginal (currently mapped to split Gaussian logic).
@ LIKELIHOOD
Discrete likelihood-based marginal built from weighted support points.
@ FLAT
Uniform (flat) marginal on a finite interval.
static std::unique_ptr< IMarginalDistribution > create(MarginalType name, MarginalConfig cfg, unsigned int seed=std::random_device{}())
Creates a concrete marginal-distribution object.
double T(double x)
Wilson coefficient T(x).