Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Analytical solution for Orthogonal Linear Least Squares in two dimensions 1.0

Date Added: September 01, 2013  |  Visits: 227

ORTHLLS2D returns the Orthogonal Linear Least Squares estimate for parameters of line a x + b y + c = 0function f = OrthLLS2D(x, y)Inputs x and y must be real vectors of equal size.Output f is the real vector [a b c] where a, b and c are the estimated parameters of the linear equation.Since a more general function called LINORTFITN has already been submitted to File Exchange (ID number: 16800) in October 2007 by Mr. F. Carr, my file is supposed to be used as a brief introduction to the analytical problem in an extremely simple case.Orthogonal Least Squares Estimate on a plane, in the simple case of a linear equation, is in fact a problem that can be easily solved analytically with no approximation (see pdf file for detailed explanation). Notice that in the general multidimensional case, an analytical solution may not exist (although Mr. Carr's function is an efficient approximation of the solution).% ====================================================% EXAMPLE: HOW TO USE THE FUNCTION% ====================================================Build two series, given the linear relation y = mx + q + errorT = 1000; % number of pointsm = -1; % slopeq = 1; % interceptx = randn(T, 1); % random x valuesu = randn(T, 1); % random errory = m * x + q + u; % y = mx + q + errorf = OrthLLS2D(x, y); % estimate [a, b, c] for equation ax + by + c = 0plot(x, y, '.') % scatter plot for empirical pointshold onplot(x, [ones(T,1) x] * [-f(3); -f(1)], '*r');% plot orthogonal linear least squaresb1 = regress(y, [ones(T,1) x]); % parameters of the ordinary least squares (y as a function of x)b2 = regress(x, [ones(T,1) y]); % parameters of the ordinary least squares (x as a function of y)plot(x, [ones(T,1) x] * b1, '.g'); % plot ordinary least squares (y as a function of x)plot([ones(T,1) y] * b2, y, '.c'); % plot ordinary least squares (x as a function of y)% ====================================================See also LINORTFIT2, LINORTFITN.

 Requirements: No special requirements Platforms: Matlab Keyword: Build,  Efficient,  Error,  Function,  Points,  Relation,  Series,  Slope Users rating: 0/10