我需要在R中生成Markov链,给出了交易矩阵和伪随机数序列。如何实施该序列?
我的伪随机数序列和交易矩阵:
a1=293
c1=123
m1=584
x1<-c()
x1[1] = 5
#generating pseudo random numbers sequence
for (i in 1:(m1-1)){
x1[i+1]=(a1*x1[i]+c1)%%m1}
#matrix
statesNames<-c('1', '2', '3', '4')
tm <- matrix(c(0.5,0.5,0,0,1/3,1/3,1/3,0,0,1/3,1/3,1/3,0,0,0.5,0.5), nrow=4, byrow=TRUE)
mat<-new("markovchain", states = statesNames, transitionMatrix = tm)
现在,我需要使用该伪随机数序列来生成Markov链,但是如何做到这一点?
My pseudo random numbers sequence and transaction matrix:
a1=293
c1=123
m1=584
x1<-c()
x1[1] = 5
#generating pseudo random numbers sequence
for (i in 1:(m1-1)){
x1[i+1]=(a1*x1[i]+c1)%%m1}
#matrix
statesNames<-c('1', '2', '3', '4')
tm <- matrix(c(0.5,0.5,0,0,1/3,1/3,1/3,0,0,1/3,1/3,1/3,0,0,0.5,0.5), nrow=4, byrow=TRUE)
mat<-new("markovchain", states = statesNames, transitionMatrix = tm)
Now I need to use that pseudo random numbers sequence to generate Markov chain, but how to do that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论