用R模拟马尔科夫链[封闭式]。

问题描述 投票:-1回答:1

用过渡矩阵模拟马尔科夫链

#transition matrix
 P = matrix(c(.4, .3, .5, 0, .5, 0, 0, .3, .4), nrow = 3, ncol = 5,
               byrow = TRUE)
r distribution montecarlo markov-chains
1个回答
2
投票

我不清楚你到底在找什么。如果你是想获得以下信息后的过渡矩阵 10100 次,你可以跟踪进化进度,通过。Reduce,其中选项 accumulate 应设置为 TRUE

P10 <- Reduce(`%*%`,replicate(10,P,simplify = FALSE),accumulate = TRUE)
P100 <- Reduce(`%*%`,replicate(100,P,simplify = FALSE),accumulate = TRUE)
© www.soinside.com 2019 - 2024. All rights reserved.