Difference in results when running the different version but simple script.

조회 수: 5 (최근 30일)
Joy Tian
Joy Tian 2015년 10월 18일
편집: Walter Roberson 2015년 10월 19일
I make my own script about calculating the transition probability of Markov Chain.I run the two scripts and get different results.Can you detect what makes the difference? What I was doing is
[t,j]=size(sets);
p00=zeros(j,1);
p01=zeros(j,1);
p10=zeros(j,1);
p11=zeros(j,1);
for i=1:j,
prev=sets(1:t-1,i);
next=sets(2:t,i);
p00(i)=sum(prev <= 1 & next <= 1)/sum(sets<=1);
p01(i)=sum(prev <= 1 & next > 1)/sum(sets<=1);
p10(i)=sum(prev > 1 & next <= 1)/sum(sets>1);
p11(i)=sum(prev > 1 & next > 1)/sum(sets>1);
end
Another very similiar version is
for i=1:nv,
s0=sequence(1:nt-1,i);
s1=sequence(2:nt,i);
ndry=length(find(s0 <= threshold));
nwet=length(find(s0 > threshold));
p00(i)=length(find(s0 <= threshold & s1 <= threshold))/ndry;
p01(i)=length(find(s0 <= threshold & s1 > threshold))/ndry;
p10(i)=length(find(s0 > threshold & s1 <= threshold))/nwet;
p11(i)=length(find(s0 > threshold & s1 > threshold))/nwet;
end

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by