#matrix representation #get the mean number of transitions for the chain to enter state j starting at state i P=matrix(c(0.5,0.4,0.1,0,0.3,0.4,0.3,0,0.2,0.3,0,0.5,0.2,0.3,0,0),ncol=4,byrow=T) I=matrix(c(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),ncol=4,byrow=T) solve(I-P)