LArSoft
v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
|
Base class providing virtual fitting interface for polynomial fitters. More...
#include "SimpleFits.h"
Public Types | |
using | Data_t = typename Base_t::Data_t |
type of the data More... | |
using | FitParameters_t = typename Interface_t::FitParameters_t |
type of set of fit parameters More... | |
using | FitMatrix_t = typename Interface_t::FitMatrix_t |
type of matrix for covariance (a std::array) More... | |
using | MatrixOps = FastMatrixOperations< Data_t, NParams > |
using | Measurement_t = typename Collector_t::Measurement_t |
type of measurement without uncertainty More... | |
using | MeasurementAndUncertainty_t = typename Collector_t::MeasurementAndUncertainty_t |
type of measurement with uncertainty More... | |
Public Member Functions | |
virtual bool | isValid () const override |
Returns if the fit has valid results. More... | |
bool | FillResults (FitParameters_t ¶ms, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override |
Fills the specified parameters. More... | |
bool | FillResults (FitParameters_t ¶ms, FitParameters_t ¶merrors, FitMatrix_t &Xmat, Data_t &det, FitMatrix_t &Smat) const override |
Fills the specified parameters. More... | |
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 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... | |
void | clear () |
Clears all the statistics. More... | |
template<typename Stream > | |
void | PrintStats (Stream &out) const |
Prints the collected statistics into a stream. More... | |
Fitting | |
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 | FitParameter (unsigned int n) const override |
Returns the parameter n of the fit result. More... | |
virtual Data_t | FitParameterError (unsigned int n) const override |
Returns the error on parameter n of the fit result. More... | |
virtual Data_t | ChiSquare () const override |
Returns the of the fit. More... | |
virtual int | NDF () const override |
Returns the degrees of freedom in the determination of the fit. 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) |
Statistic retrieval | |
| |
int | N () const |
Data_t | AverageUncertainty () const |
Static Public Member Functions | |
static FitParameters_t | ExtractParameterErrors (FitMatrix_t const &Smat) |
Extracts parameter errors from diagonal of the covarriance matrix. More... | |
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... | |
template<typename V > | |
static constexpr V | sqr (V const &v) |
Returns the square of the specified value. More... | |
Static Public Attributes | |
static constexpr unsigned int | Degree = Base_t::Degree |
Degree of the fit. More... | |
static constexpr unsigned int | NParams = Interface_t::NParams |
Number of parameters in the fit. More... | |
Protected Member Functions | |
virtual FitMatrix_t | MakeMatrixX () const |
Fills and returns the matrix of x^n sum coefficients ( { x^(i+j) } ) More... | |
virtual FitParameters_t | MakeMatrixY () const |
Fills and returns the matrix (vector) of x^n y sum coefficients. More... | |
virtual FitParameters_t | FitParameterErrors (FitMatrix_t const &Smat) const |
Computes and returns all the parameter errors of the fit result. More... | |
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... | |
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... | |
virtual FitParameters_t | FitParameters (FitMatrix_t const &Xmat) const |
Returns the fitted parameters using the provided information. More... | |
virtual FitParameters_t | FitParameters (FitMatrix_t const &Smat, Data_t) const |
Returns the fitted parameters using the provided information. More... | |
virtual Data_t | Param (unsigned int n, FitMatrix_t const &Xmat) const |
Computes a single fit parameter using the given information. More... | |
virtual Data_t | Param (unsigned int n, FitMatrix_t const &Xmat, Data_t detXmat) const |
Computes a single fit parameter using the given information. More... | |
Protected Attributes | |
Collector_t | stats |
statistics collected from fit data input More... | |
Private Types | |
using | Interface_t = SimpleFitterInterface< T, D+1 > |
interface More... | |
using | Base_t = SimplePolyFitterDataBase< T, D > |
class storing input More... | |
Base class providing virtual fitting interface for polynomial fitters.
Definition at line 637 of file SimpleFits.h.
|
private |
class storing input
Definition at line 642 of file SimpleFits.h.
using lar::util::details::SimplePolyFitterBase< T, D >::Data_t = typename Base_t::Data_t |
type of the data
Definition at line 653 of file SimpleFits.h.
using lar::util::details::SimplePolyFitterBase< T, D >::FitMatrix_t = typename Interface_t::FitMatrix_t |
type of matrix for covariance (a std::array)
Definition at line 659 of file SimpleFits.h.
using lar::util::details::SimplePolyFitterBase< T, D >::FitParameters_t = typename Interface_t::FitParameters_t |
type of set of fit parameters
Definition at line 656 of file SimpleFits.h.
|
private |
interface
Definition at line 641 of file SimpleFits.h.
|
inherited |
Definition at line 466 of file SimpleFits.h.
|
inherited |
type of measurement without uncertainty
Definition at line 354 of file SimpleFits.h.
|
inherited |
type of measurement with uncertainty
Definition at line 358 of file SimpleFits.h.
|
inlineinherited |
Definition at line 366 of file SimpleFits.h.
Referenced by cluster::ClusterParamsAlg::IntegrateFitCharge().
|
inlineinherited |
Definition at line 369 of file SimpleFits.h.
|
inlineinherited |
Definition at line 372 of file SimpleFits.h.
|
inlineinherited |
Definition at line 397 of file SimpleFits.h.
|
inlineinherited |
Definition at line 411 of file SimpleFits.h.
|
inlineinherited |
Definition at line 415 of file SimpleFits.h.
|
inlineinherited |
Definition at line 377 of file SimpleFits.h.
|
inlineinherited |
Definition at line 381 of file SimpleFits.h.
|
inlineinherited |
Definition at line 385 of file SimpleFits.h.
|
inlineinherited |
Definition at line 389 of file SimpleFits.h.
|
inlineinherited |
Definition at line 429 of file SimpleFits.h.
|
overridevirtual |
Returns the of the fit.
Implements lar::util::details::SimpleFitterInterface< T, D+1 >.
Reimplemented in lar::util::QuadraticFit< T >, and lar::util::LinearFit< T >.
Definition at line 1741 of file SimpleFits.h.
|
inlineinherited |
Clears all the statistics.
Definition at line 421 of file SimpleFits.h.
|
inlinestaticinherited |
Returns the cube of the specified data value.
Definition at line 610 of file SimpleFits.h.
|
inlineprotectedvirtualinherited |
Computes the determinant of a matrix.
Definition at line 615 of file SimpleFits.h.
|
pure virtualinherited |
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.
|
overridevirtual |
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 1641 of file SimpleFits.h.
|
static |
Extracts parameter errors from diagonal of the covarriance matrix.
Definition at line 1715 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::Degree, and lar::util::details::SimplePolyFitterBase< T, D >::Param().
Referenced by lar::util::details::SimplePolyFitterBase< T, D >::Param().
|
pure virtualinherited |
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 |
|
pure virtualinherited |
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 |
|
pure virtualinherited |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Implemented in lar::util::details::SimplePolyFitterBase< T, 1U >, and lar::util::details::SimplePolyFitterBase< T, 2U >.
|
override |
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 |
Definition at line 1598 of file SimpleFits.h.
|
override |
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 |
Definition at line 1617 of file SimpleFits.h.
|
override |
Fills the specified parameters.
params | the fitted values of the parameters |
paramerrors | the uncertainty on the fitted parameters |
Definition at line 1629 of file SimpleFits.h.
|
inlineoverridevirtual |
Returns the parameter n of the fit result.
n | degree of the parameter; must be no larger than Degree |
std::range_error | if there is no unique solution |
Reimplemented from lar::util::details::SimpleFitterInterface< T, D+1 >.
Definition at line 1548 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::FitParameterError().
Referenced by lar::util::details::SimplePolyFitterBase< T, D >::isValid().
|
overridevirtual |
Computes and returns all the covariance matrix of the fit result.
std::range_error | if there is no unique solution |
The matrix is symmetric, and stored in a linear way (say, first row, then second row).
Implements lar::util::details::SimpleFitterInterface< T, D+1 >.
Definition at line 1585 of file SimpleFits.h.
Referenced by lar::util::details::SimplePolyFitterBase< T, D >::FitParameterErrors().
|
overridevirtual |
Returns the error on parameter n of the fit result.
n | degree of the parameter; must be no larger than Degree |
std::range_error | if there is no unique solution |
Reimplemented from lar::util::details::SimpleFitterInterface< T, D+1 >.
Definition at line 1556 of file SimpleFits.h.
Referenced by lar::util::details::SimplePolyFitterBase< T, D >::FitParameter().
|
overridevirtual |
Computes and returns all the parameter errors of the fit result.
std::range_error | if there is no unique solution |
Implements lar::util::details::SimpleFitterInterface< T, D+1 >.
Definition at line 1576 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::FitParameterCovariance().
|
inlineprotectedvirtual |
Computes and returns all the parameter errors of the fit result.
Definition at line 798 of file SimpleFits.h.
|
overridevirtual |
Computes and returns all the parameters of the fit result.
std::range_error | if there is no unique solution |
Implements lar::util::details::SimpleFitterInterface< T, D+1 >.
Definition at line 1564 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::NParams.
Referenced by lar::util::details::SimplePolyFitterBase< T, D >::FitParameters(), and lar::util::details::SimplePolyFitterBase< T, D >::MakeMatrixY().
|
protectedvirtual |
Returns the fitted parameters using the provided information.
Definition at line 1679 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::FitParameters(), and lar::util::details::FitDataCollector< T, D >::NParams.
|
protectedvirtual |
Returns the fitted parameters using the provided information.
Definition at line 1691 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::Param().
|
inlineprotectedvirtualinherited |
Computes the inverse of a matrix (using provided determinant)
Definition at line 620 of file SimpleFits.h.
|
inlineprotectedvirtualinherited |
Computes the inverse of a matrix.
Definition at line 624 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, D+1 >.
Definition at line 1540 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::FitParameter().
|
protectedvirtual |
Fills and returns the matrix of x^n sum coefficients ( { x^(i+j) } )
Definition at line 1654 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::NParams.
|
protectedvirtual |
Fills and returns the matrix (vector) of x^n y sum coefficients.
Definition at line 1668 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::FitParameters(), and lar::util::details::FitDataCollector< T, D >::NParams.
|
inlineprotectedvirtualinherited |
Computes the product of a FitMatrix_t and a FitParameters_t.
Definition at line 629 of file SimpleFits.h.
|
inlineinherited |
Definition at line 427 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, D+1 >.
Definition at line 731 of file SimpleFits.h.
|
inlineinherited |
Evaluates the fitted function; alias of Evaluate()
Definition at line 603 of file SimpleFits.h.
|
protectedvirtual |
Computes a single fit parameter using the given information.
Definition at line 1700 of file SimpleFits.h.
References lar::util::details::SimplePolyFitterBase< T, D >::ExtractParameterErrors().
Referenced by lar::util::details::SimplePolyFitterBase< T, D >::ExtractParameterErrors(), and lar::util::details::SimplePolyFitterBase< T, D >::FitParameters().
|
protectedvirtual |
Computes a single fit parameter using the given information.
Definition at line 1727 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::NParams.
|
inlineinherited |
Prints the collected statistics into a stream.
Definition at line 436 of file SimpleFits.h.
|
inlinestaticinherited |
Returns the square of the specified value.
Definition at line 441 of file SimpleFits.h.
References geo::sqr().
|
inlinestaticinherited |
Returns the square of the specified data value.
Definition at line 607 of file SimpleFits.h.
|
inlineprotectedinherited |
Returns the weighted sum of x^n.
Definition at line 447 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::XN().
|
inlineprotectedinherited |
Returns the weighted sum of x^n y.
Definition at line 450 of file SimpleFits.h.
References lar::util::details::FitDataCollector< T, D >::XNY().
|
static |
Degree of the fit.
Definition at line 648 of file SimpleFits.h.
|
static |
Number of parameters in the fit.
Definition at line 651 of file SimpleFits.h.
|
protectedinherited |
statistics collected from fit data input
Definition at line 444 of file SimpleFits.h.