place value for elements which not in transition probability matrix.
1 view (last 30 days)
Show older comments
I have sequence
qq= [1 3 3 4 1 5 4 6 3]
and I am making transition probability matrix p as follows
1 3 4 5 6
1 0 0.5 0 0.5 0
3 0 0.5 0.5 0 0
4 0.5 0 0 0 0.5
5 0 0 1 0 0
6 0 1 0 0 0
then I have another sequence which have some different values than qq, i.e.
qq1=[1 3 2 2 3 4 1 7 7 8 3 9 1]
for window of 5 I am selecting first 5 elements i.e. 1 3 2 2 3 and then taking their relative transition probability values from matrix p. i.e. for 1 3 2 2 3, p(1,3), p(3,2), p(2,2), p(2,3). Now I am sliding window and skipping 1st element and adding next element so elements are 3 2 2 3 4 and calculating transition probability values from matrix p. now again next values 2 2 3 4 1 and doing same thing upto last window i.e. 7 8 3 9 1.
so for that code is as follows
nm=numel(qq1);
N=5;
for k=1:nm-N+1;
w=qq(k:k+N-1);
for t=1:N-1;
x=w(t);
x1=w(t+1);
pv=p(x,x1);
lg(t)=log(pv);
sm=sum(lg);
end
f(k)=sm;
end
now for p(1,7),p(7,7),p(8,3) there is no value in p matrix so for that I want to take value 0.01 i.e. p(1,7)=0.01, p(7,7)=0.01, p(8,3)=0.01 so how to do this by editing above code or separately.
0 Comments
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!