Markov chain simulation code

3 次查看(过去 30 天)
saja mk
saja mk 2020-10-1
In Markov chain code
transition_probabilities = [0.1 0.9;0.8 0.2];
starting_value = 1;
chain_length = 5;
chain = zeros(1,chain_length);
chain(1)=starting_value;
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
whats the aim of using cumsum function?
Why compare with random value in each iteration?

回答(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