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
MArghe
2011년 5월 30일
댓글 수: 1
Oleg Komarov
2011년 5월 30일
Line 8: zeros(M) = zeros(M,M) --> zeros(6545) ~ 2.6 Gb = (6545^2) * 8 bytes
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!