A framework for fitting functions to data with SciPy which unifies the various available interpolation methods and provides a common interface to them based on the following simple methods:
Fitter.__init__(p)
: set parameters of interpolation function, e.g. polynomial degreeFitter.fit(x, y)
: fit given input-output dataFitter.__call__(x)
orFitter.eval(x)
: evaluate function on new input data
Each interpolation routine falls in one of two categories: scatter fitting or
grid fitting. They share the same interface, only differing in the definition
of input data x
.
Scatter-fitters operate on unstructured scattered input data (i.e. not on a
grid). The input data consists of a sequence of x
coordinates and a sequence
of corresponding y
data, where the order of the x
coordinates does not
matter and their location can be arbitrary. The x
coordinates can have an
arbritrary dimension (although most classes are specialised for 1-D or 2-D
data). If the dimension is bigger than 1, the coordinates are provided as an
array of column vectors. These fitters have ScatterFit
as base class.
Grid-fitters operate on input data that lie on a grid. The input data consists
of a sequence of x-axis tick sequences and the corresponding array of y
data. These fitters have GridFit
as base class.
The module is organised as follows:
ScatterFit
: Abstract base class for scatter fittersLinearLeastSquaresFit
: Fit linear regression model to data using SVDPolynomial1DFit
: Fit polynomial to 1-D dataPolynomial2DFit
: Fit polynomial to 2-D dataPiecewisePolynomial1DFit
: Fit piecewise polynomial to 1-D dataIndependent1DFit
: Interpolate N-dimensional matrix along given axisDelaunay2DScatterFit
: Interpolate scalar function of 2-D data, based on Delaunay triangulation and cubic / linear interpolationNonLinearLeastSquaresFit
: Fit a generic function to data, based on non-linear least squares optimisationGaussianFit
: Fit Gaussian curve to multi-dimensional dataSpline1DFit
: Fit a B-spline to 1-D dataSpline2DScatterFit
: Fit a B-spline to scattered 2-D dataRbfScatterFit
: Do radial basis function (RBF) interpolation
GridFit
: Abstract base class for grid fittersSpline2DGridFit
: Fit a B-spline to 2-D data on a rectangular grid
squash
: Flatten array, but not necessarily all the way to a 1-D arrayunsquash
: Restore an array that was reshaped bysquash
sort_grid
: Ensure that the coordinates of a rectangular grid are in ascending orderdesort_grid
: Undo the effect ofsort_grid
vectorize_fit_func
: Factory that creates vectorised version of function to be fitted to datarandomise
: Randomise fitted function parameters by resampling residuals
https://github.com/ska-sa/scikits.fitting
Ludwig Schwardt <ludwig at ska.ac.za>