0
$\begingroup$

I am using MATLAB 2012a to run 3 tests. With my data, I obtain very small values, and for the Anderson–Darling (A–D) tests, the results are not even normalized. Please verify my code. I am also using the A–D script which is found at this link.

sample= N;

h1=histfit(sample,30,'weibull');
xdata1 = get(h1(2), 'XData');
ydata1 = get(h1(2), 'YData');
[~,p_weibull_cs,stats_weibull_cs] = chi2gof(ydata1);
[~,p_weibull_ks,stats_weibull_ks] = kstest(ydata1);
p_weibull_ad = AnDartest(ydata1);

@Tom Lane,

I did modify my code and am currently working like this,;

pd3 = fitdist(sample, 'weibull');
dist3 = makedist('Weibull','a',pd3.ParameterValues(1),'b',pd3.ParameterValues(2))
[h_chi_weibull, p_chi_weibull, stats_chi_weibull]= chi2gof(sample,'CDF',pd3)
[h_ad_weibull, p_ad_weibull, adstat_weibull,cv_ad_weibull]= adtest(sample,'Distribution','weibull')

[h_ks_weibull, p_ks_weibull, ksstat_weibull,cv_ks_weibull]= kstest(sample,'CDF',dist3)

NOW MY PROBLEM IS THE CHI TEST IS RETURNING ONLY 1 OR 0, NOT VALUES IN BETWEEN..

$\endgroup$
1
  • 4
    $\begingroup$ Zay, this is the third post I've seen from you that seems to be throwing random functions at your problem (and seemingly, missing every time). Since you don't know what you're doing - I intend no slight by that, we were all in that position once - you are very unlikely to arrive at a good solution to whatever your problem is by chance. I suggest (again) that instead you simply tell us in clear, non-jargon (and non-Matlab) terms what it is you're trying to achieve and we may be able to offer better help that trying to guess what you're doing from what you imagine you should be calling. $\endgroup$
    – Glen_b
    Commented Jun 30, 2014 at 23:58

1 Answer 1

1
$\begingroup$

Your ydata1 variable is the heights of the histogram bins. Then with kstest you test to see if those bin heights could come from a standard normal distribution. With chi2gof you test to see if those bin heights could come from a fitted normal distribution, with the degrees of freedom adjusted as an approximate way to take the fitting into account. My guess is that you don't want to do either of those things.

My guess is that you really want to test sample against a Weibull distribution. I suggest you test log(sample) against an extreme value distribution using the lillietest function, because this function takes the fitting into account, and because the log transform converts Weibull to extreme value.

I'm not acquainted with the Anderson-Darling script.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.