RANSAC

The RANdom Sample And Consensus (RANSAC) algorithm is an iterative, nondeterministic algorithm for estimating model parameters in the presence of outliers (FB81). It is based on randomly selecting the elements that generate the model.

RANSAC and all its variants can be viewed as algorithms that iteratively alternate between two phases: hypothesis generation (hypothesis generation) and hypothesis evaluation (hypothesis evaluation).

In brief, the algorithm randomly selects $s$ samples from the $n$ input samples $X=\{\mathbf{x}_1 , \ldots, \mathbf{x}_n \}$, with $s$ large enough to estimate a model (the hypothesis). Once a hypothesis has been obtained, the algorithm counts how many of the $n$ elements of $X$ are sufficiently close to it to be considered compatible.

A sample $\mathbf{x} \in X$ is classified as an inlier or outlier with respect to the hypothesis under consideration if its distance from the model $d_{\boldsymbol\beta}(\mathbf{x})$ is, respectively, less than or greater than a threshold $\tau$, which normally depends on the problem.

The threshold $\tau$ poses a problem in practical settings where additive error is Gaussian and therefore has infinite support. In this case, a probability of classifying samples as inliers must nevertheless be specified to determine a threshold $\tau$.

All samples that satisfy the hypothesis are called inliers with respect to that hypothesis.

The set of these inliers is the consensus set associated with the hypothesis $\boldsymbol\beta$:


\begin{displaymath}
S(\boldsymbol\beta) =
\left\{
\mathbf{x} \in X :
d_{\boldsymbol\beta}(\mathbf{x}) < \tau
\right\}
\end{displaymath} (4.140)

Among all the randomly generated models, the one that maximizes a given metric is selected; in classical RANSAC, this metric is the cardinality of the consensus set.

One problem is determining how many hypotheses to generate to obtain a good probability of finding the correct model.

There is a statistical relationship between the number of iterations $N$ and the probability $p$ that at least one of the generated hypotheses consists exclusively of inliers. The number of trials $N$ must satisfy


\begin{displaymath}
(1-P)^N \le 1-p
\end{displaymath}

that is,


\begin{displaymath}
N \ge \frac{\log(1-p)}{\log(1-P)}
\end{displaymath} (4.141)

where $P$ is the probability that a single random sample consists exclusively of inliers.

A common approximation for $P$ is $P=(1-\epsilon)^s$4.3 and therefore


\begin{displaymath}
N =
\frac{\log(1-p)}
{\log\!\left(1-(1-\epsilon)^s\right)}
\end{displaymath} (4.142)

where $\epsilon$ is the a priori probability of selecting an outlier and $s$ is the number of elements required to define the model.

Assuming the outlier fraction $\epsilon$ is known, the expected number of inliers in the dataset is


\begin{displaymath}
T = (1-\epsilon)n.
\end{displaymath}

Normally, $s$ is set to the minimum number of elements required to define the model. If a larger value is chosen, the model must be estimated by numerical regression on the provided constraints. This strategy can be useful when observation noise is high, but it increases the risk of including outliers in the sample.



Footnotes

...#tex2html_wrap_inline15641#4.3
The exact estimate is

\begin{displaymath}
P = \frac{\binom{n_i}{s}}{\binom{n}{s}},
\end{displaymath}

where $n_i$ is the total number of inliers, $n$ is the total number of elements, and $s$ is the number of elements required to define the model.


Subsections
Paolo medici
2026-10-19