degrees of freedom chi2inv

8 Ansichten (letzte 30 Tage)
C.G.
C.G. am 21 Nov. 2022
Bearbeitet: John D'Errico am 21 Nov. 2022
I am using a code given to me by somebody else to generate a 95th percentile for my data, and one of the lines in my code is:
nw = 4;
K = 2*nw-1;
nw2 = 2*K;
r95 = mean * chi2inv(0.90,nw2)/nw2;
I understand that the nw2 variable in chi2inv is the degrees of freedom, but what does degrees of freedom actually mean, and what would it do to the output if it was changed?
Also, what would dividing this equation by nw2 at the end do?

Antworten (1)

John D'Errico
John D'Errico am 21 Nov. 2022
Bearbeitet: John D'Errico am 21 Nov. 2022
This really should be asked on a different forum, as only barely about MATLAB, and a good answer requires teaching a class in statistics. That won't happen here.
I'll give you a quick intuitive answer, but then suggest you need to take a class in statics, or at least do some reading if you want more help.
Think of degrees of freedom as the amount of information content available in your data.
Suppose you have n data points. Every piece of data is one piece of information. (That some data points may be more valuable than others is food for yet another entire class in statistics.) But initially, n pieces of information.
Now, compute the mean. That is one parameter inferred from your data. But if you now try to compute the variance, you need to use the mean to compute the variance. So you had only n-1 pieces of information available to compute that variance.
If you look at the formula for a mean, what do you see?
mu = sum(X)/n
So add up all of your data, then divide by n, the degrees of freedom available.
However, the formula for the variance does what?
V = sum((X - mu).^2)/(n-1)
So you subtract off the mean, square everything, sum it up, but now divide by n-1. (There are all sorts of issues in this, as to why another formula will divide by n, when computing a population variance. Again, this is NOT a class in statistics.)
Sorry, but if you want a better answer, time to do some serious readng, or take a class.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by