Simulating a Markov Chain

2 views (last 30 days)
Amir
Amir on 26 Feb 2016
Edited: Amir on 27 Feb 2016
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

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!