Effacer les filtres
Effacer les filtres

this code is not working for transition probability matrix ....make it correct?

1 vue (au cours des 30 derniers jours)
Dhines
Dhines le 11 Jan 2013
my transition probability matrix equation is given under link. http://latex.codecogs.com/gif.latex?p1_{h}(i,j)=\frac{\sum_{u=1}^{S_{u}-2}\sum_{v=1}^{S_{v}}\delta%20(F_{h}(u,v)=i,{F_{h}}(u+1,v)=j)}{\sum_{u=1}^{^{S_{u}-2}}%20\sum_{v=1}^{^{S_{v}}}\delta%20({F_{h}(u,v)=i})}
for this eqn i wrote code given below
sv=128;
su=128;
for i=1:9
for j=1:9
a(i,j)=0;
for u=1:su-2
for v=1:sv
if (Yh(u,v)==i && Yh(u+1,v)==j)
dell=1;
else
dell=0;
end
a(i,j)=a(i,j)+dell;
b(i,j)=0;
if(Yh(u,v)==i)
dell1=1;
else
dell1=0;
end
b(i,j)=b(i,j)+dell1;
end
end
end
end
.....the final result want to know for above code is p=a./b.... and here the dell value as considered as dell(.)=1 if and only if its argumens are satisfied, otherwise dell(.)=0.
  2 commentaires
Dhines
Dhines le 17 Jan 2013
please check it ..this is another eqn<http://latex.codecogs.com/gif.latex?P1v(i,j)=\frac{{\sum_{u=1}^{^{S_{u}-1}}\sum_{v=1}^{S_{v}-1}\delta%20({F_{h}(u,v)=i,{F_{h}(u,v+1)=j}})}}{\sum_{u=1}^{{S_{u}-1}}\sum_{v=1}^{S_{v}-1}\delta%20(F_{h}(u,v)=i)}>..... i wrote code for this eqn is p1v=zeros(9); for ii=1:9 p1=Yh(1:end-1,:)==ii; for jj=1:9 p2=Yh(:,2:end-1)==jj; p1v(ii,jj) = nnz(p1 & p2)./nnz(p1); end end ...is it correct ?
Jan
Jan le 17 Jan 2013
What does "is not working" mean? Do you get an error message or do the results differ from your expectations?

Connectez-vous pour commenter.

Réponses (2)

Walter Roberson
Walter Roberson le 11 Jan 2013
Why are you setting b(i,j)=0 inside each "for v" iteration ?

Andrei Bobrov
Andrei Bobrov le 11 Jan 2013
Modifié(e) : Andrei Bobrov le 11 Jan 2013
p1h = zeros(9);
for ii = 1:9
p1 = Yh(1:end-2,:) == ii;
for jj = 1:9
p2 = Yh(2:end-1,:) == jj;
p1h(ii,jj) = nnz(p1 & p2)./nnz(p1);
end
end
  2 commentaires
Walter Roberson
Walter Roberson le 11 Jan 2013
The p1 computation could be moved to prior to the "for jj" loop.
Andrei Bobrov
Andrei Bobrov le 11 Jan 2013
Hi Walter! I agree with you, corrected.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by