Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Markov Chain matrix
Posted:
Apr 17, 2014 9:57 AM


hie guys,
Im trying to create a bayes model for the markov chain that consist of a 4 state condition/ my question is 1. How do I do coding for Bayes as there nothing much on the help file... 2.how do I do the coding for bayes if I already know the B and T condition?
This is what I tried doing ...Manage to run with the following coding but the matrix did not turn out according to the constrained set (if (check_P(1,1)+check_P(1,2)+check_P(1,3)+check_P(1,4))<=1) %% clear all clc for i=1:200 for j=1:200 satisfied='no '; while satisfied=='no ' satisfied='no '; while satisfied=='no ' satisfied='no '; while satisfied=='no ' satisfied='no '; while satisfied=='no ' B = rand(1); T = rand(1); C = rand(1); ==know to do bayes coding F = rand(1); BT=B*T; TB=T*B; BF= B*F; BC = B*C; CB = C*B; FC=F*C; TF=T*F; TC =T*C; CT=C*T; CF=C*F; P(:,:,j) = [B BT BC BF; TB T TC TF; CB CT C FC; 0 0 0 1]; check_P=P(:,:,j)^1; if (check_P(1,1)+check_P(1,2)+check_P(1,3)+check_P(1,4))<=1 satisfied='yes'; end check_P=P(:,:,j)^1; if (check_P(2,1)+check_P(2,2)+check_P(2,3)+check_P(2,4))<=1 satisfied='yes'; end if (check_P(3,1)+check_P(3,2)+check_P(3,3)+check_P(3,4))<=1 satisfied='yes'; end if (check_P(4,1)+check_P(4,2)+check_P(4,3)+check_P(4,4))<=1 satisfied='yes'; end end end end end savedata.(['P' num2str(i)])=P; end end Result obtained 0.8637 0.0437 0.6334 0.6172 not equal or lesser than 1 0.0437 0.0506 0.0371 0.0362 not equal or lesser than 1 0.6334 0.0371 0.7334 0.5241 not equal or lesser than 1 0 0 0 1.0000



