# Determining the degree of freedom for a chi-squared test on a strict avalanche criterion matrix

I have read that the degree of freedom is calculated by subtracting 1 from the number of states a random variable can be in. I am performing a goodness of fit test on a 64*32 strict avalanche criterion matrix where the expected frequency of any a[i,j] is 50000 and the observed frequency can lie between [0,100000].What I am confused about is that how do I calculate the degree of freedom? Since the observed value might range from 0-100000, will my degree of freedom be equal to (100000-1)? Please advise.

## 1 Answer

you have $n=64\times 32$ random variables so your degrees of freedom should be $n-1=2047.$

• But I have a new problem,I have getting chi-squared statistic in the order of 10^7 and p-value as 0 – Kishan Kishore Apr 9 '16 at 18:53
• Maybe raw chi squared is not the way to go. On page 23 of the document cosic.esat.kuleuven.be/nessie/deliverables/… a normalized measure is used for a similar purpose. So try to scale your random variables to be X_{i,j}=|(a[i,j]/#X)-1| where #X is 64 and then apply chi squared to the sum of these normalized variables. – kodlu Apr 10 '16 at 0:27