NAME

nst_wlsq_fit -- compute weighted least squares fit

PROTOTYPE

float nst_wlsq_fit(int iNum, int iDimX, int iDimY, float **ppfX, float **ppfY, float *pfG, float *pfA)

ARGUMENTS

int iNum
nr of data pairs (X,Y)
int iDimX
dimension of each input vector X
int iDimY
dimension of each output vector Y
float **ppfX
iNum ptrs to input data vectors X
float **ppfY
iNum ptrs to output data vectors Y
float *pfG
iNum non-negative weights. pfW=NULL selects weights = 1
float *pfA
result: iDimY x (1+iDimX) matrix A. pfA is assumed to point to sufficient memory.

DESCRIPTION:

Solves the weighted least squares problem that consists of minimizing

S[A] = sum_i=0^iNum-1 g_i * (Ax_i - y_i)^2

as a function of the matrix A. Each vector x_i is considered to be the iDimX dimensional i-th data vector, but with an additional bias element of value 1 appended: x=(X_i,1). Thus, each x_i is iDimX+1 dimensional, and the result matrix A is iDimY x (iDimX+1). The additional, rightmost row provides the necessary bias vector for non-centered Y-data and contains the weighted average of all Y vectors.

ALGORITHM:

The result matrix A must obey the normal equations

     A XX' = YX'

A solution to these equations is found with a singular value decomposition of C=XX', setting singular components to zero:

     C = UVW'
    1/C := VDU'

with D_ii = 1/W_ii if W_ii is nonzero, 0 else. This always singles out the minimum norm solution for A, no matter how singular XX' is.

FILE

/local/homes/rhaschke/nst7/man/../o.linx86//../nstsrc/nst_nr.c