Filter löschen
Filter löschen

what's wrong with my ks test?

4 Ansichten (letzte 30 Tage)
Kalle
Kalle am 24 Sep. 2023
Kommentiert: Kalle am 24 Sep. 2023
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?

Akzeptierte Antwort

the cyclist
the cyclist am 24 Sep. 2023
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 Kommentar
Kalle
Kalle am 24 Sep. 2023
Owww, how embarrassing! thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by