# degree of freedom, when to $-1$ or $-2$? [duplicate]

I have taken an introductory course in statistics. But I cant understand the degree of freedom. I understand that it is the number of dimensions of free components of the final random variable. But I couldn't get why it is sometimes $n-1$ or $n-2$ rather than simply $n$?(where $n$ is the number of observations in the experiment)

Can someone kindly explain to me in simple language or redirect me to a straightforward material, why/when is the degree of freedom not $n$?

The correct degree of freedom is whatever it is, because the statistic you calculate is given by that distribution with that degree of freedom. the non-rigorous rule of thumb tells you that you lose 1 degree of freedom everytime you estimate a parameter. That is why you use $X^2_{n-1}$, for example, if you test a variance with unknown mean. However, this should only serve an intuition.