|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
Coordinates statistical inputs, nuisance distributions, MLE fits and contour/scan computations. More...
#include <StatisticManager.h>
Public Member Functions | |
| StatisticManager (StatisticConfig config, std::shared_ptr< IModel > obs_int, std::shared_ptr< IStatCorrelationProxy > pscp, std::shared_ptr< IStatParameterProxy > pspp, std::shared_ptr< IStatSourcesProxy > sp, std::shared_ptr< IStatDependencyPruner > dp, std::shared_ptr< INuisanceReader > nuisance_reader, std::shared_ptr< IStatParamOptimizerProxy > spop) | |
| Constructs a statistic manager and initializes observable/nuisance state. | |
| std::vector< std::unique_ptr< IMarginalDistribution > > | build_nuisance_marginal_distributions () |
| Builds marginal distributions for all currently cached nuisances. | |
| std::unique_ptr< JointDistribution > | build_nuisance_distribution () |
| Builds the joint nuisance distribution from cached nuisance marginals and correlations. | |
| std::unique_ptr< JointDistribution > | build_exp_data_distribution () |
| Builds the joint experimental-data distribution from cached observables and correlations. | |
| void | reload_nuisance_specs () |
| Reloads default and user nuisance specifications and invalidates fit state. | |
| void | set_nuisance_user_file (const fs::path &user_yaml_path) |
| Selects a custom user nuisance-definition file and reloads nuisance specifications. | |
| void | clear_nuisance_user_file () |
| Clears the custom user nuisance file and reloads the default configured user file. | |
| const NuisanceRegistry & | default_nuisance_specs () const |
| const NuisanceRegistry & | user_nuisance_specs () const |
| const NuisanceRegistry & | merged_nuisance_specs () const |
| std::map< BinnedObservableId, GaussianSummary > | compute_uncertainties () |
| Computes Gaussian summaries for MC-propagated observable uncertainties. | |
| MCResult | compute_uncertainties_and_sampling () |
| Runs MC uncertainty propagation and returns both samples and summaries. | |
| FitResultWithMaps | compute_MLE (const std::vector< ParamId > &p_specs) |
| Computes the maximum-likelihood fit for a selected set of fit parameters. | |
| 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. | |
| void | prepare_likelihood_for_scan (const std::vector< ParamId > &p_specs) |
| Prepares a likelihood object for manual scans without running a full MLE. | |
| void | set_manual_scan_point (const std::map< ParamId, double > &p_hat, const std::map< ParamId, double > &eta_hat) |
| Sets the reference point used by subsequent likelihood scans. | |
| 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 the current likelihood on a regular 2D grid around the active reference point. | |
| void | save_likelihood_scan_csv (const std::string &path, const LikelihoodScanGrid &grid) const |
| Writes a likelihood scan grid to a CSV file. | |
| void | update_cache (const std::vector< ParamId > &p_specs=std::vector< ParamId >()) |
| Updates the full statistical cache for the selected fit parameters. | |
| void | select_experiment (const std::string &experiment) |
| Restricts subsequent statistics to a single experiment name. | |
| void | select_experiments (const std::set< std::string > &experiments) |
| Restricts subsequent statistics to the provided set of experiment names. | |
| void | select_experiments (const std::vector< std::string > &experiments) |
| Restricts subsequent statistics to the provided vector of experiment names. | |
| void | select_experiments_all () |
| Clears any experiment selection and uses all available experiments. | |
| bool | has_experiment_selection () const noexcept |
| std::set< std::string > | selected_experiments () const |
| void | select_experiment_observables (const std::set< ExperimentObs > &observables) |
| Restricts subsequent statistics to an explicit list of experimental measurements. | |
| void | select_experiment_observables (const std::vector< ExperimentObs > &observables) |
| Vector overload for select_experiment_observables. | |
| void | select_experiment_observables_all () |
| Clears the explicit experimental-observable selection. | |
| bool | has_experiment_observable_selection () const noexcept |
| std::set< ExperimentObs > | selected_experiment_observables () const |
| std::map< ParamId, double > | get_all_obss_deps () |
| Selects all nuisance dependencies relevant to the current observable set. | |
| std::map< ParamId, double > | get_p_specs (const std::vector< ParamId > &p_specs) |
| Resolves initial fit-parameter values from the parameter proxy. | |
| std::map< ParamId, std::map< ParamId, double > > | get_all_correlations () |
| std::map< ExperimentObs, std::map< ExperimentObs, double > > | get_all_obs_correlations () |
| std::map< ExperimentObs, double > | get_obs_exp () |
| void | print_cache () |
| Prints the current internal cache to standard output for debugging. | |
Coordinates statistical inputs, nuisance distributions, MLE fits and contour/scan computations.
The manager owns no low-level physics data itself. Instead, it delegates model predictions to IModel, parameter values and uncertainties to the statistical proxies, and nuisance metadata to INuisanceReader. Its role is to assemble those sources into the distributions and likelihoods required by the fitting workflow.
Definition at line 210 of file StatisticManager.h.
| StatisticManager::StatisticManager | ( | StatisticConfig | config, |
| std::shared_ptr< IModel > | obs_int, | ||
| std::shared_ptr< IStatCorrelationProxy > | pscp, | ||
| std::shared_ptr< IStatParameterProxy > | pspp, | ||
| std::shared_ptr< IStatSourcesProxy > | sp, | ||
| std::shared_ptr< IStatDependencyPruner > | dp, | ||
| std::shared_ptr< INuisanceReader > | nuisance_reader, | ||
| std::shared_ptr< IStatParamOptimizerProxy > | spop | ||
| ) |
Constructs a statistic manager and initializes observable/nuisance state.
The constructor computes the model observables once, loads default and user nuisance specifications, merges them, and invalidates any previous fit state.
| config | Runtime statistical configuration. |
| obs_int | Model used to compute and predict observables. |
| pscp | Correlation proxy for parameters and observables. |
| pspp | Parameter proxy providing central values and uncertainties. |
| sp | Source proxy used to resolve leaf dependencies. |
| dp | Dependency pruner used to detach fit parameters from nuisance dependencies. |
| nuisance_reader | Reader used to load default/user nuisance specifications. |
| spop | Optional/statistical parameter optimizer proxy used by the surrounding workflow. |
| std::invalid_argument | if nuisance_reader is null. |
Definition at line 514 of file StatisticManager.cpp.
| std::unique_ptr< JointDistribution > StatisticManager::build_exp_data_distribution | ( | ) |
Builds the joint experimental-data distribution from cached observables and correlations.
Definition at line 601 of file StatisticManager.cpp.
| std::unique_ptr< JointDistribution > StatisticManager::build_nuisance_distribution | ( | ) |
Builds the joint nuisance distribution from cached nuisance marginals and correlations.
Definition at line 573 of file StatisticManager.cpp.
| std::vector< std::unique_ptr< IMarginalDistribution > > StatisticManager::build_nuisance_marginal_distributions | ( | ) |
Builds marginal distributions for all currently cached nuisances.
Definition at line 541 of file StatisticManager.cpp.
| void StatisticManager::clear_nuisance_user_file | ( | ) |
Clears the custom user nuisance file and reloads the default configured user file.
Definition at line 1284 of file StatisticManager.cpp.
| FitResultWithMaps StatisticManager::compute_MLE | ( | const std::vector< ParamId > & | p_specs | ) |
Computes the maximum-likelihood fit for a selected set of fit parameters.
The likelihood backend is selected through StatisticConfig::likelihood_mode. This method also updates the internal state required by contour and scan methods.
| p_specs | Ordered list of fit-parameter identifiers. |
| std::invalid_argument | if p_specs resolves to an empty fit-parameter set. |
Definition at line 683 of file StatisticManager.cpp.
| std::map< BinnedObservableId, GaussianSummary > StatisticManager::compute_uncertainties | ( | ) |
Computes Gaussian summaries for MC-propagated observable uncertainties.
Definition at line 642 of file StatisticManager.cpp.
| MCResult StatisticManager::compute_uncertainties_and_sampling | ( | ) |
Runs MC uncertainty propagation and returns both samples and summaries.
Definition at line 668 of file StatisticManager.cpp.
| Contour StatisticManager::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.
| p1 | First fit parameter. |
| p2 | Second fit parameter. |
| z | Gaussian-equivalent significance level. |
| bounds | Bounds as {xmin, xmax, ymin, ymax}. |
| options | Contour and profiling options. |
| std::runtime_error | if no MLE has been computed. |
| std::invalid_argument | if the parameters are not part of the last fit or are identical. |
Definition at line 949 of file StatisticManager.cpp.
|
inline |
Definition at line 273 of file StatisticManager.h.
Definition at line 1700 of file StatisticManager.cpp.
| std::map< ExperimentObs, std::map< ExperimentObs, double > > StatisticManager::get_all_obs_correlations | ( | ) |
Definition at line 1707 of file StatisticManager.cpp.
| std::map< ParamId, double > StatisticManager::get_all_obss_deps | ( | ) |
Selects all nuisance dependencies relevant to the current observable set.
Definition at line 1382 of file StatisticManager.cpp.
| std::map< ExperimentObs, double > StatisticManager::get_obs_exp | ( | ) |
Definition at line 1715 of file StatisticManager.cpp.
Resolves initial fit-parameter values from the parameter proxy.
| p_specs | Fit-parameter identifiers. |
Definition at line 1693 of file StatisticManager.cpp.
|
noexcept |
Definition at line 2045 of file StatisticManager.cpp.
|
noexcept |
Definition at line 1996 of file StatisticManager.cpp.
|
inline |
Definition at line 279 of file StatisticManager.h.
| void StatisticManager::prepare_likelihood_for_scan | ( | const std::vector< ParamId > & | p_specs | ) |
Prepares a likelihood object for manual scans without running a full MLE.
The current central values of the fit parameters and nuisance parameters are stored as the default scan reference point. A later call to compute_MLE(...) or set_manual_scan_point(...) overrides this reference.
| p_specs | Ordered list of fit parameters to expose in the scan. |
Definition at line 1733 of file StatisticManager.cpp.
| void StatisticManager::print_cache | ( | ) |
Prints the current internal cache to standard output for debugging.
Definition at line 1172 of file StatisticManager.cpp.
| void StatisticManager::reload_nuisance_specs | ( | ) |
Reloads default and user nuisance specifications and invalidates fit state.
Definition at line 1266 of file StatisticManager.cpp.
| void StatisticManager::save_likelihood_scan_csv | ( | const std::string & | path, |
| const LikelihoodScanGrid & | grid | ||
| ) | const |
Writes a likelihood scan grid to a CSV file.
| path | Output CSV path. |
| grid | Scan grid to serialize. |
Definition at line 1949 of file StatisticManager.cpp.
| LikelihoodScanGrid StatisticManager::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 the current likelihood on a regular 2D grid around the active reference point.
| p1 | First scanned parameter. |
| p2 | Second scanned parameter. |
| x_half_width | Half-width of the scan window along p1. |
| y_half_width | Half-width of the scan window along p2. |
| nx | Number of x grid points. |
| ny | Number of y grid points. |
Definition at line 1841 of file StatisticManager.cpp.
| void StatisticManager::select_experiment | ( | const std::string & | experiment | ) |
Restricts subsequent statistics to a single experiment name.
Definition at line 1969 of file StatisticManager.cpp.
| void StatisticManager::select_experiment_observables | ( | const std::set< ExperimentObs > & | observables | ) |
Restricts subsequent statistics to an explicit list of experimental measurements.
This is stricter than select_experiments(): the experiment-name filter keeps every measurement from the selected experiments whose theory observable has been registered, whereas this method keeps only the exact (experiment, observable/bin) entries listed here. It is useful to reproduce SuperIso myobs.in / arXiv ancillary observable lists exactly.
Definition at line 2029 of file StatisticManager.cpp.
| void StatisticManager::select_experiment_observables | ( | const std::vector< ExperimentObs > & | observables | ) |
Vector overload for select_experiment_observables.
Definition at line 2022 of file StatisticManager.cpp.
| void StatisticManager::select_experiment_observables_all | ( | ) |
Clears the explicit experimental-observable selection.
Definition at line 2040 of file StatisticManager.cpp.
| void StatisticManager::select_experiments | ( | const std::set< std::string > & | experiments | ) |
Restricts subsequent statistics to the provided set of experiment names.
Definition at line 1980 of file StatisticManager.cpp.
| void StatisticManager::select_experiments | ( | const std::vector< std::string > & | experiments | ) |
Restricts subsequent statistics to the provided vector of experiment names.
Definition at line 1973 of file StatisticManager.cpp.
| void StatisticManager::select_experiments_all | ( | ) |
Clears any experiment selection and uses all available experiments.
Definition at line 1991 of file StatisticManager.cpp.
| std::set< ExperimentObs > StatisticManager::selected_experiment_observables | ( | ) | const |
Definition at line 2049 of file StatisticManager.cpp.
| std::set< std::string > StatisticManager::selected_experiments | ( | ) | const |
Definition at line 2000 of file StatisticManager.cpp.
| void StatisticManager::set_manual_scan_point | ( | const std::map< ParamId, double > & | p_hat, |
| const std::map< ParamId, double > & | eta_hat | ||
| ) |
Sets the reference point used by subsequent likelihood scans.
| p_hat | Map of fit-parameter values at the manual reference point. |
| eta_hat | Map of nuisance values at the manual reference point. |
| std::runtime_error | if no likelihood has been prepared. |
| std::invalid_argument | if one required parameter value is missing. |
Definition at line 1809 of file StatisticManager.cpp.
| void StatisticManager::set_nuisance_user_file | ( | const fs::path & | user_yaml_path | ) |
Selects a custom user nuisance-definition file and reloads nuisance specifications.
| user_yaml_path | Path to the user YAML/JSON nuisance file. |
Definition at line 1279 of file StatisticManager.cpp.
| void StatisticManager::update_cache | ( | const std::vector< ParamId > & | p_specs = std::vector<ParamId>() | ) |
Updates the full statistical cache for the selected fit parameters.
| p_specs | Fit parameters to detach from the nuisance set. |
Definition at line 1181 of file StatisticManager.cpp.
|
inline |
Definition at line 276 of file StatisticManager.h.