The LADFIT function fits the paired data { xi , yi } to the linear model, y = A + Bx, using a "robust" least absolute deviation method. The result is a two-element vector containing the model parameters, A and B .
This routine is written in the IDL language. Its source code can be found in the file
ladfit.pro
in the
lib
subdirectory of the IDL distribution.
Define two n -element vectors of paired data.
X = [-3.20, 4.49, -1.66, 0.64, -2.43, -0.89, -0.12, 1.41, $
Y = [-7.14, -1.30, -4.26, -1.90, -6.19, -3.98, -2.87, -1.66, $
Sort the X values into ascending order, and sort the Y values to match the new order of the elements in X: