Interfaces for the NAG Mark 29.2 fit Chapter.
fit - Curve and Surface Fitting
The main aim of this module is to assist you in finding a function which approximates a set of data points. Typically the data contain random errors, as of experimental measurement, which need to be smoothed out. To seek an approximation to the data, it is first necessary to specify for the approximating function a mathematical form (a polynomial, for example) which contains a number of unspecified coefficients: the appropriate fitting function then derives for the coefficients the values which provide the best fit of that particular form. The module deals mainly with curve and surface fitting (i.e., fitting with functions of one and of two variables) when a polynomial or a cubic spline is used as the fitting function, since these cover the most common needs. However, fitting with other functions and/or more variables can be undertaken by means of general linear or nonlinear functions (some of which are contained in other modules) depending on whether the coefficients in the function occur linearly or nonlinearly. Cases where a graph rather than a set of data points is given can be treated simply by first reading a suitable set of points from the graph.
The module also contains functions for evaluating, differentiating and integrating polynomial and spline curves and surfaces, once the numerical values of their coefficients have been determined.
There is also a function for computing a Padé approximant of a mathematical function (see Background to the Problems).
This subpackage contains examples for the
fitmodule. See also the Examples subsection.
with cubic splines:
Automatic knot placement
with bicubic splines
data on rectangular mesh:
Data on lines:
Data on rectangular mesh:
at a point
at vector of points
of rational functions:
Least squares curve fit
Least squares surface fit
Minimax space fit
Scattered data fit
For full information please refer to the NAG Library document
Minimax curve fit by polynomials.
>>> main() naginterfaces.library.fit.dim1_minimax_polynomial Python Example Results. Minimax curve fit by polynomials. Coefficients of degree-5 polynomial fit of exp: (1.0000e+00, 1.0001e+00, 4.9909e-01, 1.7042e-01, 3.4784e-02, 1.3909e-02)
Spline approximation to a set of scattered data using a two-stage approximation method.
>>> main() naginterfaces.library.fit.dim2_spline_ts_sctr Python Example Results. Fit a spline for the Franke function. Spline value at (0.00, 0.00) is 0.76.