# Iteratively reweighted least squares (IRLS)

## Iteratively reweighted least squares (IRLS) :

Iteratively reweighted least squares (IRLS) is an algorithm used to solve optimization problems that involve fitting a model to data by minimizing the sum of squared errors. It is an iterative method, meaning that it repeats a series of steps until it arrives at a satisfactory solution.
One way to understand IRLS is to consider a simple linear regression problem, where we want to fit a line to a set of data points. The line is defined by its slope and intercept, and we can represent it mathematically as y = mx + b, where y is the dependent variable, x is the independent variable, m is the slope, and b is the intercept. To fit this line to the data, we need to find the values of m and b that minimize the sum of squared errors, which is the sum of the squares of the differences between the observed values of y and the values of y predicted by the line.
One way to solve this problem is to use the method of least squares, which involves finding the values of m and b that minimize the sum of squared errors. This can be done by setting the partial derivatives of the sum of squared errors with respect to m and b to zero and solving for m and b. However, this method can be computationally expensive and may not always converge to a solution.
IRLS is a more efficient method that can be used to solve this problem. It involves iteratively updating the values of m and b in a way that reduces the sum of squared errors at each step. The key idea behind IRLS is to weight the errors differently at each iteration, so that the larger errors have a greater influence on the updated values of m and b. This weighting scheme allows IRLS to converge faster and more reliably than the method of least squares.
To illustrate how IRLS works, let’s consider a simple example. Suppose we have a dataset with two variables, x and y, where x is the independent variable and y is the dependent variable. We want to fit a line to this data by minimizing the sum of squared errors.
First, we initialize the values of m and b to some arbitrary values, such as m = 1 and b = 0. Then, we compute the predicted values of y using the equation y = mx + b. Next, we compute the errors, which are the differences between the observed values of y and the predicted values of y.
Now, we need to weight the errors. We do this by computing a weight for each error based on its magnitude. For example, we could use the reciprocal of the error as the weight, so that larger errors are given more weight.
Next, we update the values of m and b using a weighted least squares approach, where the weights are the weights we computed in the previous step. This means that the larger errors have a greater influence on the updated values of m and b.
Finally, we repeat these steps until the sum of squared errors is minimized, or until a certain convergence criteria is met. This means that at each iteration, we compute the predicted values of y, the errors, the weights, and the updated values of m and b, until we arrive at a satisfactory solution.
To see how IRLS can improve upon the method of least squares, let’s consider another example. Suppose we have a dataset with two variables, x and y, where x is the independent variable and y is the dependent variable. However, this time, the data contains some outliers, which are values that are significantly different from the majority of the data.
If we use the method of least squares to fit a line to this data, the outliers will have a large influence on the values of m and b, which can lead to a suboptimal solution. This is because the method of least squares treats all errors equally, regardless of their magnitude.
On the other hand, if we use IRLS to fit a line to this data, the outliers will have less influence on the values of m and b because they will be given less weight. This is because IRLS weights the errors differently at each iteration, so that the larger errors have a lesser influence on the updated values of m and b.
Therefore, IRLS is better suited for dealing with data that contains outliers because it can reduce the influence of these outliers on the fitted model. This makes IRLS a more robust and reliable method for fitting models to data.
In summary, IRLS is an iterative algorithm that is used to solve optimization problems that involve fitting a model to data by minimizing the sum of squared errors. It is an efficient and robust method that can improve upon the method of least squares by weighting the errors differently at each iteration, so that the larger errors have a lesser influence on the updated values of the model parameters. By using IRLS, we can arrive at a more reliable and accurate solution to the optimization problem.