Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
example_main.cpp
Go to the documentation of this file.
1#include <iostream>
2#include <random>
3#include <gsl/gsl_cdf.h>
4
5
6#include "BToMuMuToy.h"
7// #include "LinearAlgebra.h"
8#include "Statistics.h"
9#include "GaussianApprox.h"
10// #include "MonteCarloPredictor.h"
11#include "Fit.h"
12
13#include "StatisticInterface.h"
14
15int main() {
16// // Experimental inputs (vector + covariance)
17// const Vec Oexp{3.52e-9, 1.3e-10};
18// Matrix SigmaO = {
19// { (1.2e-10)*(1.2e-10), -0.2*(1.2e-10)*(0.2e-10) },
20// { -0.2*(1.2e-10)*(0.2e-10), (0.2e-10)*(0.2e-10) }
21// };
22
23
24// // Nuisances prior mean + covariance (diagonal here, but any SPD is ok)
25// const Vec eta_mean{0.194, 0.234, 0.0635, 0.04111, 0.00858};
26// Matrix SigmaEta = {
27// {0.010*0.010, 0,0,0,0},
28// {0, 0.010*0.010, 0,0,0},
29// {0,0, 0.014*0.014, 0,0},
30// {0,0,0, 0.00077*0.00077, 0},
31// {0,0,0,0, 0.00019*0.00019}
32// };
33
34
35// // Build contexts
36// auto SigmaO_chol = SPDMatrix::cholesky(SigmaO);
37// auto SigmaEta_chol = SPDMatrix::cholesky(SigmaEta);
38// LikelihoodContext ctx{Oexp, SigmaO_chol, eta_mean, SigmaEta_chol};
39
40
41// // Model
42// BToMuMuToy model;
43
44
45// // MC prediction + skewness check
46// MCPredictConfig cfg; cfg.draws = 10000; cfg.skew_abs_threshold = 0.2;
47// MonteCarloPredictor mc(model, eta_mean, SigmaEta, cfg);
48// std::mt19937 rng(12345);
49
50
51// const Vec p_test{-4.5, 0.0};
52// auto summaries = mc.summarize(p_test, rng);
53// std::cout << "Skewness[BR_s] = " << summaries[0].skew << " (ok=" << summaries[0].approx_ok << ")\n";
54// std::cout << "BR_s_untag = " << summaries[0].mu << " ± " << summaries[0].sigma << "\n";
55// std::cout << "BR_d = " << summaries[1].mu << " ± " << summaries[1].sigma << "\n";
56
57
58// // MLE and profiled likelihood
59// MLEstimator est(ctx, [&model](const Vec& p, const Vec& eta){ return model.predict(p, eta); });
60
61
62// const Vec p0{-4.5, 0.0};
63// const Vec eta0 = eta_mean; // good initial guess
64// FitResult fr = est.fit(p0, eta0);
65
66
67// std::cout << "MLE: C10=" << fr.p_hat[0] << ", Cp10=" << fr.p_hat[1]
68// << ", ell_hat=" << fr.ell_hat << "\n";
69
70
71// // Profile T(C10) with Cp10 fixed at 0, confidence interval @95%
72// auto T = [&](double c10){ return est.wilks_T(Vec{c10, 0.0}, fr, eta0); };
73
74
75// const double thr95 = gsl_cdf_chisq_Pinv(0.95, 1);
76// double c10_min=-7.0, c10_max=-1.0; int N=200;
77
78
79// double left=std::numeric_limits<double>::quiet_NaN();
80// double right=std::numeric_limits<double>::quiet_NaN();
81
82
83// double prevp=c10_min, prevT=T(prevp);
84// for (int i=1;i<=N;++i) {
85// double p = c10_min + (c10_max-c10_min)*i/double(N);
86// double t = T(p);
87// if (std::isnan(left) && (prevT-thr95)*(t-thr95) <= 0.0) left = prevp;
88// if ((prevT-thr95)*(t-thr95) <= 0.0) right = p;
89// prevp=p; prevT=t;
90// }
91// std::cout << "95% CI for C10 (Cp10=0 profiled): [" << left << ", " << right << "]\n";
92
94 HyperisoConfig confighyp;
95 confighyp.model = Model::SM;
96
97 hyp.init("lha/si_input.flha", confighyp);
98 StatisticConfig config;
99 std::shared_ptr<ObservableInterface> oint = std::make_shared<ObservableInterface>();
100 // config.obss = {
101 // {ObservableMapper::to_id(Observables::BR_BS_MUMU), QCDOrder::LO},
102 // {ObservableMapper::to_id(Observables::BR_BS_MUMU_UNTAG), QCDOrder::LO},
103 // {ObservableMapper::to_id(Observables::BR_BD_MUMU), QCDOrder::LO}
104 // };
105 StatisticInterface inter = StatisticInterface(config, oint);
106
107 std::map<BinnedObservableId, GaussianSummary> res = inter.compute_uncertainties();
108
109 for (auto elem : res) {
110 std::cout << elem.first.str() << " : " << elem.second << std::endl;
111 }
112 return 0;
113}
High-level maximum-likelihood fitting and confidence-contour API.
Utilities for summarizing observable samples with Gaussian approximations.
High-level facade for statistical computations.
Statistical helpers for Monte Carlo observable samples.
High-level interface to initialize and monitor the main framework configuration.
void init(const std::string &lhaFile, HyperisoConfig config)
Initializes Hyperiso using a LHA file and a full Config object.
std::map< BinnedObservableId, GaussianSummary > compute_uncertainties()
Computes Gaussian uncertainty summaries for all active observables.
int main()
Configuration object controlling model, input flags and optional MARTY resources.
Definition Config.h:24
Model model
Current model.
Definition Config.h:33