In statistics, a residual is a deviation from an observed value of any sample set from its estimated value. Put more precisely, a residual (e) is the difference observed in the predicted function value (ŷ) and the final observed value (y) of a dependent variable.
Generally errors, residuals and functions are used widely in statistics in regression analysis.
Consider the size of pins being produced in a factory machine. The average size of the pins is 50 mm. There are a total of 1000 pins that are produced. Suppose for the sake of analysis, a sample of 50 pins is used to estimate the true size of the pins. If the estimated sample mean of the pins is 52mm, then the difference or deviation of every pin from its sample mean is called its residual value. So, if a random pin within the sample measures 55mm, then the residual value is (55 – 52) 3mm. Another pin which measures 48mm will have residual value as (48 – 52) -4mm. Likewise, the residual value can be computed for all the pins within the sample.
The sum of all the residuals as well as mean of the residuals within a random sample is zero.