Simulating a Markov Chain

2 次查看(过去 30 天)
Amir
Amir 2016-2-26
编辑: Amir 2016-2-27
I would like to simulate a Markov chain to construct predictive model based probabilities. So I have a Markov chain for transformation sequences as:
P(S)=P(s1)(from i=2:L)P(s(i)|s(i-1))
This states the probability of a transformation applied in the sequence depends upon the transformation that have been applied before. Since the probability doesn't change among the sequence, this is a stationery markov chain. So the
P(s1)
is the probability at the first position of the sequence, and
P(s(i)|s(i-1))
the transition matrix with i=1,...,L which I have already learnt by counting. So my question is when I have a matrix n such as :
n =
0 1 0 0 1 1 0
1 1 0 1 1 1 0
1 1 0 0 0 1 1
1 1 1 1 1 1 0
0 0 1 1 1 1 0
1 0 0 0 1 1 0
1 0 0 1 0 1 0
0 0 1 0 0 1 1
1 0 1 1 0 0 1
0 0 1 0 0 1 0
1 0 0 1 0 0 1
0 0 0 1 0 0 1
0 1 1 0 0 1 0
1 1 1 1 1 1 1
0 1 1 0 0 1 1
0 1 0 1 1 0 1
1 1 0 1 1 1 1
0 1 1 0 0 0 0
0 0 0 1 1 0 0
0 1 0 0 0 1 0
0 1 1 0 1 0 0
1 0 0 0 0 1 1
1 0 1 1 0 1 1
1 0 0 1 0 0 0
1 1 0 0 1 1 1
using the formula I can calculate the probability of having second variable 1 when first variable had been 1:
>> sum(n(find(n(:,1)),2))/sum(n(find(n(:,1)))) % which is the P(s(2)|s(1))
ans =
0.4615
and I can carry on to calculate
P(s(i)|s(i-1)) *...*P(s(7)|s(6))
to come up with the product and assuming P(s1)=0.5, I can calculate the final P(S). Is that correct? My understanding is that this way we will have one value for P(S), while as stated in the textbook, we should have a probability matrix of (7*7). Thus apparently I am doing something right here, can anyone help me out on this?
-Amir

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Markov Chain Models 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by