1#ifndef STATISTIC_MANAGER_H
2#define STATISTIC_MANAGER_H
194 std::map<ParamId, std::map<ParamId, double>>
SigmaEta;
195 std::map<ExperimentObs, std::map<ExperimentObs, double>>
SigmaObs;
230 std::shared_ptr<IModel> obs_int,
231 std::shared_ptr<IStatCorrelationProxy> pscp,
232 std::shared_ptr<IStatParameterProxy> pspp,
233 std::shared_ptr<IStatSourcesProxy> sp,
234 std::shared_ptr<IStatDependencyPruner> dp,
235 std::shared_ptr<INuisanceReader> nuisance_reader,
236 std::shared_ptr<IStatParamOptimizerProxy> spop);
340 const std::map<ParamId, double>& eta_hat);
373 void update_cache(
const std::vector<ParamId>& p_specs = std::vector<ParamId>());
444 void rebuild_merged_nuisance_specs();
447 void invalidate_fit_state();
470 fit_app::ParameterDefinition make_nuisance_parameter_definition(const
ParamId& pid,
472 double sigma_hint) const;
491 void validate_fit_parameter_sensitivity();
494 bool accepts_experiment_observable(const
ExperimentObs& exp_obs) const;
511 std::optional<fs::path> current_user_nuisance_file_;
522 std::vector<
double> last_scan_p_;
523 std::vector<
double> last_scan_eta_;
524 bool has_manual_scan_point_ = false;
526 std::vector<
ParamId> last_detached_fit_params_;
529 std::optional<
std::set<
std::
string>> selected_experiments_;
Chi-square likelihood implementation for models without explicit nuisance parameters.
Factory utilities for constructing copula objects from typed configurations.
CopulaType
Identifies the copula family used to model dependence.
@ GAUSSIAN
Gaussian copula, defined by a correlation matrix.
High-level maximum-likelihood fitting and confidence-contour API.
Abstract model interface used by the statistical layer.
Interface for loading nuisance-parameter specifications.
Statistical-layer port for read-only access to correlation coefficients.
Statistical-layer port for pruning and restoring parameter dependencies.
Statistical-layer port for batched parameter edits and optimized commits.
Statistical-layer port for read-only access to parameters and observable entries.
Statistical-layer port for retrieving leaf parameter sources.
Joint probability distribution built from marginals and a copula.
Monte Carlo propagation of nuisance-parameter uncertainties.
Factory for building marginal-distribution configuration objects.
Factory for instantiating concrete marginal distributions.
MarginalType
Supported marginal-distribution families.
Data structures for nuisance-parameter specifications.
std::unordered_map< ParamId, NuisanceSpec > NuisanceRegistry
Registry of nuisance specifications indexed by parameter id.
Nuisance sampler backed by a joint random-vector generator.
StatisticLikelihoodMode
Selects the likelihood backend used by StatisticManager::compute_MLE().
@ PROFILED_NUISANCE
Full likelihood with explicit nuisance parameters profiled during the fit.
@ CHI2_MC_COVARIANCE
Fast chi-square likelihood using MC theory covariance plus experimental covariance.
Default implementation of a profileable negative log-likelihood.
Interface for a model capable of producing observable predictions.
Abstract interface for nuisance specification loaders.
Abstract port used by the statistics module to prune dependency links.
Abstract interface for batched parameter mutation in the statistics layer.
Abstract read-only interface to parameters and observables for the statistics layer.
Abstract statistics-layer interface for dependency source resolution.
High-level driver for likelihood minimization and 2D contour extraction.
Builds distribution-configuration objects from parameters or observables.
Coordinates statistical inputs, nuisance distributions, MLE fits and contour/scan computations.
void select_experiments(const std::set< std::string > &experiments)
Restricts subsequent statistics to the provided set of experiment names.
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.
void print_cache()
Prints the current internal cache to standard output for debugging.
std::set< ExperimentObs > selected_experiment_observables() const
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.
std::map< ExperimentObs, std::map< ExperimentObs, double > > get_all_obs_correlations()
void reload_nuisance_specs()
Reloads default and user nuisance specifications and invalidates fit state.
std::vector< std::unique_ptr< IMarginalDistribution > > build_nuisance_marginal_distributions()
Builds marginal distributions for all currently cached nuisances.
void set_nuisance_user_file(const fs::path &user_yaml_path)
Selects a custom user nuisance-definition file and reloads nuisance specifications.
std::unique_ptr< JointDistribution > build_nuisance_distribution()
Builds the joint nuisance distribution from cached nuisance marginals and correlations.
const NuisanceRegistry & default_nuisance_specs() const
bool has_experiment_observable_selection() const noexcept
void select_experiment_observables_all()
Clears the explicit experimental-observable selection.
void select_experiment_observables(const std::set< ExperimentObs > &observables)
Restricts subsequent statistics to an explicit list of experimental measurements.
void select_experiment(const std::string &experiment)
Restricts subsequent statistics to a single experiment name.
std::set< std::string > selected_experiments() const
std::map< ParamId, std::map< ParamId, double > > get_all_correlations()
void prepare_likelihood_for_scan(const std::vector< ParamId > &p_specs)
Prepares a likelihood object for manual scans without running a full MLE.
std::map< BinnedObservableId, GaussianSummary > compute_uncertainties()
Computes Gaussian summaries for MC-propagated observable uncertainties.
const NuisanceRegistry & merged_nuisance_specs() const
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.
std::map< ExperimentObs, double > get_obs_exp()
bool has_experiment_selection() const noexcept
FitResultWithMaps compute_MLE(const std::vector< ParamId > &p_specs)
Computes the maximum-likelihood fit for a selected set of fit parameters.
std::map< ParamId, double > get_p_specs(const std::vector< ParamId > &p_specs)
Resolves initial fit-parameter values from the parameter proxy.
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_experiments_all()
Clears any experiment selection and uses all available experiments.
const NuisanceRegistry & user_nuisance_specs() const
std::unique_ptr< JointDistribution > build_exp_data_distribution()
Builds the joint experimental-data distribution from cached observables and correlations.
std::map< ParamId, double > get_all_obss_deps()
Selects all nuisance dependencies relevant to the current observable set.
void clear_nuisance_user_file()
Clears the custom user nuisance file and reloads the default configured user file.
MCResult compute_uncertainties_and_sampling()
Runs MC uncertainty propagation and returns both samples and summaries.
Hash specialization for SymbolId<Tag>.
std::map< ExperimentObs, MarginalType > override_exp_data_marginals
Per-observable overrides for experimental-data marginals.
double chi2_covariance_ridge_abs
Absolute diagonal ridge used before inverting chi-square covariance matrices.
double nuisance_relevance_cutoff
Relative-uncertainty cutoff for the first nuisance preselection pass.
bool MLE_allow_profile_hessian_fallback
Allows numerical profile-Hessian covariance fallback if backend covariance fails.
bool MLE_trace_first_evals
Enables debug tracing of the first likelihood evaluations.
bool fit_parameter_sensitivity_keep_on_failure
Keeps a fit parameter when its sensitivity probe cannot be evaluated safely.
bool MLE_run_hesse
Whether to request HESSE/covariance estimation after the fit.
unsigned MLE_strategy
Backend minimization strategy; zero means backend default where supported.
double nuisance_sensitivity_probe_sigmas
Size of the +/- finite-difference probe in units of nuisance sigma.
double MLE_tol
Minimizer tolerance passed to the backend.
double fit_parameter_sensitivity_rel_cutoff
Relative observable shift required to regard a fit parameter as active.
double fit_parameter_sensitivity_probe_fraction
Minimum probe size as a fraction of explicit/default fit bounds.
bool MLE_verbose
Enables verbose output from the fit backend.
double nuisance_sensitivity_context_sigma
Randomized-context spread in nuisance sigma units.
int nuisance_sensitivity_contexts
Number of contexts tested by sensitivity pruning; negative disables the check.
double MLE_profile_hessian_step_scale
Step scaling used by the numerical profile-Hessian fallback.
double chi2_covariance_ridge_rel
Relative diagonal ridge used before inverting chi-square covariance matrices.
double nuisance_sensitivity_rel_cutoff
Relative observable shift required to keep a nuisance.
bool MLE_request_minos
Whether to request MINOS errors when supported by the backend build.
unsigned nuisance_sensitivity_seed
RNG seed used to build sensitivity-pruning contexts.
bool nuisance_sensitivity_keep_on_failure
Keeps a nuisance if its sensitivity probe fails.
std::map< ParamId, MarginalType > override_nuisance_marginals
Per-parameter overrides for nuisance marginal laws.
double fit_parameter_sensitivity_abs_cutoff
Absolute observable shift required to regard a fit parameter as active.
std::size_t MLE_max_iter
Maximum number of minimizer function calls/iterations.
double nuisance_sensitivity_scale_floor
Lower scale used when normalizing relative observable shifts.
double nuisance_sensitivity_abs_cutoff
Absolute observable shift required to keep a nuisance.
bool MC_force_decay_threads_to_one
Give MC priority over internal decay parallelism.
CopulaType nuisance_copula_type
Copula used to correlate nuisance parameters.
bool fit_parameter_sensitivity_check
Reject fit parameters that do not measurably change any selected observable.
std::size_t MLE_trace_max_evals
Maximum number of likelihood evaluations printed when tracing is enabled.
double MLE_profile_hessian_eig_floor_rel
Relative eigenvalue floor used to regularize the fallback Hessian.
StatisticLikelihoodMode likelihood_mode
Likelihood mode used by compute_MLE().
std::size_t MC_forced_decay_threads
Decay thread count while MC workers are running.
bool nuisance_sensitivity_pruning
Enables local model-sensitivity pruning of nuisance candidates.
CopulaType exp_data_copula_type
Copula used to correlate experimental observables.
Runtime options controlling 2D contour computation.
Output of a contour extraction algorithm.
User-facing MLE result keyed by physics parameter identifiers.
std::map< ParamId, double > p_hat_std
Profiled standard deviations of fitted parameters.
std::map< ParamId, double > eta_hat
Best-fit/profiler values of nuisance parameters.
std::map< ParamId, std::map< ParamId, double > > p_correlations
Correlation matrix of fitted parameters.
std::map< ParamId, double > p_hat
Best-fit values of fitted parameters.
double ell_hat
Minimum negative log-likelihood value.
bool fit_ok
True when the fit returned a usable parameter estimate.
Summary of a global likelihood fit.
Abstract read-only interface for correlation queries in the statistics module.
Shared immutable-like data required to evaluate a likelihood.
Regular two-dimensional grid of likelihood-scan evaluations.
double y_center
Reference value used as the scan center on y.
double x_center
Reference value used as the scan center on x.
ParamId y_param
Identifier of the second scanned parameter.
std::vector< LikelihoodScanPoint > points
Flattened grid points in x-major order.
ParamId x_param
Identifier of the first scanned parameter.
std::size_t nx
Number of grid points along x.
std::size_t ny
Number of grid points along y.
Single point of a two-dimensional likelihood scan.
double delta_nll
Difference between nll and the minimum NLL found on the scan grid.
double x
Coordinate along the first scanned fit parameter.
double nll
Negative log-likelihood value at this point.
double y
Coordinate along the second scanned fit parameter.
Specification of one nuisance parameter.
Composite identifier for a single parameter.
Internal cache of currently selected observables, nuisances, correlations and fit state.
std::map< ParamId, double > p_specs
Selected fit parameters and their initial values.
FitResultWithMaps mle_result
Last MLE result expressed with map-based identifiers.
std::map< ExperimentObs, double > exp_obs
Experimental central values used by the current fit.
std::map< ParamId, double > eta_specs_real
Selected nuisance parameters and their central values.
std::map< ExperimentObs, std::map< ExperimentObs, double > > SigmaObs
Correlation matrix of selected experimental observables.
std::map< ParamId, std::map< ParamId, double > > SigmaEta
Correlation matrix of selected nuisances.
std::shared_ptr< StatisticProgressMonitor > progress_monitor
Optional thread-safe progress sink for GUI/notebook frontends.
std::string mc_samples_csv_path
Output CSV path used when write_mc_samples_csv is true.
bool print_scan_summary
Print likelihood-scan summaries.
bool print_fit_summary
Print high-level fit backend summaries.
unsigned int MC_seed
RNG seed used for reproducible MC nuisance and experimental-data sampling.
std::size_t mc_progress_probe_draws
Number of first accepted draws used to stabilize the first ETA.
std::map< ParamId, std::pair< double, double > > fit_parameter_bounds
Optional explicit minimizer bounds keyed by fit ParamId.
bool write_mc_samples_csv
Write accepted MC observable samples to CSV.
bool print_mc_config
Print nuisance candidates and retained MC marginal configuration.
AdvancedStatisticConfig advanced
Advanced fit/pruning/covariance configuration.
bool print_chi2_pipeline_progress
Print chi-square workflow stages after/beside the MC progress bar.
bool print_mc_progress
Print MC progress with ETA based on measured draw time.
std::size_t MC_draws
Number of accepted MC draws used for uncertainty propagation.
bool print_debug
Master debug flag for low-level diagnostic output.
std::size_t MC_threads
Number of worker threads used by MC propagation.
std::size_t mc_progress_update_every
Accepted-draw stride between progress updates.
std::map< ParamId, double > fit_parameter_offsets
Optional affine display offsets: model value = fitted value - offset.
double skew_abs_threshold
Absolute skewness threshold below which a summary is treated as symmetric.
bool print_cache_summary
Print internal cache diagnostics.