Simulating a Markov Chain
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Markov Chain Models finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!