The threshold value to determine when a data point fits a model (), and the number of inliers (data points fitted to the model within
t) required to assert that the model fits well to data () are determined based on specific requirements of the application and the dataset, and possibly based on experimental evaluation. The number of iterations (), however, can be roughly determined as a function of the desired probability of success () as shown below. Let be the desired probability that the RANSAC algorithm provides at least one useful result after running. In extreme (for simplifying the derivation), RANSAC returns a successful result if in some iteration it selects only inliers from the input data set when it chooses points from the data set from which the model parameters are estimated. (In other words, all the selected data points are inliers of the model estimated by these points). Let w be the probability of choosing an inlier each time a single data point is selected, that is roughly, :w = number of inliers in data / number of points in data A common case is that w is not well known beforehand because of an unknown number of inliers in data before running the RANSAC algorithm, but some rough value can be given. With a given rough value of w and roughly assuming that the points needed for estimating a model are selected independently (It is a rough assumption because each data point selection reduces the number of data point candidates to choose in the next selection in reality), w^{n} is the probability that all
n points are inliers and 1 - w^{n} is the probability that at least one of the points is an outlier, a case which implies that a bad model will be estimated from this point set. That probability to the power of (the number of iterations in running the algorithm) is the probability that the algorithm never selects a set of points which all are inliers, and this is the same as 1 - p (the probability that the algorithm does not result in a successful model estimation) in extreme. Consequently, : 1 - p = (1 - w^n)^k \, which, after taking the
logarithm of both sides, leads to : k = \frac{\log(1 - p)}{\log(1 - w^n)} This result assumes that the data points are selected independently, that is, a point which has been selected once is replaced and can be selected again in the same iteration. This is often not a reasonable approach and the derived value for should be taken as an upper limit in the case that the points are selected without replacement. For example, in the case of finding a line which fits the data set illustrated in the above figure, the RANSAC algorithm typically chooses two points in each iteration and computes maybe_model as the line between the points and it is then critical that the two points are distinct. To gain additional confidence, the
standard deviation or multiples thereof can be added to . The standard deviation of is defined as : \operatorname{SD}(k) = \frac{\sqrt{1 - w^n}}{w^n} ==Advantages and disadvantages==