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.

### Calling Sequence

Result = LADFIT( X, Y )

### Arguments

#### X

An n -element integer, single-, or double-precision floating-point vector. Note that the X vector must be sorted into ascending order.

#### Y

An n -element integer, single-, or double-precision floating-point vector. Note that the elements of the Y vector must be paired with the appropriate elements of X .

### Keywords

#### ABSDEV

Set this keyword to a named variable that will contain the mean absolute deviation for each data-point in the y-direction.

#### DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

### Example

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, \$

2.95, 2.18, 3.72, 5.26]

Y = [-7.14, -1.30, -4.26, -1.90, -6.19, -3.98, -2.87, -1.66, \$

-0.78, -2.61, 0.31, 1.74]

Sort the X values into ascending order, and sort the Y values to match the new order of the elements in X:

XX = X(SORT(X))

YY = Y(SORT(X))

Compute the model parameters, A and B .