Chapter 11 - Page 423, Exercise 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.

Looking for N:

library(matlib)
## This version of Shiny is designed to work with 'htmlwidgets' >= 1.5.
##     Please upgrade via install.packages('htmlwidgets').
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
#find Identity matrix
I  <- diag(1,3,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
# Inversing IQ
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

Looking for Nc

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

Looking for 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 <- N %*% R
NR <- round(NR,3)
NR
##       [,1]  [,2]
## [1,] 0.467 0.533
## [2,] 0.200 0.800
## [3,] 0.067 0.933