When fitting a model to a set of observations, there are often outlier observations that should not be used in the fitting.
For example, when computing the least squares fit of a sphere to points, such as with pivot calibration for a tracked stylus, the points are the observations and the sphere is the model. But some of the points may be outliers, such as points that are collected before the stylus is placed at its pivot point, or after the stylus is removed.
RANSAC is an algorithm to fit a model to observations in the presence of outliers. "RANSAC" means "RANndom SAmple Consensus".
RANSAC operates as follows:
Usually, Steps 1-to-3 are iterated through at most a certain number of times and the largest set of inliers ever found in Step 2 is kept from iteration to iteration. If nothing satisfactory is found, this largest set of inliers is used in Step 4.
Problem: fit a line to $n$ points, $p_1, \; p_2, \ldots, p_n$ in 2D. We are happy once 90% of the points are within distance 0.01 of the line.
Note that the 90% and the 0.01 threshold must be chosen with some knowledge of many outliers are expected, and how well you expect the model to fit the points.
RANSAC does this:
$n = { \large (y_2-y_1, x_1-x_2) \over \large | (y_2-y_1, x_1-x_2) |}$and
$d = n \cdot (x_1,y_1)$.
$| n \cdot p_i - d | \leq 0.01$