** DATA_605_Discussion_Wk_10_Ch11_#2 **
** Ch.11, Exercise 2 **
Example 11.4 The President of the United States tells person A his or her intention to run or not to run in the next election. Then A relays the news to B, who in turn relays the message to C, and so forth, always to some new person. We assume that there is a probability a that a person will change the answer from yes to no when transmitting it to the next person and a probability b that he or she will change it from no to yes. We choose as states the message, either yes or no. The transition matrix is then P =
yes no
yes [(1 − a) (a) ]
no [(b) (1 − b) ]
The initial state represents the President’s choice.
2 In Example 11.4, let a = 0 and b = 1/2. Find P, P2, and P3. What would Pn be? What happens to Pn as n tends to infinity? Interpret this result.
#Find P, P2, and P3.
a <- 0
b <- 0.5
y <- c(1 - a, a, b, 1 - b)
P <- matrix(y, nrow = 2, byrow = T)
columns <- c("YES", "NO")
row.names(P) <- columns
colnames(P) <- columns
matrix1 <- function(a, exp) {
var1 <- a
for (x in 1:(exp - 1)){
var1 <- a %*% var1
}
return(var1)
}
# Outputs
P
## YES NO
## YES 1.0 0.0
## NO 0.5 0.5
matrix1(P, 2)
## YES NO
## YES 1.00 0.00
## NO 0.75 0.25
matrix1(P, 3)
## YES NO
## YES 1.000 0.000
## NO 0.875 0.125
# Result
# > P
# YES NO
# YES 1.0 0.0
# NO 0.5 0.5
# >
# > matrix1(P, 2)
# YES NO
# YES 1.00 0.00
# NO 0.75 0.25
# >
# > matrix1(P, 3)
# YES NO
# YES 1.000 0.000
# NO 0.875 0.125
# Note: as n increases the prob of yes end result increases for either a start position of yes or no
#What would Pn be? What happens to Pn as n tends to infinity? Interpret this result.
#For Pn, plug n into the matrix output formula
# matrix1(P,n)
# test this with a very large number, showing tendency of n towards infinity
matrix1(P, 100000)
## YES NO
## YES 1 0
## NO 1 0
# YES NO
# YES 1 0
# NO 1 0
#intrepretation: in the end the presidents answers will be changed to yes
** END **