npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::LocalQuadraticLeastSquaresND< Point, Numeric > Class Template Reference

#include <LocalQuadraticLeastSquaresND.hh>

Public Member Functions

 LocalQuadraticLeastSquaresND (unsigned polyDegree, const AbsDistributionND &weight, const double *bandwidthValues, unsigned nBandwidthValues, const Point *pointCoords, unsigned nPoints, const Numeric *values, const Numeric *errors=0)
 
unsigned dim () const
 
unsigned polyDegree () const
 
unsigned nPoints () const
 
unsigned nTermsFitted () const
 
bool hasErrors () const
 
double getBandwidth (const unsigned bwNumber) const
 
double chiSquare () const
 
double lscvCriterion () const
 
void setPointCoords (const Point *newCoords)
 
void setValues (const Numeric *newValues)
 
void setErrors (const Numeric *newErrors)
 
void setBandwidth (const unsigned bwNum, const double newBw)
 
Matrix< double > smootherMatrix (double stepInErrorUnits=1.0e-3) const
 
template<typename Num2 >
double fit (const Num2 *coordinate, unsigned coordinateDim, double *gradient=0, unsigned lenGradient=0, double *hessian=0, unsigned lenHessian=0, unsigned excludedPoint=UINT_MAX) const
 

Detailed Description

template<class Point, typename Numeric>
class npstat::LocalQuadraticLeastSquaresND< Point, Numeric >

Local quadratic least squares fitter. Template parameter class Point must be subscriptable.

Constructor & Destructor Documentation

◆ LocalQuadraticLeastSquaresND()

template<class Point , typename Numeric >
npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::LocalQuadraticLeastSquaresND ( unsigned  polyDegree,
const AbsDistributionND weight,
const double *  bandwidthValues,
unsigned  nBandwidthValues,
const Point *  pointCoords,
unsigned  nPoints,
const Numeric *  values,
const Numeric *  errors = 0 
)

The "polyDegree" parameter must be 0, 1, or 2.

All values in the "bandwidthValues" array must be positive and their number, "nBandwidthValues", must be equal to the dimensionality of the weight function, weight.dim(). The bandwidth values will be copied into an internal buffer.

Make sure that the bandwidth values are sufficiently large so that the number of points for which the weight function is positive is always at least as large as the number of polynomial terms fitted. This must be true for every future "fit" call.

This object will not copy or own "pointCoords", "values", or "errors" arrays. The number of elements in all of these arrays must be the same and equal to "nPoints". All errors must be positive. The "errors" array can also be NULL in which case all errors are assumed to be equal.

Member Function Documentation

◆ chiSquare()

template<class Point , typename Numeric >
double npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::chiSquare ( ) const

The following function returns the chi-square of the fit. If the errors have not been specified, the sum of squared differences is returned (as if each error is set to 1).

◆ dim()

template<class Point , typename Numeric >
unsigned npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::dim ( ) const
inline

Examine object properties

◆ fit()

template<class Point , typename Numeric >
template<typename Num2 >
double npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::fit ( const Num2 *  coordinate,
unsigned  coordinateDim,
double *  gradient = 0,
unsigned  lenGradient = 0,
double *  hessian = 0,
unsigned  lenHessian = 0,
unsigned  excludedPoint = UINT_MAX 
) const

Perfom local quadratic polynomial fit with weight function centered at "coordinate". In additional to the fitted value, one can get the gradient and the Hessian at the fitted point, as estimated by the fit.

◆ lscvCriterion()

template<class Point , typename Numeric >
double npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::lscvCriterion ( ) const

The following function returns the chi-square obtained by the leave-one-out least squares cross validation

◆ setBandwidth()

template<class Point , typename Numeric >
void npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::setBandwidth ( const unsigned  bwNum,
const double  newBw 
)
inline

Change bandwidth used for weight calculations

◆ setErrors()

template<class Point , typename Numeric >
void npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::setErrors ( const Numeric *  newErrors)
inline

Change errors for the point locations provided in the constructor. The array must have at least "nPoints()" elements (or it can be NULL).

◆ setPointCoords()

template<class Point , typename Numeric >
void npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::setPointCoords ( const Point *  newCoords)
inline

Change the point coordinates. Note that the number of new coordinates must be exactly equal to the number of points provided in the constructor. The array will not be copied.

◆ setValues()

template<class Point , typename Numeric >
void npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::setValues ( const Numeric *  newValues)
inline

Change values for the point locations provided in the constructor. The array must have at least "nPoints()" elements.

◆ smootherMatrix()

template<class Point , typename Numeric >
Matrix<double> npstat::LocalQuadraticLeastSquaresND< Point, Numeric >::smootherMatrix ( double  stepInErrorUnits = 1.0e-3) const

Estimate of the smoother matrix. Will be nPoints x nPoints in size, so this works only for relatively small datasets. Smoother matrix plays similar role to the hat matrix.


The documentation for this class was generated from the following file: