WSTS Data-Fitting Software

Overview

This is a suite of programs to fit functions to discrete data. The programs are written in C++ using the mathematical library and include:

These programs are high-integrity mathematical software. The standard production versions do not include graphics, for portability and to make it easier to run the programs as part of batch processes. However, the output is suitable for reading into most spreadsheets or programs such as GNUPLOT. Versions with built-in graphics are available for a restricted set of platforms - please enquire for more information.

Executable programs:
Platform
Platform
Source code:

POLYFIT: 1D polynomial fitting

POLYFIT finds the best least-squares polynomial to fit data. The data may include weightings for each point.

The program calculates the fitting coefficients, the residual of the fit (sum of squares of deviation from each point), the determinant of the fitting equation (indicating when the fitting process may run into trouble if the problem is ill-conditioned) and the deviation in each point.

Here is an example of the results of polynomial fitting with and without weights, and plotted using GNUPLOT:

polynomial fitting graph

LINFIT: 1D fitting of a linear combination of arbitrary functions

LINFIT finds the best least-squares fit of a set of arbitrary functions to data.The data may include weightings for each point.

The program calculates the fitting coefficients, the residual of the fit (sum of squares of deviation from each point), the determinant of the fitting equation (indicating when the fitting process may run into trouble if the problem is ill-conditioned) and the deviation in each point.

Allowable functions include any of the Realfunction1d class in the WSTS C++ maths library.

Here is an example of the results of the fitting program, plotted using GNUPLOT:

linear fitting graph

LINFITND: ND fitting of a linear combination of arbitrary functions

LINFITND finds the best least-squares fit of a set of arbitrary functions to data. The data may include weightings for each point.

The program calculates the fitting coefficients, the residual of the fit (sum of squares of deviation from each point), the determinant of the fitting equation (indicating when the fitting process may run into trouble if the problem is ill-conditioned) and the deviation in each point.

Allowable functions include any of the Realfunctionnd class in the WSTS C++ maths library.

For an animated example of the results of the fitting program, plotted using GNUPLOT, click here (191 kb).

LINFITGEN: fit a linear combination of arbitrary functions, general version with function values read in as external data

LINFITGEN finds the best least-squares fit of a set of arbitrary functions to data. The data may include weightings for each point. The value of each function at each data point is read in, so the functions may be calculated by any means whatsoever.

The program calculates the fitting coefficients, the residual of the fit (sum of squares of deviation from each point), the determinant of the fitting equation (indicating when the fitting process may run into trouble if the problem is ill-conditioned) and the deviation in each point.

GENITER: general iterative fitting

These programs are intended to help with the fitting of parameters in (possibly very complicated) models to match data (possibly tested with very complicated calculations). They can be used as building blocks for batch files which set up input data for the programs which use the models, extract the relevant output data, and compare against the desired results.

UNIX batch files are also included to connect the programs together for use with any external model, e.g. a continuum mechanics calculation. (The programs can be used on any platform, but corresponding batch files will beed to be written if UNIX is not available.)

CONVOLVE: 1D convolution and deconvolution

CONVOLVE convolves or deconvolves tabulated functions using fast Fourier transforms.

The program takes as input two functions, f and g say, described as tables. If asked to convolve the functions, the program calculates f*g. If asked to deconvolve the functions, the program takes f as being h*g for some function h, which it calculates.

RNDPTS: generator for random points in ND

RNDPTS generates random points over a specified region, which may be arbitrarily complicated. The density of points may be any function of position.

The input data specifies a surface within which all points are to lie, and a range for each spatial coordinate over which to look for candidate points. Allowable surfaces include any of the Surface class in the WSTS C++ maths library.

The density function is the probability that any candidate point will be accepted. (Values greater than or equal to 1 are always accepted.) Allowable functions include any of the Realfunctionnd class in the WSTS C++ maths library.

FNGEN: generator for 1D sample data

FNGEN generates data for testing data-fitting programs.

The input data specifies a set of functions and the amplitude for each, and a noise function with amplitude and offset.

Allowable functions include any of the Realfunction1d class in the WSTS C++ maths library. Allowable random number generators include any of the Random_number_generator class in the WSTS C++ maths library. The offset and amplitude functions allow the noise properties to be varied with position.

FNGENND: generator for ND sample data

FNGENND generates data for testing data-fitting programs.

The input data specifies a set of functions and the amplitude for each, and a noise function with amplitude and offset.

Allowable functions include any of the Realfunctionnd class in the WSTS C++ maths library.

Allowable random number generators include any of the Random_number_generator class in the WSTS C++ maths library. The offset and amplitude functions allow the noise properties to be varied with position.

PLANEFIT: fit a (hyper)plane to data

PLANEFIT finds the best least-squares fit of a hyperplane to a set of data. The data may include weightings for each point.

The program calculates the parameters of the plane (its normal vector and family parameter) and the deviation of each data point from the fit. The program operates in any number of space dimensions.

For an animated example of the results of the fitting program, plotted using GNUPLOT, click here (184 kb).

SPHEREFIT: fit a (hyper)sphere to data

SPHEREFIT finds the best least-squares fit of a hypersphere to a set of points, by solving a matrix equation rather than simply averaging points. The data may include weightings for each point.

The program calculates the parameters of the sphere (its centre and radius), and operates in any number of space dimensions.

ELLIPSOIDFIT: fit a (hyper)ellipsoid to data

ELLIPSOIDFIT finds the best least-squares fit of a hyperellipsoid to a set of points. The data may include weightings for each point.

The program calculates the parameters of the ellipsoid (its centre and half-axes), and operates in any number of space dimensions. The principal axes of the ellipsoid are parallel with the coordinate directions.

The centre of the ellipsoid may be defined by the user, or calculated by a (weighted) average of the points.

GENELLIPSOIDFIT: fit a general (hyper)ellipsoid to data

GENELLIPSOIDFIT finds the best least-squares fit of a general hyperellipsoid - where the principal axes may point in any direction - to a set of points. The data may include weightings for each point. The axes must be chosen by the user.

The program calculates the parameters of the ellipsoid (its centre and half-axes), and operates in any number of space dimensions. The half-axes are expressed in terms of the axis vectors: if these are not unit vectors then the half-axes will vary with the length chosen.

The centre of the ellipsoid may be defined by the user, or calculated by a (weighted) average of the points.