LinearFitCnstrntLU.h

Classes

LinearFitConstraintLU -- Solve Linear fit with constraints with LU factorization method (full description)

class LinearFitConstraintLU:public LinearFitConstraint<Type>

Interface

Public Members
LinearFitConstraintLU()
virtual ~LinearFitConstraintLU()
virtual Vector<Type> fit(const Vector<Type> &x, const Vector<Type> &y, const Vector<Type> &sigma)
virtual Vector<Type> fit(const Matrix<Type> &x, const Vector<Type> &y, const Vector<Type> &sigma)
virtual Matrix<Type> compuCovariance()

Description

Review Status

Programs:
Tests:

Prerequisite

Etymology

A linear combination of functions is used to fit a set data points. The parameters being fitted are subjected to linear constraints.

Synopsis

The following is a brief summary of the linear least-squares fit with constraint problem. See module header, Fitting.h, for a more complete description.

Given a set of N data points (measurements), (x(i), y(i)) i = 0,...,N-1, along with a set of standard deviations, sigma(i), for the data points, and M specified functions, f(j)(x) j = 0,...,M-1, we form a linear combination of the functions:

    z(i) = a(0)f(0)(x(i)) + a(1)f(1)(x(i)) + ... + a(M-1)f(M-1)(x(i)),
    
where a(j) j = 0,...,M-1 are a set of parameters to be determined.

Besides the M specified functions, we are also given a set of P linear equations (constraints) for the parameters a(i) to satisfy:

    e(0,j)a(0) + e(1,j)a(1) + ... + e(M-1,j)a(M-1) + c(j) = 0, j=0,P-1,
    
where e(i,j) and c are known constants. The linear least-squares fit with constraints tries to minimize chi-square
    chi-square = [(y(0)-z(0))/sigma(0)]^2 + [(y(1)-z(1))/sigma(1)]^2 + ... 
                 + [(y(N-1)-z(N-1))/sigma(N-1)]^2.
    
by adjusting parameters a(i) within the limit imposed by the constraint equations.

If we define

    A(i,j) = function(j)(x(i))/sigma(i)
    b(i) = y(i)/sigma(i)
    
The chi-square we are trying to minimize becomes:
    chi-square = |A*a -b|^2 
    
The constraint equations are
    e(0,j)a(0) + e(1,j)a(1) + ... + e(M-1,j)a(M-1) + c(j) = 0; j = 0, P-1
    
The matrix equation to be solved then becomes
    |(trans(A)*A)  e | |  a   |  =  |trans(A)*b|
    |  trans(e)    0 | |lambda|     |   -c     |
    
where lambda = (lambda(0), lambda(1), ..., lambda(P-1)) are coefficients. The above matrix equation can be expressed as D*d = g. This class solves the equation using the LU factorization method. The covariance matrix is the inverse of (trans(A)*A). If no constraints are imposed, this class solves the normal equation of linear fit problem using the LU factorization method.

Motivation

Sometimes, the fitted parameters of a linear least-squares fit are related to each other through some specified equations (known constraints). This requires fit be performed under the constraints.

Template Arguments

The following data types can be used to instantiate the LinearFitConstraintLU template class:

  • Float
  • Double
  • Complex
  • DComplex

    Issues of Precision

    If the class is instantaited with Float, all computations are carried out in single precision. If more precise results are desired, Double should be used.

    Large Number of Unknowns or Large Number of Data Points

    If there are a large Number of unknowns or a large number of data points machine memory limit may not allow a complete in core fitting (calling fit(...) function) to be performed. In this case one can incrementally build the normal equations.

    Member Description

    LinearFitConstraintLU()

    virtual ~LinearFitConstraintLU()

    virtual Vector<Type> fit(const Vector<Type> &x, const Vector<Type> &y, const Vector<Type> &sigma)

    fit() performs least-squares fit on the supplied x, y, and sigma. For complex data, user should supply sigma for both real and imaginary parts. Returns fitted parameters in a vector.

    Tip Data points with sigma = 0 and -1 are ignored. Points with sigma = 0 should be treated as constraints. Currently, only linear fit with linear known constraints are handled.

    This function is for fitting onedimensional (1D) function to data points. Here 1D means the fitted function f(x) is a function of one variable, x.

    virtual Vector<Type> fit(const Matrix<Type> &x, const Vector<Type> &y, const Vector<Type> &sigma)

    fit() performs least-squares fit on the supplied x, y, and sigma. For complex data, user should supply sigma for both real and imaginary parts. Returns fitted parameters in a vector.

    Tip Data points with sigma = 0 and -1 are ignored. Points with sigma = 0 should be treated as constraints. Currently, only linear fit with linear known constraints are handled.

    This function is for fitting multidimensional (ND) function to data points. Here ND means the fitted function f(x0,x1,...,xn) is a function of n variables, x0,x1,...,xn. As input, a row of x, x(i,l) l = 0, L-1, where L denotes the number of independent variables, contains the variables corresponding to a single mesurement y(i).

    virtual Matrix<Type> compuCovariance()