calculation of the transition probability of a Markov's chain
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 9 Mar 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 commentaires
Voir également
Catégories
En savoir plus sur Markov Chain Models dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!