what's wrong with my ks test?

조회 수: 4 (최근 30일)
Kalle
Kalle 2023년 9월 24일
댓글: Kalle 2023년 9월 24일
I get too high D-values with my ks-test but at the same time low p-values. How is that possible?
C = wblrnd(100,1);
C = C';
% 3 parameter WEIBULL SETUP
custompdf = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-((x-c)/a).^b);
customcdf = @(x,a,b,c) (x>c).*1-exp(-((x-c)/a).^b);
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','off');
params = mle(C,'pdf',custompdf,'start',[mean(C) std(C) min(C)],'Options',opt,'LowerBound',[0 0 -Inf],'UpperBound',[Inf Inf min(C)]);
a_Welle = params(1,1);
b_Welle = params(1,2);
c_Welle = params(1,3);
x = [c_Welle+eps(c_Welle):0.1:max(C)*mean(C)];
% 2 parameter WEIBULL SETUP
p = wblfit(C);
[nlogl,pcov] = wbllike(p,C);
[quantile_Wbl2,q95lo,q95up] = wblinv(0.99958333,p(1),p(2),pcov);
Q = quantile(customcdf(x, a_Welle, b_Welle, c_Welle),0.99958333);
% kolmogorov-smirnov
[h_wbl3,p_wbl3,ksstat_wbl3] = kstest2(C, customcdf(C,a_Welle,b_Welle,c_Welle));
[h_wbl2,p_wbl2,ksstat_wbl2] = kstest2(C, wblcdf(C,p(1),p(2)));
fprintf('Two parameter Weibull-Distr.: h = %d, p = %f, D-Wert = %f\n', h_wbl2, p_wbl2, ksstat_wbl2);
Two parameter Weibull-Distr.: h = 0, p = 0.289041, D-Wert = 1.000000
fprintf('three parameter Weibull-Distr.: h = %d, p = %f, D-Wert = %f\n', h_wbl3, p_wbl3, ksstat_wbl3);
three parameter Weibull-Distr.: h = 0, p = 0.289041, D-Wert = 1.000000
How can I improve my code?

채택된 답변

the cyclist
the cyclist 2023년 9월 24일
My guess here is that this line of code
C = wblrnd(100,1);
is not doing what you expect. It is generating just one value, from a Weibull distribution with parameters a=100, b=1. Take a look the documentation for wblrnd, to find the syntax for what you want to do. I expect you wanted something like
C = wblrnd(4,3,100,1);
  댓글 수: 1
Kalle
Kalle 2023년 9월 24일
Owww, how embarrassing! thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hypothesis Tests에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by