Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
GaussianApprox.h
Go to the documentation of this file.
1#ifndef GAUSSIANAPPROX_H
2#define GAUSSIANAPPROX_H
3
4#include <vector>
5#include <stdexcept>
6
7#include "Statistics.h"
8
30 double mu {}; // population mean
31 double sigma {};
32 double sigma_p {};
33 double sigma_m {};
34 double mode {};
35 double skew {};
36 bool symmetric {};
37};
38
51inline std::ostream& operator<<(std::ostream& os, const GaussianSummary& gs) {
52 os << ObservableMapper::str(gs.id.s) << "[" << gs.id.p.first << "," <<gs.id.p.second << "] = ";
53 if (gs.symmetric) {
54 os << std::setprecision(4) << gs.mu << " +- " << gs.sigma << " (skew = " << std::setprecision(2) << gs.skew << ")";
55 } else {
56 os << std::setprecision(4) << gs.mode << " + " << gs.sigma_p << " - " << gs.sigma_m << " (skew = " << std::setprecision(2) << gs.skew << ")";
57 }
58 return os;
59}
60
75inline std::vector<GaussianSummary> gaussian_fit(const ObsSamples& S, double skew_abs_threshold=0.2) {
76 const auto cols = summarize_columns_obs(S);
77 std::vector<GaussianSummary> out;
78 for (const auto& col : cols) {
79 out.push_back(GaussianSummary{
80 col.first,
81 col.second.mean,
82 col.second.std_unbiased,
83 col.second.std_p,
84 col.second.std_m,
85 col.second.mode,
86 col.second.b1_skew,
87 std::fabs(col.second.b1_skew) < skew_abs_threshold
88 });
89 }
90
91 return out;
92}
93
94#endif
std::ostream & operator<<(std::ostream &os, const GaussianSummary &gs)
Streams a human-readable Gaussian summary.
std::vector< GaussianSummary > gaussian_fit(const ObsSamples &S, double skew_abs_threshold=0.2)
Builds Gaussian or split-Gaussian summaries for observable samples.
Statistical helpers for Monte Carlo observable samples.
std::vector< std::map< BinnedObservableId, double > > ObsSamples
Definition Statistics.h:25
std::map< BinnedObservableId, ColumnStats > summarize_columns_obs(const ObsSamples &S)
Computes per-observable summary statistics from Monte Carlo samples.
Definition Statistics.h:86
static std::string str(const IdOf< ObservableTag > &id)
Returns the string representation of an identifier.
Identifies an observable together with a numerical bin.
std::pair< double, double > p
double sigma_m
Left-side standard deviation for an asymmetric approximation.
double skew
Sample skewness estimator.
BinnedObservableId id
Binned observable identifier.
double mode
Estimated population mode.
bool symmetric
True when the distribution is treated as sufficiently symmetric.
double sigma_p
Right-side standard deviation for an asymmetric approximation.
double sigma
Symmetric population standard deviation.