"Fast" Gaussian fit More...
#include <SimpleFits.h>
Classes | |
struct | EncodeExtractor |
struct | EncodeExtractor< Pred, void > |
struct | Value_t |
< type of value and error More... | |
Public Types | |
using | Data_t = typename Base_t::Data_t |
type of the data More... | |
using | Measurement_t = typename Fitter_t::Measurement_t |
type of measurement without uncertainty More... | |
using | MeasurementAndUncertainty_t = typename Fitter_t::MeasurementAndUncertainty_t |
type of measurement with uncertainty More... | |
using | FitParameters_t = typename Fitter_t::FitParameters_t |
using | FitMatrix_t = typename Fitter_t::FitMatrix_t |
Public Types inherited from lar::util::details::SimpleFitterInterface< T, 3 > | |
using | Data_t = T |
type of the data More... | |
using | MatrixOps = FastMatrixOperations< Data_t, NParams > |
using | FitParameters_t = std::array< Data_t, NParams > |
type of set of fit parameters More... | |
using | FitMatrix_t = typename MatrixOps::Matrix_t |
type of matrix for covariance (a std::array) More... | |
Public Member Functions | |
virtual bool | FillResults (FitParameters_t ¶ms, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors) const override |
Fills the specified parameters. More... | |
virtual Data_t | Evaluate (Data_t x) const override |
Evaluates the fitted function at the specified point. More... | |
virtual Fitter_t const & | Fitter () const |
Returns the internal fitter (mostly for debugging) More... | |
Add elements | |
| |
bool | add (Data_t x, Data_t y, Data_t sy=Data_t(1.0)) |
bool | add (Measurement_t value, Data_t sy=Data_t(1.0)) |
bool | add (MeasurementAndUncertainty_t value) |
template<typename Iter > | |
void | add_without_uncertainty (Iter begin, Iter end) |
template<typename Iter , typename Pred > | |
void | add_without_uncertainty (Iter begin, Iter end, Pred extractor) |
template<typename Cont , typename Pred > | |
void | add_without_uncertainty (Cont cont, Pred extractor) |
template<typename Cont > | |
void | add_without_uncertainty (Cont cont) |
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()) |
template<typename Iter > | |
unsigned int | add_with_uncertainty (Iter begin, Iter end) |
template<typename Cont > | |
unsigned int | add_with_uncertainty (Cont cont) |
void | clear () |
Clears all the input statistics. More... | |
int | N () const |
Returns the number of (valid) points added. More... | |
template<typename Stream > | |
void | PrintStats (Stream &out) const |
Prints the collected statistics into a stream. More... | |
Fitting | |
virtual bool | isValid () const override |
Returns if the fit has valid results. More... | |
virtual FitParameters_t | FitParameters () const override |
Computes and returns all the parameters of the fit result. More... | |
virtual FitParameters_t | FitParameterErrors () const override |
Computes and returns all the parameter errors of the fit result. More... | |
virtual FitMatrix_t | FitParameterCovariance () const override |
Computes and returns all the covariance matrix of the fit result. More... | |
virtual Data_t | ChiSquare () const override |
Returns the of the original fit. More... | |
virtual int | NDF () const override |
Returns the degrees of freedom in the determination of the fit. More... | |
Public Member Functions inherited from lar::util::details::SimpleFitterInterface< T, 3 > | |
virtual | ~SimpleFitterInterface ()=default |
Virtual destructor: compiler's default. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const =0 |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const =0 |
Fills the specified parameters. More... | |
virtual bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors) const =0 |
Fills the specified parameters. More... | |
virtual Data_t | Evaluate (Data_t x) const =0 |
Evaluates the fitted function at the specified point. More... | |
Data_t | operator() (Data_t x) const |
Evaluates the fitted function; alias of Evaluate() More... | |
virtual Data_t | FitParameter (unsigned int n) const |
Returns the parameter n of the fit result. More... | |
virtual Data_t | FitParameterError (unsigned int n) const |
Returns the error on parameter n of the fit result. More... | |
Static Public Member Functions | |
static Data_t | Evaluate (Data_t x, Data_t const *params) |
Evaluates a Gaussian with given parameters at one point. More... | |
Static Public Member Functions inherited from lar::util::details::SimpleFitterInterface< T, 3 > | |
static constexpr Data_t | sqr (Data_t v) |
Returns the square of the specified data value. More... | |
static constexpr Data_t | cube (Data_t v) |
Returns the cube of the specified data value. More... | |
Static Public Attributes | |
static constexpr unsigned int | NParams = Base_t::NParams |
Number of parameters in the fit. More... | |
Static Public Attributes inherited from lar::util::details::SimpleFitterInterface< T, 3 > | |
static constexpr unsigned int | NParams |
Number of parameters in the fit. More... | |
Static Protected Member Functions | |
static FitParameters_t | ConvertParameters (FitParameters_t const &qpars) |
Converts the specified quadratic fit parameters into Gaussian. More... | |
static void | ConvertParametersAndErrors (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t ¶ms, FitParameters_t ¶merrors) |
Converts the specified quadratic fit parameters and errors. More... | |
static void | ConvertParametersAndVariances (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t ¶ms, FitParameters_t ¶mvariances) |
Converts the specified quadratic fit parameters and errors. More... | |
static void | ConvertParametersAndErrorMatrix (FitParameters_t const &qpars, FitMatrix_t const &qparerrmat, FitParameters_t ¶ms, FitMatrix_t &Smat) |
Converts the specified quadratic fit parameters and errors. More... | |
static bool | isValid (FitParameters_t const ¶ms, FitParameters_t const &qpars) |
Returns whether the specified parameters represent a valid fit. More... | |
static void | ThrowNotImplemented (std::string method) |
Mumbo-jumbo to convert the values for a quadratic fit | |
static Data_t | EncodeValue (Data_t value) |
static Data_t | DecodeValue (Data_t value) |
Converts a value from the quadratic fit into a proper value. More... | |
static Value_t | EncodeValue (Data_t value, Data_t error) |
Converts a value and error into a proper input for the quadratic fit. More... | |
static Value_t | EncodeValue (Value_t const &value) |
Converts a value and error into a proper input for the quadratic fit. More... | |
static Value_t | DecodeValue (Value_t const &value) |
Converts a value from the quadratic fit into a proper value. More... | |
static Measurement_t | EncodeValue (Measurement_t const &meas) |
Converts a value and error into a proper input for the quadratic fit. More... | |
static MeasurementAndUncertainty_t | EncodeValue (MeasurementAndUncertainty_t const &meas) |
Converts a value and error into a proper input for the quadratic fit. More... | |
static MeasurementAndUncertainty_t | EncodeValue (Measurement_t const &meas, Data_t error) |
Converts a value and error into a proper input for the quadratic fit. More... | |
template<typename Pred > | |
static EncodeExtractor< Pred > | Encoder (Pred &pred) |
template<typename VPred , typename UPred > | |
static EncodeExtractor< VPred, UPred > | Encoder (VPred &vpred, UPred &upred) |
Protected Attributes | |
Fitter_t | fitter |
the actual fitter and data holder More... | |
Private Types | |
using | Base_t = details::SimpleFitterInterface< T, 3 > |
base class More... | |
using | Fitter_t = QuadraticFit< T > |
base class More... | |
Additional Inherited Members | |
Protected Member Functions inherited from lar::util::details::SimpleFitterInterface< T, 3 > | |
virtual Data_t | Determinant (FitMatrix_t const &mat) const |
Computes the determinant of a matrix. More... | |
virtual FitMatrix_t | InvertMatrix (FitMatrix_t const &mat, Data_t det) const |
Computes the inverse of a matrix (using provided determinant) More... | |
virtual FitMatrix_t | InvertMatrix (FitMatrix_t const &mat) const |
Computes the inverse of a matrix. More... | |
virtual FitParameters_t | MatrixProduct (FitMatrix_t const &mat, FitParameters_t const &vec) const |
Computes the product of a FitMatrix_t and a FitParameters_t. More... | |
"Fast" Gaussian fit
T | data type |
This class performs a Gaussian fit on demand. This fit translates the data to its logarithm and then internally performs a quadratic fit. Note that as a consequence this fitter does not accept negative values for the y variable. Negative values in input will be completely ignored.
Methods that do not change functionality respect to the base class are not documented here – see the base class(es) documentation (mostly SimplePolyFitterBase).
Definition at line 1018 of file SimpleFits.h.
|
private |
base class
Definition at line 1019 of file SimpleFits.h.
using lar::util::GaussianFit< T >::Data_t = typename Base_t::Data_t |
type of the data
Definition at line 1026 of file SimpleFits.h.
using lar::util::GaussianFit< T >::FitMatrix_t = typename Fitter_t::FitMatrix_t |
Definition at line 1036 of file SimpleFits.h.
using lar::util::GaussianFit< T >::FitParameters_t = typename Fitter_t::FitParameters_t |
Definition at line 1035 of file SimpleFits.h.
|
private |
base class
Definition at line 1020 of file SimpleFits.h.
using lar::util::GaussianFit< T >::Measurement_t = typename Fitter_t::Measurement_t |
type of measurement without uncertainty
Definition at line 1029 of file SimpleFits.h.
using lar::util::GaussianFit< T >::MeasurementAndUncertainty_t = typename Fitter_t::MeasurementAndUncertainty_t |
type of measurement with uncertainty
Definition at line 1033 of file SimpleFits.h.
bool lar::util::GaussianFit< T >::add | ( | Data_t | x, |
Data_t | y, | ||
Data_t | sy = Data_t(1.0) |
||
) |
Definition at line 1790 of file SimpleFits.h.
|
inline |
Definition at line 1050 of file SimpleFits.h.
|
inline |
Definition at line 1053 of file SimpleFits.h.
unsigned int lar::util::GaussianFit< T >::add_with_uncertainty | ( | VIter | begin_value, |
VIter | end_value, | ||
UIter | begin_uncertainty, | ||
VPred | value_extractor, | ||
UPred | uncertainty_extractor = UPred() |
||
) |
Definition at line 1812 of file SimpleFits.h.
unsigned int lar::util::GaussianFit< T >::add_with_uncertainty | ( | Iter | begin, |
Iter | end | ||
) |
Definition at line 1829 of file SimpleFits.h.
|
inline |
Definition at line 1092 of file SimpleFits.h.
|
inline |
Definition at line 1061 of file SimpleFits.h.
void lar::util::GaussianFit< T >::add_without_uncertainty | ( | Iter | begin, |
Iter | end, | ||
Pred | extractor | ||
) |
Definition at line 1801 of file SimpleFits.h.
|
inline |
Definition at line 1068 of file SimpleFits.h.
|
inline |
Definition at line 1072 of file SimpleFits.h.
|
inlineoverridevirtual |
Returns the of the original fit.
This is not defined in the space of the Gaussian, but in the space of the internal quadratic fit. Where one is minimum, the other also is, but the actual value is different.
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1161 of file SimpleFits.h.
|
inline |
Clears all the input statistics.
Definition at line 1097 of file SimpleFits.h.
|
staticprotected |
Converts the specified quadratic fit parameters into Gaussian.
qpars | the quadratic fit parameters |
Definition at line 1920 of file SimpleFits.h.
|
staticprotected |
Converts the specified quadratic fit parameters and errors.
qpars | the quadratic fit parameters |
qparerrmat | the quadratic fit parameter error matrix |
params | the Gaussian fit parameters |
Smat | the covariance matrix of the Gaussian fit parameters |
Definition at line 1986 of file SimpleFits.h.
|
staticprotected |
Converts the specified quadratic fit parameters and errors.
qpars | the quadratic fit parameters |
qparerrmat | the quadratic fit parameter error matrix |
params | the Gaussian fit parameters |
paramerrors | the Gaussian fit parameter errors |
Definition at line 1974 of file SimpleFits.h.
|
staticprotected |
Converts the specified quadratic fit parameters and errors.
qpars | the quadratic fit parameters |
qparerrmat | the quadratic fit parameter error matrix |
params | the Gaussian fit parameters |
paramvariances | the Gaussian fit parameter variance |
Definition at line 1938 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value from the quadratic fit into a proper value.
Definition at line 1268 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value from the quadratic fit into a proper value.
Definition at line 1282 of file SimpleFits.h.
|
inlinestaticprotected |
Definition at line 1364 of file SimpleFits.h.
|
inlinestaticprotected |
Definition at line 1367 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value into a proper input for the quadratic fit; does not accept 0 or negative values!
Definition at line 1265 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1272 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1277 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1289 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1297 of file SimpleFits.h.
|
inlinestaticprotected |
Converts a value and error into a proper input for the quadratic fit.
Definition at line 1305 of file SimpleFits.h.
|
inlineoverridevirtual |
Evaluates the fitted function at the specified point.
x | the point where to evaluate the fit function |
No check is performed whether the fit is valid.
Definition at line 1225 of file SimpleFits.h.
|
static |
Evaluates a Gaussian with given parameters at one point.
x | the point where to evaluate the fit function |
params | Gaussian parameters: amplitude, mean, sigma |
Definition at line 1911 of file SimpleFits.h.
|
overridevirtual |
Fills the specified parameters.
params | the fitted values of the parameters |
Xmat | the matrix of the x^n/s^2 sums |
Smat | the covariance matrix |
det | the determinant of Xmat |
Unsupported.
Definition at line 1888 of file SimpleFits.h.
|
overridevirtual |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Xmat | the matrix of the x^n/s^2 sums |
Smat | the covariance matrix |
det | the determinant of Xmat |
Unsupported.
Definition at line 1900 of file SimpleFits.h.
|
overridevirtual |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Only the version returning the parameters and errors is supported.
Definition at line 1875 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the covariance matrix of the fit result.
std::runtime_error | if there is no unique solution |
Not supported. It's fairly too complicate to fill the whole matrix. Doable, on request.
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1858 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the parameter errors of the fit result.
std::runtime_error | if there is no unique solution |
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1847 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the parameters of the fit result.
std::runtime_error | if there is no unique solution |
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1841 of file SimpleFits.h.
|
inlinevirtual |
Returns the internal fitter (mostly for debugging)
Definition at line 1230 of file SimpleFits.h.
|
inlineoverridevirtual |
Returns if the fit has valid results.
The fit has no valid results if:
Note that checking point 2 is expensive in terms of time.
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1122 of file SimpleFits.h.
|
staticprotected |
Returns whether the specified parameters represent a valid fit.
params | Gaussian parameters |
qpars | quadratic fit parameters |
Definition at line 2040 of file SimpleFits.h.
|
inline |
Returns the number of (valid) points added.
Definition at line 1100 of file SimpleFits.h.
|
inlineoverridevirtual |
Returns the degrees of freedom in the determination of the fit.
The return value may be 0 or negative if insufficient points have been added.
Implements lar::util::details::SimpleFitterInterface< T, 3 >.
Definition at line 1170 of file SimpleFits.h.
|
inline |
Prints the collected statistics into a stream.
Definition at line 1105 of file SimpleFits.h.
|
inlinestaticprotected |
Definition at line 1425 of file SimpleFits.h.
|
protected |
the actual fitter and data holder
Definition at line 1242 of file SimpleFits.h.
|
static |
Number of parameters in the fit.
Definition at line 1024 of file SimpleFits.h.