Kolmogorov
3 次查看(过去 30 天)
显示 更早的评论
Hy, i'm trying to perform the Kolmogorov-Smirnov test by using the function h = kstest(x,CDF). I have to use this test to verify the good agreement of my data set (matrix (20,6545)) to the Cumulative GEV distribution but i can't build the CDF matrix. This is the program that i wrote:
E=patterns_EOBS(:,6545); %dataset
M=6545;
N=20;
x=[-5:3:55]';
parmhat_EOBS=zeros(M,3);
P=zeros(N,M);
CDF=zeros(N,2);
h=zeros(M);
p=zeros(M);
kstat=zeros(M);
cv=zeros(M);
for j=1:M
parmhat_EOBS(j,:)=gevfit(E(:,j));
for i=1:N
P(i,j)=gevcdf(x(i),parmhat_EOBS(j,1),parmhat_EOBS(j,2),parmhat_EOBS(j,3));
end
CDF(:,j)=horzcat(E(:,j),P(:,j));
[h(j),p(j),kstat(j),cv(j)]=kstest(E(:,j),CDF(:,j));
end
And this is the error that mathlab returns to me:
??? Subscripted assignment dimension mismatch.
Error in ==> KolmoEOBS at 22 CDF(:,j)=horzcat(E(:,j),P(:,j));
CAn you help me?
MArghe
1 个评论
Andrew Newell
2011-5-30
Since you don't know the parameters of your distribution in advance, you should be using lillietest.
回答(3 个)
Ivan van der Kroon
2011-5-26
Matlab is very clear here; your dimensions mitmatch: size(CDF(:,j))=[20,1] while size(horzcat(E(:,j),P(:,j)))=[20,2].
Another problem that will occur is that j will be greater than 2 at some point while size(CDF)=[20,2].
From this I think you are looking for
CDF=zeros(N,2,M);
CDF(:,:,j)=horzcat(E(:,j),P(:,j));
0 个评论
Ivan van der Kroon
2011-5-30
I know that CDF has to be of size Nx2, but you want to have M of those in your for-loop. So you have to use CDF(:,:,j), which is a Nx2 again. If you are not interested in it, you should overwrite it every iteration, i.e. no preallocation fod CDF and no indexes:
CDF=horzcat(E(:,j),P(:,j));
[h(j),p(j),kstat(j),cv(j)]=kstest(E(:,j),CDF);
This way you save considerable memory. But working with a 6545x6545 system is hard as Oleg commented. It checked and it worked for me (on my 64bits version).
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Hypothesis Tests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!