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...
 

Detailed Description

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
datSzNumber of elements in given data arrays array.
datXAData array with 'x' values.
datYAData array with 'y' values.
dstADestination ptr for intercept 'a', may be NULL.
dstBDestination ptr for gradient 'b', may be NULL.
dstSigADestination ptr for std dev of 'a', may be NULL.
dstSigBDestination ptr for std dev of 'b', may be NULL.
dstQDestination 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
datXAData array with 'x' values.
datYAData array with 'y' values.
idxXAIndex array with indicies into the 'x' data buffer. for the values use examine.
idxYAIndex array with indicies into the 'y' data buffer. for the values use examine.
idxASzNumber of elements in each of the given index arrays.
dstADestination ptr for intercept 'a', may be NULL.
dstBDestination ptr for gradient 'b', may be NULL.
dstSigADestination ptr for std dev of 'a', may be NULL.
dstSigBDestination ptr for std dev of 'b', may be NULL.
dstQDestination 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
xVecData vector x of size vecSz.
yVecData vector y of size vecSz.
vecSzSize of data vectors.
polyDegDegree of ploynomial.
cVecDestination vector for the polynomial coefficients, which must have at least polyDeg + 1 elements.

References AlcFree(), AlcMalloc(), ALG_DBG, ALG_DBG_LVL_1, ALG_DBG_LVL_FN, ALG_ERR_FUNC, ALG_ERR_MALLOC, AlgMatrixGaussSolve(), AlgMatrixRectFree(), AlgMatrixRectNew(), _AlgMatrixRect::array, _AlgMatrix::core, and _AlgMatrix::rect.