Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
StatisticInterface.cpp
Go to the documentation of this file.
2
4
5StatisticInterface::StatisticInterface(StatisticConfig config, std::shared_ptr<ObservableInterface> oi_) {
6 std::shared_ptr<ObservableInterface> oi = oi_;
7 std::shared_ptr<IStatParamOptimizerProxy> spop = std::make_shared<StatParamOptimizerProxy>();
8 std::shared_ptr<IModel> oia = std::make_shared<ObservableInterfaceProxy>(oi, spop);
9 std::shared_ptr<IStatCorrelationProxy> pscp = std::make_shared<StatCorrelationProxy>();
10 std::shared_ptr<IStatParameterProxy> pspp = std::make_shared<StatParameterProxy>();
11 std::shared_ptr<IStatSourcesProxy> sp = std::make_shared<StatParamSourcesProxy>();
12 std::shared_ptr<IStatDependencyPruner> sdp = std::make_shared<StatDependencyPruner>();
13 std::shared_ptr<INuisancePathsProvider> npp =
14 std::make_shared<RuntimeNuisancePathsAdapter>();
15 std::shared_ptr<INuisanceReader> nr = std::make_shared<NuisanceReader>(npp);
16
17 manager = std::make_shared<StatisticManager>(config, oia, pscp, pspp, sp, sdp, nr, spop);
18
19 manager->select_experiments_all();
20 manager->update_cache();
21}
22
23void StatisticInterface::select_experiment(const std::string& experiment) {
24 manager->select_experiment(experiment);
25 manager->update_cache();
26}
27
28void StatisticInterface::select_experiments(const std::vector<std::string>& experiments) {
29 manager->select_experiments(experiments);
30 manager->update_cache();
31}
32
34 manager->select_experiments_all();
35 manager->update_cache();
36}
37
39 return manager->has_experiment_selection();
40}
41
42std::set<std::string> StatisticInterface::selected_experiments() const {
43 return manager->selected_experiments();
44}
45
47 const std::vector<ExperimentObs>& observables
48) {
49 manager->select_experiment_observables(observables);
50 manager->update_cache();
51}
52
54 manager->select_experiment_observables_all();
55 manager->update_cache();
56}
57
59 return manager->has_experiment_observable_selection();
60}
61
63 return manager->selected_experiment_observables();
64}
65
66std::map<BinnedObservableId, GaussianSummary> StatisticInterface::compute_uncertainties() {
67 return manager->compute_uncertainties();
68}
69
71 return manager->get_all_obss_deps();
72}
73
75 return manager->compute_uncertainties_and_sampling();
76}
77
78FitResultWithMaps StatisticInterface::compute_MLE(const std::vector<ParamId>& p_specs) {
79 return manager->compute_MLE(p_specs);
80}
81
82Contour StatisticInterface::compute_confidence_contour(ParamId p1, ParamId p2, double z, std::array<double, 4> bounds, ContourOptions options) {
83 return manager->confidence_contour(p1, p2, z, bounds, options);
84}
85
87 manager->reload_nuisance_specs();
88 manager->update_cache();
89}
90
91void StatisticInterface::set_nuisance_user_file(const std::string& user_yaml_path) {
92 manager->set_nuisance_user_file(user_yaml_path);
93 manager->update_cache();
94}
95
97 manager->clear_nuisance_user_file();
98 manager->update_cache();
99}
100
101void StatisticInterface::prepare_likelihood_for_scan(const std::vector<ParamId>& p_specs) {
102 manager->prepare_likelihood_for_scan(p_specs);
103}
104
105void StatisticInterface::set_manual_scan_point(const std::map<ParamId, double>& p_hat,
106 const std::map<ParamId, double>& eta_hat) {
107 manager->set_manual_scan_point(p_hat, eta_hat);
108}
109
111 ParamId p1,
112 ParamId p2,
113 double x_half_width,
114 double y_half_width,
115 std::size_t nx,
116 std::size_t ny
117) const {
118 return manager->scan_likelihood_around_current_point(
119 p1, p2, x_half_width, y_half_width, nx, ny
120 );
121}
122
124 const LikelihoodScanGrid& grid) const {
125 manager->save_likelihood_scan_csv(path, grid);
126}
127
128void StatisticInterface::update_cache(const std::vector<ParamId>& p_specs) {
129 manager->update_cache(p_specs);
130}
131
132std::map<ParamId, double>StatisticInterface:: get_all_obss_deps() {
133 return manager->get_all_obss_deps();
134}
135
136std::map<ParamId, double> StatisticInterface::get_p_specs(const std::vector<ParamId>& p_specs) {
137 return manager->get_p_specs(p_specs);
138}
139
140std::map<ParamId, std::map<ParamId, double>> StatisticInterface::get_all_correlations() {
141 return manager->get_all_correlations();
142}
143
144std::map<ExperimentObs, std::map<ExperimentObs, double>> StatisticInterface::get_all_obs_correlations() {
145 return manager->get_all_obs_correlations();
146}
147
148std::map<ExperimentObs, double> StatisticInterface::get_obs_exp() {
149 return manager->get_obs_exp();
150}
151
153 manager->print_cache();
154}
Bridges active Core runtime paths to Statistic nuisance-file lookup.
High-level facade for statistical computations.
MCResult compute_uncertainties_and_sampling()
Runs uncertainty propagation and returns both samples and summaries.
std::map< ParamId, double > get_p_specs(const std::vector< ParamId > &p_specs)
std::map< BinnedObservableId, GaussianSummary > compute_uncertainties()
Computes Gaussian uncertainty summaries for all active observables.
void update_cache(const std::vector< ParamId > &p_specs=std::vector< ParamId >())
Refreshes the cached statistical inputs.
std::set< ExperimentObs > selected_experiment_observables() const
Returns the active exact experimental-observable selection.
void select_experiments_all()
Clears any experiment restriction and uses all experiments.
std::map< ParamId, std::map< ParamId, double > > get_all_correlations()
void print_cache()
Prints the current manager cache for diagnostics.
Contour compute_confidence_contour(ParamId p1, ParamId p2, double z, std::array< double, 4 > bounds, ContourOptions options)
Computes a two-dimensional confidence contour.
std::map< ExperimentObs, std::map< ExperimentObs, double > > get_all_obs_correlations()
void set_manual_scan_point(const std::map< ParamId, double > &p_hat, const std::map< ParamId, double > &eta_hat)
Manually sets the central point used by likelihood scans.
void reload_nuisance_specs()
Reloads default and user nuisance specifications.
std::map< ExperimentObs, double > get_obs_exp()
bool has_experiment_observable_selection() const noexcept
Tests whether an exact experimental-observable selection is active.
void clear_nuisance_user_file()
Restores the default user nuisance file lookup.
void set_nuisance_user_file(const std::string &user_yaml_path)
Uses a specific user nuisance configuration file.
FitResultWithMaps compute_MLE(const std::vector< ParamId > &p_specs)
Runs a maximum-likelihood fit for the requested fit parameters.
void save_likelihood_scan_csv(const std::string &path, const LikelihoodScanGrid &grid) const
Saves a likelihood scan grid as a CSV file.
void prepare_likelihood_for_scan(const std::vector< ParamId > &p_specs)
Builds and stores the likelihood objects required for scan calls.
bool has_experiment_selection() const noexcept
Tests whether an experiment selection is active.
void select_experiment(const std::string &experiment)
Restricts the analysis to a single experiment.
void select_experiment_observables(const std::vector< ExperimentObs > &observables)
Restricts the analysis to exact experiment/observable/bin entries.
void select_experiment_observables_all()
Clears any exact experimental-observable restriction.
LikelihoodScanGrid scan_likelihood_around_current_point(ParamId p1, ParamId p2, double x_half_width, double y_half_width, std::size_t nx, std::size_t ny) const
Evaluates a rectangular likelihood scan around the current point.
std::set< std::string > selected_experiments() const
Returns the currently selected experiments.
std::map< ParamId, double > get_active_observable_dependencies()
Returns the nuisance/input parameters currently seen by the statistical manager.
void select_experiments(const std::vector< std::string > &experiments)
Restricts the analysis to a set of experiments.
Runtime options controlling 2D contour computation.
Definition Fit.h:93
Output of a contour extraction algorithm.
User-facing MLE result keyed by physics parameter identifiers.
Regular two-dimensional grid of likelihood-scan evaluations.
Composite identifier for a single parameter.
Definition ParamID.h:57