我有一个矩阵,如下所示,显示马尔可夫模型中的动作和当前状态以及下一个状态。
Action State..t. state.t.1.
1 Use Experinced supplier within becnhamrk within becnhamrk
2 Use Experinced supplier within becnhamrk within becnhamrk
3 Use Experinced supplier out of Benchmark out of Benchmark
4 Use The nearest Supplier within becnhamrk within becnhamrk
5 Use The nearest Supplier out of Benchmark out of Benchmark
6 Use The nearest Supplier out of Benchmark out of Benchmark
然后我想计算事件发生的概率,并将其替换为跟随矩阵(p)的默认概率:
state<-c("within becnhamrk","out of Benchmark")
action<-c("Use Experinced supplier","Use The nearest Supplier")
p<-array(0,c(length(state),length(state),length(action)))
colnames(p)=state
rownames(p)=state
# transition probability matrix based on the action that we have choosen
for(i in 1:length(action)){
p[,,i]<-matrix(0, nrow=length(state), ncol=length(state), byrow=TRUE)
}
当我执行ftable()的函数时,它给出了频率表,但我想找到当我采取行动1或行动2时从状态(t)进入状态(t + 1)的概率。怎么能我使用将从第一个表计算的概率值填充下面的矩阵。
, , 1
within becnhamrk out of Benchmark
within becnhamrk 0 0
out of Benchmark 0 0
, , 2
within becnhamrk out of Benchmark
within becnhamrk 0 0
out of Benchmark 0 0