Class providing data collection for the simple polynomial fitters. More...
#include <SimpleFits.h>
Classes | |
struct | SumExtractor |
struct | SumExtractor< Power, 0U > |
Public Types | |
using | Data_t = T |
type of the data More... | |
using | Measurement_t = std::tuple< Data_t, Data_t > |
type of measurement without uncertainty More... | |
using | MeasurementAndUncertainty_t = std::tuple< Data_t, Data_t, Data_t > |
type of measurement with uncertainty More... | |
Public Member Functions | |
void | clear () |
Clears all the statistics. More... | |
template<typename Stream > | |
void | Print (Stream &out) const |
Prints the statistics into a stream. More... | |
Add elements | |
bool | add (Data_t x, Data_t y, Data_t sy=Data_t(1.0)) |
Adds one entry with specified x, y and uncertainty. More... | |
bool | add (Measurement_t value, Data_t sy=Data_t(1.0)) |
Adds one entry with specified x, y and uncertainty. More... | |
bool | add (MeasurementAndUncertainty_t value) |
Adds one entry with specified x, y and uncertainty. More... | |
template<typename Iter > | |
void | add_without_uncertainty (Iter begin, Iter end) |
Adds measurements from a sequence, with no uncertainty. More... | |
template<typename Iter , typename Pred > | |
void | add_without_uncertainty (Iter begin, Iter end, Pred extractor) |
Adds measurements from a sequence with no uncertainty. More... | |
template<typename Cont , typename Pred > | |
void | add_without_uncertainty (Cont cont, Pred extractor) |
Adds all measurements from a container, with no uncertainty. More... | |
template<typename Cont > | |
void | add_without_uncertainty (Cont cont) |
Adds all measurements from a container, with no uncertainty. More... | |
template<typename VIter , typename UIter , typename VPred , typename UPred = identity> | |
unsigned int | add_with_uncertainty (VIter begin_value, VIter end_value, UIter begin_uncertainty, VPred value_extractor, UPred uncertainty_extractor=UPred()) |
Adds measurements with uncertainties from a sequence. More... | |
template<typename Iter > | |
unsigned int | add_with_uncertainty (Iter begin, Iter end) |
Adds measurements with uncertainties from a sequence. More... | |
template<typename Cont > | |
unsigned int | add_with_uncertainty (Cont cont) |
Adds measurements with uncertainties from a container. More... | |
Static Public Member Functions | |
static Data_t | UncertaintyToWeight (Data_t s) |
Transforms an uncertainty into a weight ( ) More... | |
static Data_t | WeightToUncertainty (Data_t w) |
Transforms a weight back to an uncertainty ( ) More... | |
Static Public Attributes | |
static constexpr unsigned int | Degree = D |
Degree of the fit. More... | |
static constexpr unsigned int | NParams = Degree + 1 |
Protected Attributes | |
WeightTracker< Data_t > | s2 |
accumulator for uncertainty More... | |
DataTracker< Degree *2, Data_t > | x |
accumulator for variable x^k More... | |
WeightTracker< Data_t > | y |
accumulator for y More... | |
DataTracker< 1, Data_t > | y2 |
accumulator for y2 More... | |
DataTracker< Degree, Data_t > | xy |
accumulator for variable xy More... | |
Statistic retrieval | |
int | N () const |
Returns the number of entries added. More... | |
Data_t | AverageUncertainty () const |
Returns an average of the uncertainties. More... | |
Data_t | XN (unsigned int n) const |
Returns the weighted sum of x^n. More... | |
Data_t | XNY (unsigned int n) const |
Returns the weighted sum of x^n y. More... | |
template<unsigned int N> | |
Data_t | XN () const |
Returns the weighted sum of x^N. More... | |
template<unsigned int N> | |
Data_t | XNY () const |
Returns the weighted sum of x^N y. More... | |
Data_t | Y2 () const |
Returns the weighted sum of y^2. More... | |
template<typename V > | |
static constexpr V | sqr (V const &v) |
Returns the square of the specified value. More... | |
Class providing data collection for the simple polynomial fitters.
Definition at line 37 of file SimpleFits.h.
using lar::util::details::FitDataCollector< T, D >::Data_t = T |
type of the data
Definition at line 76 of file SimpleFits.h.
using lar::util::details::FitDataCollector< T, D >::Measurement_t = std::tuple<Data_t, Data_t> |
type of measurement without uncertainty
Definition at line 79 of file SimpleFits.h.
using lar::util::details::FitDataCollector< T, D >::MeasurementAndUncertainty_t = std::tuple<Data_t, Data_t, Data_t> |
type of measurement with uncertainty
Definition at line 82 of file SimpleFits.h.
bool lar::util::details::FitDataCollector< T, D >::add | ( | Data_t | x, |
Data_t | y, | ||
Data_t | sy = Data_t(1.0) |
||
) |
Adds one entry with specified x, y and uncertainty.
x | value of x |
y | value of y |
sy | value of uncertainty on y (1 by default) |
If the uncertainty is exactly 0, the entry is ignored and not added.
Definition at line 1446 of file SimpleFits.h.
|
inline |
Adds one entry with specified x, y and uncertainty.
value | the ( x ; y ) pair |
sy | value of uncertainty on y (1 by default) |
If the uncertainty is exactly 0, the entry is ignored and not added.
Definition at line 108 of file SimpleFits.h.
|
inline |
Adds one entry with specified x, y and uncertainty.
value | ( x ; y ; sy ), sy being the uncertainty on y |
If the uncertainty is exactly 0, the entry is ignored and not added.
Definition at line 118 of file SimpleFits.h.
unsigned int lar::util::details::FitDataCollector< T, D >::add_with_uncertainty | ( | VIter | begin_value, |
VIter | end_value, | ||
UIter | begin_uncertainty, | ||
VPred | value_extractor, | ||
UPred | uncertainty_extractor = UPred() |
||
) |
Adds measurements with uncertainties from a sequence.
VIter | forward iterator to the elements to be added |
UIter | forward iterator to the uncertainties |
VPred | predicate to extract the measurement from iterator value |
UPred | predicate to extract the uncertainty from iterator value |
begin_value | iterator to the first measurement to be added |
end_value | iterator after the last measurement to be added |
begin_uncertainty | iterator to the uncertainty of first measurement |
value_extractor | predicate extracting the measurement to be inserted |
uncertainty_extractor | predicate extracting the uncertainty |
Each element is added with the uncertainty pointed by the matching element in the list pointed by begin_weight: the measurement of *(begin_value)
will have uncertainty *(begin_uncertainty)
, the next measurement *(begin_value + 1)
will have uncertainty *(begin_uncertainty + 1)
, etc.
The predicates are required to react to a call like with:
Measurement_t VPred::operator() (typename VIter::value_type); Data_t UPred::operator() (typename UIter::value_type);
Points with zero or infinite uncertainty are ignored and not added.
Definition at line 1477 of file SimpleFits.h.
unsigned int lar::util::details::FitDataCollector< T, D >::add_with_uncertainty | ( | Iter | begin, |
Iter | end | ||
) |
Adds measurements with uncertainties from a sequence.
Iter | forward iterator to MeasurementAndUncertainty_t to be added |
begin | iterator pointing to the first measurement to be added |
end | iterator pointing after the last measurement to be added |
The value pointed by the iterator must be a MeasurementAndUncertainty_t or something with elements convertible to its own (Data_t triplet). For more complicate structures, use the version with two predicates (using the uncertainty iterator the same as the measurement iterator).
Points with zero or infinite uncertainty are ignored and not added.
Definition at line 1499 of file SimpleFits.h.
|
inline |
Adds measurements with uncertainties from a container.
Cont | type of container of MeasurementAndUncertainty_t elements |
cont | container of MeasurementAndUncertainty_t to be added |
The values in the container must be tuples with each element convertible to Data_t.
Points with zero or infinite uncertainty are ignored and not added.
Definition at line 254 of file SimpleFits.h.
|
inline |
Adds measurements from a sequence, with no uncertainty.
Iter | forward iterator to the pairs to be added |
begin | iterator pointing to the first element to be added |
end | iterator pointing after the last element to be added |
The value pointed by the iterator must be a tuple with types compatible with Measurement_t.
Definition at line 135 of file SimpleFits.h.
void lar::util::details::FitDataCollector< T, D >::add_without_uncertainty | ( | Iter | begin, |
Iter | end, | ||
Pred | extractor | ||
) |
Adds measurements from a sequence with no uncertainty.
Iter | forward iterator to the elements to be added |
Pred | a predicate to extract the element from iterator value |
begin | iterator pointing to the first element to be added |
end | iterator pointing after the last element to be added |
extractor | the predicate extracting the value to be inserted |
The predicate is required to react to a call like with:
Measurement_t Pred::operator() (typename Iter::value_type);
Definition at line 1467 of file SimpleFits.h.
|
inline |
Adds all measurements from a container, with no uncertainty.
Cont | type of container of the elements to be added |
Pred | a predicate to extract the element from iterator value |
cont | container of the elements to be added |
extractor | the predicate extracting the value to be inserted |
The predicate is required to react to a call like with:
Measurement_t Pred::operator() (typename Cont::value_type);
The container must support the range-based for loop syntax, that is is must have std::begin<Cont>() and std::end<Cont>() defined.
Definition at line 169 of file SimpleFits.h.
|
inline |
Adds all measurements from a container, with no uncertainty.
Cont | type of container of the elements to be added |
cont | container of the elements to be added |
The container must support the range-based for loop syntax, that is is must have std::begin<Cont>() and std::end<Cont>() defined. The value in the container must be convertible to the Measurement_t type.
Definition at line 183 of file SimpleFits.h.
|
inline |
Returns an average of the uncertainties.
std::range_error | if no entry was added |
The average is the square root of the harmonic average of the variances (that is, the errors squared):
Definition at line 277 of file SimpleFits.h.
|
inline |
Clears all the statistics.
Definition at line 1509 of file SimpleFits.h.
|
inline |
Returns the number of entries added.
Definition at line 266 of file SimpleFits.h.
void lar::util::details::FitDataCollector< T, D >::Print | ( | Stream & | out | ) | const |
Prints the statistics into a stream.
Definition at line 1519 of file SimpleFits.h.
|
inlinestatic |
Returns the square of the specified value.
Definition at line 283 of file SimpleFits.h.
|
inlinestatic |
Transforms an uncertainty into a weight ( )
Definition at line 317 of file SimpleFits.h.
|
inlinestatic |
|
inline |
Returns the weighted sum of x^n.
Definition at line 287 of file SimpleFits.h.
|
inline |
Returns the weighted sum of x^N.
Definition at line 297 of file SimpleFits.h.
|
inline |
Returns the weighted sum of x^n y.
Definition at line 291 of file SimpleFits.h.
|
inline |
Returns the weighted sum of x^N y.
Definition at line 302 of file SimpleFits.h.
|
inline |
Returns the weighted sum of y^2.
Definition at line 307 of file SimpleFits.h.
|
static |
Degree of the fit.
Definition at line 73 of file SimpleFits.h.
|
static |
Definition at line 74 of file SimpleFits.h.
|
protected |
accumulator for uncertainty
Definition at line 327 of file SimpleFits.h.
|
protected |
accumulator for variable x^k
Definition at line 328 of file SimpleFits.h.
|
protected |
accumulator for variable xy
Definition at line 331 of file SimpleFits.h.
|
protected |
accumulator for y
Definition at line 329 of file SimpleFits.h.
|
protected |
accumulator for y2
Definition at line 330 of file SimpleFits.h.