Fitting a mathematical model to a set of samples (eg fitting a sphere to a set of 3D cartesian points supposed to lie on its surface) is not an easy task.
The samples usually come from measurement and as such, even assuming that systematic errors are absent, they are anyway affected by errors due to the finite accuracy and precision of the measuring process.
It can be shown that, at least for linear models, a least squares fitting gives the maximum likelihood estimation of the model parameters if the error distribution is gaussian, an assumption which is usually considered acceptable.
Unluckily it is very common to have samples in good agreement with a gaussian error distribution except for a certain, supposedly small number of outliers, that is samples with exceptional errors, not fitting into the gaussian distribution, due to unforeseeable conditions.
Even one single outlier may severely hurt the result of least squares fitting; so outliers must be recognized and excluded from the fitting.
The statistical methods for outlier rejection I know of (RANSAC, LMedS) are binary; that is, they select a subset of the available samples, on which fitting is to be performed. A sample either is accepted or rejected; therefore such methods have no closed form solution.
Typically, if the model being fitted needs samples as a minimum to determine its parameters (example with a geometric shape: four points for a sphere), a large number of minimal subsets is prepared by random choice; each subset determines a model, which is tested against the whole set of samples by computing the distance between each sample and the model.
According to RANSAC, the best model is the one having the maximum number of samples under a specified distance; according to LMedS, it is the one having the least value of the median of squared distances.
Then all the samples not agreeing with the best model found are discarded; the remaining are used for a least squares fit, giving the ‘accredited’ model.
The above procedure is often summarized as
where is the set of model parameters, are the samples and is the (squared, or anyway unsigned) distance between the sample and the model having parameters .
is formally a weight, but it can attain only the values for accepted samples or for rejected samples.
Would it be possible to consider as true real weights to be computed together with parameters ? Something like
Of course it can not work as written, because the expression has no lower bound with respect to . We could use squared weights (as we don’t want negative weights) and add a constraint to avoid trivial minima; eg
It is easy to see that this isn’t sufficient, because this expression still has many unwanted minima; for example, when all the are null except one, say , and the set of parameters is chosen so that .
It turns out that a good choice is
where is not less than the expected number of outliers. This way, all weights are forced to be greater than zero except at most of them, for which it could be .