what's wrong with my ks test?

3 次查看(过去 30 天)
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);

更多回答(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