The number of degrees of freedom is the number of values in thefinal calculation of a statistic that are free to vary.
A simple example is shown in calculating the mean of a sample.Supposeisa sample from a population.
Let
Theareestimates of the residualswhereisthe true mean of the population.
The sum of the residuals (unlike the sum of the errors) isnecessarily 0. If we know the values of anyofthe residuals, we can find the last residual, so that even thoughthere are n residuals, onlyofthese are free to vary. For this reason we say that the residuals ofa sample of size n hasdegreesof freedom.
For the same reason, the sample standard deviationincludesan expression n-1 in the denominator.
We can write
isthe sum of the squares of the residuals and the residuals only haven-1 degrees of freedom, so that