Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Markov Chain matrix
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Salvinder

Posts: 13
Registered: 9/11/12
Markov Chain matrix
Posted: Apr 17, 2014 9:57 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.