How to create a Markov chain sequence given the transition matrix and the states

조회 수: 5 (최근 30일)
sn at
sn at 2017년 2월 11일
댓글: shahab anjum 2020년 3월 9일
There is 5 states as follows:
QS=[2.0243
-0.6361
0.7770
1.0486
1.1569] % or QS={2.024 ,-0.6361 ,0.7770, 1.0486 ,1.1569}
And this is the transition matrix that has the probabilities of going from one state to another:
P=[0.5000 0.0556 0.0556 0.0556 0.0556
0.0556 0.5000 0.0556 0.0556 0.0556
0.0556 0.0556 0.5000 0.0556 0.0556
0.0556 0.0556 0.0556 0.5000 0.0556
0.0556 0.0556 0.0556 0.0556 0.5000];
How can I get a Markov chain sequence Js=[Js(1)...Js(t)] from these given P and QS? (t is a given time)
I used the following code to produce the sequence but it does not use the state space which is known in computing the sequence.
transition_probabilities=P;
chain_length=512;
chain = zeros(1,chain_length);
chain(1)=starting_value; %Starting value=1;
for i=2:chain_length
this_step_distribution = transition_probabilities(chain(i-1),:);
cumulative_distribution = cumsum(this_step_distribution);
r = rand();
chain(i) = find(cumulative_distribution>r,1);
end
Will I still get the right sequence, even if I don't use the State space?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Markov Chain Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by