calculation of the transition probability of a Markov's chain
Mostrar comentarios más antiguos
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
Respuestas (1)
Walter Roberson
el 9 de Mzo. de 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.)
Categorías
Más información sobre Biomedical Imaging en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!