calculation of the transition probability of a Markov's chain

7 ビュー (過去 30 日間)
som
som 2011 年 12 月 30 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 3 月 9 日
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.)

カテゴリ

Help Center および File ExchangeMarkov Chain Models についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by