Simbody  3.6
SimTK::SplineFitter< T > Class Template Reference

Given a set of data points, this class creates a Spline_ which interpolates or approximates them. More...

Classes

class  SplineFitterImpl
 

Public Member Functions

 SplineFitter (const SplineFitter &copy)
 
SplineFitter operator= (const SplineFitter &copy)
 
 ~SplineFitter ()
 
const Spline_< T > & getSpline ()
 Get the Spline_ that was generated by the fitting. More...
 
Real getSmoothingParameter ()
 Get the smoothing parameter that was used for the fitting. More...
 
Real getMeanSquaredError ()
 Get the estimate of the true mean squared error in the data that was determined by the fitting. More...
 
Real getDegreesOfFreedom ()
 Get the estimate of the number of degrees of freedom of the residual that was determined by the fitting. More...
 

Static Public Member Functions

static SplineFitter fitFromGCV (int degree, const Vector &x, const Vector_< T > &y)
 Perform a fit, choosing a value of the smoothing parameter that minimizes the Generalized Cross Validation function. More...
 
static SplineFitter fitFromErrorVariance (int degree, const Vector &x, const Vector_< T > &y, Real error)
 Perform a fit, choosing a value of the smoothing parameter based on the known error variance in the data. More...
 
static SplineFitter fitFromDOF (int degree, const Vector &x, const Vector_< T > &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. More...
 
static SplineFitter fitForSmoothingParameter (int degree, const Vector &x, const Vector_< T > &y, Real p)
 Perform a fit, using a specified fixed value for the smoothing parameter. More...
 

Detailed Description

template<class T>
class SimTK::SplineFitter< T >

Given a set of data points, this class creates a Spline_ which interpolates or approximates them.

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<Vec3> fitter = SplineFitter::fitFromGCV(degree, x, y);
Spline_<Vec3> 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.

Constructor & Destructor Documentation

◆ SplineFitter()

template<class T >
SimTK::SplineFitter< T >::SplineFitter ( const SplineFitter< T > &  copy)
inline

◆ ~SplineFitter()

template<class T >
SimTK::SplineFitter< T >::~SplineFitter ( )
inline

Member Function Documentation

◆ operator=()

template<class T >
SplineFitter SimTK::SplineFitter< T >::operator= ( const SplineFitter< T > &  copy)
inline

◆ fitFromGCV()

template<class T >
static SplineFitter SimTK::SplineFitter< T >::fitFromGCV ( int  degree,
const Vector x,
const Vector_< T > &  y 
)
inlinestatic

Perform a fit, choosing a value of the smoothing parameter that minimizes the Generalized Cross Validation function.

Parameters
[in]degreeThe degree of the spline to create. This must be a positive, odd integer.
[in]xThe value of the independent variable for each data point.
[in]yThe values of the dependent variables for each data point.
Returns
A SplineFitter object containing the desired Spline_.

◆ fitFromErrorVariance()

template<class T >
static SplineFitter SimTK::SplineFitter< T >::fitFromErrorVariance ( int  degree,
const Vector x,
const Vector_< T > &  y,
Real  error 
)
inlinestatic

Perform a fit, choosing a value of the smoothing parameter based on the known error variance in the data.

Parameters
[in]degreeThe degree of the spline to create. This must be a positive, odd integer.
[in]xThe value of the independent variable for each data point.
[in]yThe values of the dependent variables for each data point.
[in]errorThe variance of the error in the data.
Returns
A SplineFitter object containing the desired Spline_.

◆ fitFromDOF()

template<class T >
static SplineFitter SimTK::SplineFitter< T >::fitFromDOF ( int  degree,
const Vector x,
const Vector_< T > &  y,
Real  dof 
)
inlinestatic

Perform a fit, choosing a value of the smoothing parameter based on the expect number of degrees of freedom of the residual.

Parameters
[in]degreeThe degree of the spline to create. This must be a positive, odd value.
[in]xThe value of the independent variable for each data point.
[in]yThe values of the dependent variables for each data point.
[in]dofThe expected number of degrees of freedom.
Returns
A SplineFitter object containing the desired Spline_.

◆ fitForSmoothingParameter()

template<class T >
static SplineFitter SimTK::SplineFitter< T >::fitForSmoothingParameter ( int  degree,
const Vector x,
const Vector_< T > &  y,
Real  p 
)
inlinestatic

Perform a fit, using a specified fixed value for the smoothing parameter.

Parameters
[in]degreeThe degree of the spline to create. This must be a positive, odd value.
[in]xThe value of the independent variable for each data point.
[in]yThe values of the dependent variables for each data point.
[in]pThe value of the smoothing parameter.
Returns
A SplineFitter object containing the desired Spline_.

◆ getSpline()

template<class T >
const Spline_<T>& SimTK::SplineFitter< T >::getSpline ( )
inline

Get the Spline_ that was generated by the fitting.

◆ getSmoothingParameter()

template<class T >
Real SimTK::SplineFitter< T >::getSmoothingParameter ( )
inline

Get the smoothing parameter that was used for the fitting.

◆ getMeanSquaredError()

template<class T >
Real SimTK::SplineFitter< T >::getMeanSquaredError ( )
inline

Get the estimate of the true mean squared error in the data that was determined by the fitting.

◆ getDegreesOfFreedom()

template<class T >
Real SimTK::SplineFitter< T >::getDegreesOfFreedom ( )
inline

Get the estimate of the number of degrees of freedom of the residual that was determined by the fitting.


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