Functions > Data Analysis > Curve Fitting > Median-Median Regression
  
Median-Median Regression
medfit(vx, vy)—Returns a vector containing the coefficients a and b for a line of the form a + b·x that best approximates the data in vectors vx and vy using median-median regression.
The median-median algorithm divides data sets into 3 smaller sets of approximately the same size. Each set is then represented by a single point determined by the medians of the x and y data in the set. A line is then fit to these 3 points. The intercept is chosen so that the line passes through the point which is the average of the medians among the three groups:
Click to copy this expression
If the data contains outliers, the least-squares fit may be thrown off while trying to minimize the distance to the outlier. The medfit line is much less sensitive to outliers, just as the median is a less outlier-sensitive measure of centrality than the mean.
Arguments
vx is a vector of real numbers representing the x values.
vy is a vector of real numbers representing the y values. vy must be the same length as vx.