25using Path = std::vector<std::pair<double, double>>;
28 std::cout << std::setprecision(17);
29 std::cout <<
"fit_ok = " << fit.
fit_ok <<
"\n";
30 std::cout <<
"ell_hat = " << fit.
ell_hat <<
"\n";
32 std::cout <<
"\np_hat:\n";
33 for (
const auto& [pid, val] : fit.p_hat) {
37 std::cout <<
"\neta_hat:\n";
38 for (
const auto& [pid, val] : fit.eta_hat) {
42 std::cout <<
"\np_hat_std:\n";
43 for (
const auto& [pid, val] : fit.p_hat_std) {
47 std::cout <<
"\np_correlations:\n";
48 for (
const auto& [pi, row] : fit.p_correlations) {
49 for (
const auto& [pj, corr] : row) {
52 <<
") = " << corr <<
"\n";
58 std::ofstream out(path);
59 out <<
"name,value,error\n";
61 for (
const auto& [pid, val] : fit.p_hat) {
69 << std::setprecision(17) << val <<
","
74void save_contour_csv(
const std::string& path,
75 const std::string& xname,
76 const std::string& yname,
77 const std::set<Path>& contour68,
78 const std::set<Path>& contour95) {
79 std::ofstream out(path);
80 out <<
"# x=" << xname <<
"\n";
81 out <<
"# y=" << yname <<
"\n";
82 out <<
"cl,path_id,x,y\n";
84 std::size_t path_id = 0;
85 for (
const auto& path_pts : contour68) {
86 for (
const auto& p : path_pts) {
87 out <<
"0.683," << path_id <<
","
88 << std::setprecision(17) << p.first <<
","
95 for (
const auto& path_pts : contour95) {
96 for (
const auto& p : path_pts) {
97 out <<
"0.95," << path_id <<
","
98 << std::setprecision(17) << p.first <<
","
113 hyp.
init(
"lha/si_input.flha", config_hyp);
115 auto oint = std::make_shared<ObservableInterface>();
119 std::shared_ptr<IStatParamOptimizerProxy> spop = std::make_shared<StatParamOptimizerProxy>();
121 auto model = std::make_shared<ObservableInterfaceProxy>(oint, spop);
129 std::vector<ParamId> p_specs = {
134 std::shared_ptr<INuisancePathsProvider> npp = std::make_shared<DefaultNuisancePathsProvider>();
139 std::make_shared<StatCorrelationProxy>(),
140 std::make_shared<StatParameterProxy>(),
141 std::make_shared<StatParamSourcesProxy>(),
142 std::make_shared<StatDependencyPruner>(),
143 std::make_shared<NuisanceReader>(npp),
147 auto t0 = std::chrono::steady_clock::now();
149 auto t1 = std::chrono::steady_clock::now();
150 std::cout <<
"Uncertainty pass done in "
151 << std::chrono::duration_cast<std::chrono::milliseconds>(t1 - t0).count()
155 auto t2 = std::chrono::steady_clock::now();
157 auto t3 = std::chrono::steady_clock::now();
159 std::cout <<
"\nMLE done in "
160 << std::chrono::duration_cast<std::chrono::milliseconds>(t3 - t2).count()
164 std::cerr <<
"[ERROR] MLE fit failed.\n";
168 print_fit_result(fit);
169 save_bestfit_csv(
"bestfit.csv", fit);
170 std::cout <<
"[INFO] Wrote bestfit.csv\n";
172 if (p_specs.size() == 2) {
176 std::array<double, 4> bounds = {0.05, 0.35, 0.05, 0.35};
180 const double z68_2d = std::sqrt(2.30);
181 const double z95_2d = std::sqrt(5.99);
191 std::cout <<
"first contour done" << std::endl;
193 auto t4 = std::chrono::steady_clock::now();
195 auto t5 = std::chrono::steady_clock::now();
197 std::cout <<
"\nContour done in "
198 << std::chrono::duration_cast<std::chrono::milliseconds>(t5 - t4).count()
203 std::cout <<
"[INFO] contour 68% paths = " << c68.level <<
"\n";
204 std::cout <<
"[INFO] contour 95% paths = " << c95.level <<
"\n";
213 std::cout <<
"[INFO] Wrote contours.csv\n";
@ AMS
Adaptive/marching-squares contour extractor.
@ MINUIT
Minuit contour extractor.
Default nuisance-configuration path provider.
Concrete reader for nuisance-parameter definition files.
Adapter from ObservableInterface to the statistical model interface.
High-level, user-facing entry point to compute flavor observables.
Concrete statistical proxy forwarding correlation queries to CorrelationProvider.
Statistics-layer adapter over the core DependencyPruner service.
Statistics-layer adapter for retrieving leaf parameter sources.
Statistics-layer proxy for read-only access to parameters and observables.
High-level orchestration of statistical uncertainty propagation, likelihood construction and fit scan...
@ CHI2_MC_COVARIANCE
Fast chi-square likelihood using MC theory covariance plus experimental covariance.
static IdOf< ObservableTag > to_id(Observables e)
Converts an enum value to an IdOf<Tag>.
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.
Coordinates statistical inputs, nuisance distributions, MLE fits and contour/scan computations.
Contour confidence_contour(ParamId p1, ParamId p2, double z, std::array< double, 4 > bounds, ContourOptions options)
Computes a two-dimensional confidence contour for the last successful MLE.
FitResultWithMaps compute_MLE(const std::vector< ParamId > &p_specs)
Computes the maximum-likelihood fit for a selected set of fit parameters.
std::vector< Point > Path
std::string to_string_any(const T &x)
double MLE_tol
Minimizer tolerance passed to the backend.
std::size_t MLE_max_iter
Maximum number of minimizer function calls/iterations.
StatisticLikelihoodMode likelihood_mode
Likelihood mode used by compute_MLE().
Runtime options controlling 2D contour computation.
ContourAlgorithm primary_contour_method
std::optional< ContourAlgorithm > fallback_contour_method
User-facing MLE result keyed by physics parameter identifiers.
std::map< ParamId, double > p_hat_std
Profiled standard deviations of fitted parameters.
double ell_hat
Minimum negative log-likelihood value.
bool fit_ok
True when the fit returned a usable parameter estimate.
Configuration object controlling model, input flags and optional MARTY resources.
Model model
Current model.
Composite identifier for a single parameter.
AdvancedStatisticConfig advanced
Advanced fit/pruning/covariance configuration.
std::size_t MC_draws
Number of accepted MC draws used for uncertainty propagation.