Data 605 Discussion week10 # 11.2.8

8 In Example 11.13 (Drunkard’s Walk) of this section, assume that the probability of a step to the right is 2/3, and a step to the left is 1/3. Find N, Nc, and NR. Compare these with the results of Example 11.15

transition matrix in canonical form:

P <- matrix(c(0, 1/3, 0, 0, 0, 2/3, 0, 1/3, 0, 0, 0, 2/3, 0, 0, 0, 1/3, 0, 0, 1, 0, 0, 0, 2/3, 0, 1), nrow=5)
P
##           [,1]      [,2]      [,3]      [,4]      [,5]
## [1,] 0.0000000 0.6666667 0.0000000 0.3333333 0.0000000
## [2,] 0.3333333 0.0000000 0.6666667 0.0000000 0.0000000
## [3,] 0.0000000 0.3333333 0.0000000 0.0000000 0.6666667
## [4,] 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000
## [5,] 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000

N:

library(matlib)
## Warning: package 'matlib' was built under R version 3.3.3
Q <- matrix(c(0, 1/3, 0, 2/3, 0, 1/3, 0, 2/3, 0), nrow=3)
Q
##           [,1]      [,2]      [,3]
## [1,] 0.0000000 0.6666667 0.0000000
## [2,] 0.3333333 0.0000000 0.6666667
## [3,] 0.0000000 0.3333333 0.0000000
I <- matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1), nrow=3)
I
##      [,1] [,2] [,3]
## [1,]    1    0    0
## [2,]    0    1    0
## [3,]    0    0    1
IQ <- I-Q
IQ
##            [,1]       [,2]       [,3]
## [1,]  1.0000000 -0.6666667  0.0000000
## [2,] -0.3333333  1.0000000 -0.6666667
## [3,]  0.0000000 -0.3333333  1.0000000
N <- inv(IQ)
N
##      [,1] [,2] [,3]
## [1,]  1.4  1.2  0.8
## [2,]  0.6  1.8  1.2
## [3,]  0.2  0.6  1.4

NR:

R <- matrix(c(1/3, 0, 0, 0, 0, 2/3), nrow=3)
R
##           [,1]      [,2]
## [1,] 0.3333333 0.0000000
## [2,] 0.0000000 0.0000000
## [3,] 0.0000000 0.6666667
NR <-round(N %*% R, 4)
NR
##        [,1]   [,2]
## [1,] 0.4667 0.5333
## [2,] 0.2000 0.8000
## [3,] 0.0667 0.9333

NC:

c <-matrix(c(1, 1, 1), nrow=3)
NC <- N %*% c
NC
##      [,1]
## [1,]  3.4
## [2,]  3.6
## [3,]  2.2