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

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

Réponses (0)

Catégories

En savoir plus sur Physics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by