HOW TO USE Chi Squared Test to test Triangle Distribution?

4 Ansichten (letzte 30 Tage)
Hamish Atkins
Hamish Atkins am 27 Mär. 2018
Kommentiert: Jeff Miller am 28 Mär. 2018
Hi, I have generated 1000 random variables with the triangle distribution. I am then doing a significance test on the variables against the same triangle distribution with the Chi Squared test. However, the test rarely rejects the null hypothesis (i.e. h = 0 & p > 0.05 mostly) which is contradictory in that the test data was generated from the same distribution. Please see my code below. Am I using the chi2gof() function incorrectly?
for i = 1:1000
x = rand;
random_vars(i) = icdf('Triangular',x,'a',1,'b',2,'c',4);
end
pd = makedist('Triangular','a',1,'b',2,'c',4);
[h,p] = chi2gof(random_vars,'CDF',pd)

Akzeptierte Antwort

Jeff Miller
Jeff Miller am 27 Mär. 2018
It sounds like you are expecting h=1 and p<.05 when the fit is good, but that is not the way the test works, but that is backwards from how chi2gof actually works.
chi2gof tests the null hypothesis that the data come from the hypothesized distribution (i.e., your triangular). Since the data really do come from that distribution, the null hypothesis should indeed be rejected rarely. That means you will usually get h=0 and p>.05 by that test when you compare the generated data against the distribution from which they were truly generated.
  2 Kommentare
Hamish Atkins
Hamish Atkins am 28 Mär. 2018
Thanks for your answer, that explains a lot.
Also, is it OK to use the triangle distribution with the chi2gof() function? I have heard it only works with a normal distribution.
Jeff Miller
Jeff Miller am 28 Mär. 2018
Yes, it should work with the triangle. In principle, the test can be computed with any distribution at all. From the docs, it looks like MATLAB supports using chi2gof with any distribution that can be created with makedist or fitdist.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by