从转换矩阵中找到下一个状态?随机游走Matlab仿真 [英] finding the next states from transition matrix ? random walk Matlab simulation

查看:123
本文介绍了从转换矩阵中找到下一个状态?随机游走Matlab仿真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在matlab中为随机步行移动性模型建模,我面临着有关从转换矩阵中找到下一个状态的问题.我已经创建了状态转换矩阵,但是我不知道如何找到下一个状态?

I'm trying to model random walk mobility model in matlab I'm facing problem regarding finding the next state from a transition matrix. I have already created my state transition matrix but I dont know how to find the next state ?

我知道我具有转移矩阵中每个状态的所有概率,但是我需要实际上根据这些概率选择下一个状态是什么. 有人可以帮我吗?

I know I have all the probabilities for each state from the trasition matrix but I need to actually choose based on those probability what the next state will be. can someone help me with that ?

推荐答案

如果A是行总和为1的转换矩阵,则可以像这样模拟马尔可夫链:

If A is your transition matrix with rows summing to 1, then you can simulate the Markov chain like this:

cdf = cumsum(A,2);
for t =1:numSteps
   stateIndex = min(find(rand < cdf(stateIndex,:)));
   % ....
end

这篇关于从转换矩阵中找到下一个状态?随机游走Matlab仿真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆