Markov Chain
Purpose
To compare 2 drunkard walks
Moves between Home (0) Bar(4) which are absorbing states 1,2,3 points have left and righ prob as 0.5
> Q <- matrix(data = NA, nrow = 3, ncol = 3) > Q[1, ] <- c(0, 0.5, 0) > Q[2, ] <- c(0.5, 0, 0.5) > Q[3, ] <- c(0, 0.5, 0) > N <- solve(diag(3) - Q) > C <- c(1, 1, 1) > R <- matrix(data = NA, nrow = 3, ncol = 2) > R[1, ] <- c(0.5, 0) > R[2, ] <- c(0, 0) > R[3, ] <- c(0, 0.5) > N1 <- N > NC1 <- N %*% C > NR1 <- N %*% R |
Moves between Home (0) Bar(4) which are absorbing states 1,2,3 points have left and righ prob as 2/3 and 1/3
> Q <- matrix(data = NA, nrow = 3, ncol = 3) > Q[1, ] <- c(0, 2/3, 0) > Q[2, ] <- c(1/3, 0, 2/3) > Q[3, ] <- c(0, 1/3, 0) > N <- solve(diag(3) - Q) > C <- c(1, 1, 1) > R <- matrix(data = NA, nrow = 3, ncol = 2) > R[1, ] <- c(1/3, 0) > R[2, ] <- c(0, 0) > R[3, ] <- c(0, 2/3) > N2 <- N > NC2 <- N %*% C > NR2 <- N %*% R |
Comparison # of times man is in transient state sj if he begins at si
> print(N1)
[,1] [,2] [,3]
[1,] 1.5 1 0.5
[2,] 1.0 2 1.0
[3,] 0.5 1 1.5
> print(N2)
[,1] [,2] [,3]
[1,] 1.4 1.2 0.8
[2,] 0.6 1.8 1.2
[3,] 0.2 0.6 1.4 |
Comparison expected time before it get absorbed
> print(NC1)
[,1]
[1,] 3
[2,] 4
[3,] 3
> print(NC2)
[,1]
[1,] 3.4
[2,] 3.6
[3,] 2.2 |
Absorbtion probabilities
> print(NR1)
[,1] [,2]
[1,] 0.75 0.25
[2,] 0.50 0.50
[3,] 0.25 0.75
> print(NR2)
[,1] [,2]
[1,] 0.46666667 0.5333333
[2,] 0.20000000 0.8000000
[3,] 0.06666667 0.9333333 |