10 #ifndef LARDATA_UTILITIES_CHISQUAREACCUMULATOR_H 11 #define LARDATA_UTILITIES_CHISQUAREACCUMULATOR_H 54 template <
typename F,
typename T =
double>
85 unsigned int N()
const {
return fN; }
130 unsigned int fN = 0U;
137 {
return (x - mu) / sigma; }
160 template <
typename F>
179 template <
typename T,
typename F>
191 #endif // LARDATA_UTILITIES_CHISQUAREACCUMULATOR_H auto makeChiSquareAccumulator(F &&e)
Creates a ChiSquareAccumulator object with the specified function.
void add(Data_t x, Data_t y, Data_t s)
Adds a data point to the χ².
Namespace for general, non-LArSoft-specific utilities.
void clear()
Resets all the counts, starting from no data.
Computes a χ² from expectation function and data points.
Data_t chiSquare() const
Returns the value of χ² currently accumulated.
static Data_t sqr(Data_t v)
The usual square function.
unsigned int fN
Number of data entries.
void add(Data_t x, Data_t y)
Adds a data point to the χ².
ChiSquareAccumulator(Function_t const &expected)
Constructor: uses the specified expectation function.
Function_t fExpected
Function for the expectation.
Data_t expected(Data_t x) const
Returns the expected value for the specified parameter.
F Function_t
Type of function for the expectation.
Data_t fChiSq
Accumulated χ² value.
static Data_t z(Data_t x, Data_t mu, Data_t sigma)
Normal variable.
T Data_t
Type of parameter and observed values.
LArSoft-specific namespace.
unsigned int N() const
Returns the number of added points (it's not degrees of freedom yet!).
Data_t operator()() const