典型习题:齐次Markov链的遍历性及平稳分布
【此解法中求各n阶概率转移矩阵的R代码】
library(MASS)
data<-c(0,0,0.5,0.5,1,0,0,0,0,1,0,0,0,0,1,0)
p<-matrix(data,nrow=4,ncol=4,byrow=T)
p2=p%*%p
p3=p2%*%p
p4=p3%*%p
p5=p4%*%p
p6=p5%*%p
p7=p6%*%p
p8=p7%*%p
p9=p8%*%p
p10=p9%*%p
fractions(p10)
p
p2
p3
p4
p5
p6
p7
p8
p9
p10
【运行结果】
> library(MASS)
> data<-c(0,0,0.5,0.5,1,0,0,0,0,1,0,0,0,0,1,0)
> p<-matrix(data,nrow=4,ncol=4,byrow=T)
> p2=p%*%p
> p3=p2%*%p
> p4=p3%*%p
> p5=p4%*%p
> p6=p5%*%p
> p7=p6%*%p
> p8=p7%*%p
> p9=p8%
共有 0 条评论