Woolz Image Processing  Version 1.7.5
AlgFit

## Files

file  AlgLinearFit.c
Provides functions for fitting linear models to data, ie linear regression.

file  AlgPolyLSQ.c
Provides functions for fitting a polynomial using least squares.

## Functions

AlgError AlgLinearFit1D (int datSz, double *datXA, double *datYA, double *dstA, double *dstB, double *dstSigA, double *dstSigB, double *dstQ)
Computes the least squares best fit straight line (y = a + bx) through the given data, ie linear regression. This function is based on the function fit(): Press W. H., Teukolsky S. A., Vetterling W. T. and Flannery B. P, Numerical Recipies in C, 1992, CUP. More...

AlgError AlgLinearFitIdx1D (double *datXA, double *datYA, int *idxXA, int *idxYA, int idxASz, double *dstA, double *dstB, double *dstSigA, double *dstSigB, double *dstQ)
Computes the least squares best fit straight line (y = a + bx) through the given data, ie linear regression. More...

AlgError AlgPolynomialLSq (double *xVec, double *yVec, int vecSz, int polyDeg, double *cVec)
Attempts to fit a polynomial to the given data using a least squares approach. More...

## Function Documentation

 AlgError AlgLinearFit1D ( int datSz, double * datXA, double * datYA, double * dstA, double * dstB, double * dstSigA, double * dstSigB, double * dstQ )

Computes the least squares best fit straight line (y = a + bx) through the given data, ie linear regression. This function is based on the function fit(): Press W. H., Teukolsky S. A., Vetterling W. T. and Flannery B. P, Numerical Recipies in C, 1992, CUP.

Returns
Error code.
Parameters
 datSz Number of elements in given data arrays array. datXA Data array with 'x' values. datYA Data array with 'y' values. dstA Destination ptr for intercept 'a', may be NULL. dstB Destination ptr for gradient 'b', may be NULL. dstSigA Destination ptr for std dev of 'a', may be NULL. dstSigB Destination ptr for std dev of 'b', may be NULL. dstQ Destination ptr for goodness of fit, may be NULL.

References ALG_ERR_FUNC, ALG_ERR_NONE, and AlgGammaP().

 AlgError AlgLinearFitIdx1D ( double * datXA, double * datYA, int * idxXA, int * idxYA, int idxASz, double * dstA, double * dstB, double * dstSigA, double * dstSigB, double * dstQ )

Computes the least squares best fit straight line (y = a + bx) through the given data, ie linear regression.

Returns
Error code.
Parameters
 datXA Data array with 'x' values. datYA Data array with 'y' values. idxXA Index array with indicies into the 'x' data buffer. for the values use examine. idxYA Index array with indicies into the 'y' data buffer. for the values use examine. idxASz Number of elements in each of the given index arrays. dstA Destination ptr for intercept 'a', may be NULL. dstB Destination ptr for gradient 'b', may be NULL. dstSigA Destination ptr for std dev of 'a', may be NULL. dstSigB Destination ptr for std dev of 'b', may be NULL. dstQ Destination ptr for goodness of fit, may be NULL.

References ALG_ERR_FUNC, ALG_ERR_NONE, and AlgGammaP().

 AlgError AlgPolynomialLSq ( double * xVec, double * yVec, int vecSz, int polyDeg, double * cVec )

Attempts to fit a polynomial to the given data using a least squares approach.

Returns
Error code.
Parameters
 xVec Data vector x of size vecSz. yVec Data vector y of size vecSz. vecSz Size of data vectors. polyDeg Degree of ploynomial. cVec Destination vector for the polynomial coefficients, which must have at least polyDeg + 1 elements.