NMath User's Guide

TOC | Previous | Next | Index

Chapter 8. Least Squares (.NET, C#, CSharp, VB, Visual Basic, F#)

NMath provides classes for computing the minimum-norm solution to a linear system Ax = y. In a linear model, a quantity y depends on one or more independent variables a1, a2,...,an such that y = x0 + x1a1 + ... + xnan. (Parameter x0 is called the intercept parameter.) The goal of a least squares problem is to solve for the best values of x0, x1,...,xn.

Several observations of the independent values ai are recorded, along with the corresponding values of the dependent variable y. If m observations are performed, and for the ith observation we denote the values of the independent variables ai1, ai2,...,ain and the corresponding dependent value of y as yi, then we form the linear system Ax = y, where A = (aij) and y = (yi). The general least squares solution is the value of x that minimizes ||Ax - y||. The nonnegative least squares solution is the value of x subject to the constraint that each element of x is nonnegative.

Note that if the model contains a non-zero intercept parameter, then the first column of A is all ones.

The NMath least squares classes use a complete orthogonal factorization of A to compute the solution. Matrix A is rectangular, and may be rank deficient.


Top

Top