#include <SplineFitter.h>
The data points are assumed to represent a smooth curve plus uncorrelated additive noise. It attempts to separate these from each other and return a Spline which represents the original curve without noise.
The fitting is done based on a smoothing parameter. When the parameter is 0, the spline will exactly interpolate the data points. Larger values of the smoothing parameter produce smoother curves that may vary more from the original data. Since you generally do not know in advance what value for the smoothing parameter is "best", several different methods are provided for selecting it automatically.
If you have no prior information about the structure of the input data, call fitFromGCV():
SplineFitter<1> fitter = SplineFitter::fitFromGCV(degree, x, y); Spline<1> spline = fitter.getSpline();
This chooses a value of the smoothing parameter to minimize the Generalized Cross Validation function. It also estimates the true mean squared error of the data the the number of degrees of freedom of the residual (that is, the number of degrees of freedom not explained by the spline), which can be queried by calling getMeanSquaredError() and getDegreesOfFreedom(). Alternatively, if you have prior knowledge of the error variance or residual degrees of freedom, you can call fitFromErrorVariance() or fitFromDOF() instead. Finally, you can explicitly specify the smoothing parameter to use by calling fitForSmoothingParameter().
For more information on the GCVSPL algorithm, see Woltring, H.J. (1986), A FORTRAN package for generalized, cross-validatory spline smoothing and differentiation. Advances in Engineering Software 8(2):104-113. Also, while this class provides access to the most important features of the algorithm, there are a few advanced options which it does not expose directly. If you need those options, you can access them using the GCVSPLUtil class.
Public Member Functions | |
SplineFitter (const SplineFitter ©) | |
SplineFitter | operator= (const SplineFitter ©) |
~SplineFitter () | |
const Spline< N > & | getSpline () |
Get the Spline that was generated by the fitting. | |
Real | getSmoothingParameter () |
Get the smoothing parameter that was used for the fitting. | |
Real | getMeanSquaredError () |
Get the estimate of the true mean squared error in the data that was determined by the fitting. | |
Real | getDegreesOfFreedom () |
Get the estimate of the number of degrees of freedom of the residual that was determined by the fitting. | |
Static Public Member Functions | |
static SplineFitter | fitFromGCV (int degree, const Vector &x, const Vector_< Vec< N > > &y) |
Perform a fit, choosing a value of the smoothing parameter that minimizes the Generalized Cross Validation function. | |
static SplineFitter | fitFromErrorVariance (int degree, const Vector &x, const Vector_< Vec< N > > &y, Real error) |
Perform a fit, choosing a value of the smoothing parameter based on the known error variance in the data. | |
static SplineFitter | fitFromDOF (int degree, const Vector &x, const Vector_< Vec< N > > &y, Real dof) |
Perform a fit, choosing a value of the smoothing parameter based on the expect number of degrees of freedom of the residual. | |
static SplineFitter | fitForSmoothingParameter (int degree, const Vector &x, const Vector_< Vec< N > > &y, Real p) |
Perform a fit, using a specified fixed value for the smoothing parameter based. | |
Classes | |
class | SplineFitterImpl |
SplineFitter | ( | const SplineFitter< N > & | copy | ) | [inline] |
References SplineFitter::SplineFitterImpl::referenceCount.
~SplineFitter | ( | ) | [inline] |
References SplineFitter::SplineFitterImpl::referenceCount.
SplineFitter operator= | ( | const SplineFitter< N > & | copy | ) | [inline] |
References SplineFitter::impl, and SplineFitter::SplineFitterImpl::referenceCount.
static SplineFitter fitFromGCV | ( | int | degree, | |
const Vector & | x, | |||
const Vector_< Vec< N > > & | y | |||
) | [inline, static] |
Perform a fit, choosing a value of the smoothing parameter that minimizes the Generalized Cross Validation function.
degree | the degree of the spline to create. This must be a positive odd value. | |
x | the values of the independent variable for each data point | |
y | the values of the dependent variables for each data point |
References GCVSPLUtil::gcvspl(), fkinkryx::ier, VectorBase::size(), and y.
static SplineFitter fitFromErrorVariance | ( | int | degree, | |
const Vector & | x, | |||
const Vector_< Vec< N > > & | y, | |||
Real | error | |||
) | [inline, static] |
Perform a fit, choosing a value of the smoothing parameter based on the known error variance in the data.
degree | the degree of the spline to create. This must be a positive odd value. | |
x | the values of the independent variable for each data point | |
y | the values of the dependent variables for each data point | |
error | the variance of the error in the data |
References GCVSPLUtil::gcvspl(), fkinkryx::ier, VectorBase::size(), and y.
static SplineFitter fitFromDOF | ( | int | degree, | |
const Vector & | x, | |||
const Vector_< Vec< N > > & | y, | |||
Real | dof | |||
) | [inline, static] |
Perform a fit, choosing a value of the smoothing parameter based on the expect number of degrees of freedom of the residual.
degree | the degree of the spline to create. This must be a positive odd value. | |
x | the values of the independent variable for each data point | |
y | the values of the dependent variables for each data point | |
dof | the expected number of degrees of freedom |
References GCVSPLUtil::gcvspl(), fkinkryx::ier, VectorBase::size(), and y.
static SplineFitter fitForSmoothingParameter | ( | int | degree, | |
const Vector & | x, | |||
const Vector_< Vec< N > > & | y, | |||
Real | p | |||
) | [inline, static] |
Perform a fit, using a specified fixed value for the smoothing parameter based.
degree | the degree of the spline to create. This must be a positive odd value. | |
x | the values of the independent variable for each data point | |
y | the values of the dependent variables for each data point | |
p | the value of the smoothing parameter |
References GCVSPLUtil::gcvspl(), fkinkryx::ier, VectorBase::size(), and y.
const Spline<N>& getSpline | ( | ) | [inline] |
Get the Spline that was generated by the fitting.
References SplineFitter::SplineFitterImpl::spline.
Real getSmoothingParameter | ( | ) | [inline] |
Get the smoothing parameter that was used for the fitting.
References SplineFitter::SplineFitterImpl::p.
Real getMeanSquaredError | ( | ) | [inline] |
Get the estimate of the true mean squared error in the data that was determined by the fitting.
References SplineFitter::SplineFitterImpl::error.
Real getDegreesOfFreedom | ( | ) | [inline] |
Get the estimate of the number of degrees of freedom of the residual that was determined by the fitting.
References SplineFitter::SplineFitterImpl::dof.