calculation of the transition probability of a Markov's chain
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all
I have to series of data (i.e. Qt and Qt+1 , in t and t+1 times, respectively). I want to calculate the transition probability of P[Qt+1 | Qt] that called first order transition probability of a Markov chain.
How can I do this.
cheers
0 Kommentare
Antworten (1)
Walter Roberson
am 9 Mär. 2012
allstates = unique([Qt(:); Qt1(:)]);
[TF, fromstate_num] = ismember(Qt, allstates);
[TF, tostate_num] = ismember(Qt1, allstates);
went_from_to_count = accumarray( [fromstate_num(:), tostate_num(:)], 1, []);
num_trans_away_from = min(1, sum(went_from_to_count, 2));
went_from_to_prob = went_from_to_count ./ repmat( num_trans_away_from, 1, size(went_from_to_count,2) );
After this,
went_from_to_prob(J,K) is P[allstates(K) | allstates(J)]
Note that an entire row could be empty, if the last state transitioned to does not otherwise occur (the "accept" state.)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Markov Chain Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!