11.5 p466

  1. A study of the strengths of Ivy League football teams shows that if a school has a strong team one year it is equally likely to have a strong team or average team next year; if it has an average team, half the time it is average next year, and if it changes it is just as likely to become strong as weak; if it is weak it has 2/3 probability of remaining so and 1/3 of becoming average.
  1. A school has a strong team. On the average, how long will it be before it has another strong team?

Let’s simulate this problem, with 10,000 trials

n = 10000
length = rep(0, n)
for (i in 1:n){
  last = "Start"
  k = 0
  while (last != "Strong"){
    p = runif(1)
    if (last == "Start") {
      if (p > 0.5) {
        last = "Strong"
        length[i] = k + 1
      }
      else {
        last = "Average"
        k = k + 1
      }
    } else if (last == "Average"){
      if (p >= 0.75) {
        last = "Strong"
        length[i] = k + 1
      } else if (p <= 0.25 ){
        last = "Weak"
        k = k + 1
      } else {
        last = "Average"
        k = k + 1
      }
    }
    else if (last == "Weak"){
      if (p >= 2/3) {
        last = "Average"
        k = k + 1
      }else {
        last = "Weak"
        k = k + 1
      }
    }
  }
}
print(paste("The average time until the next Strong team:",mean(length)))
## [1] "The average time until the next Strong team: 4.4882"
hist(length, main = "Histogram of years until a strong team recurs")

plot(ecdf(length), main = "CDF of years until a strong team recurs")

  1. A school has a weak team; how long (on the average) must the alumni wait for a strong team?

Let’s replicate the code above, albeit with a different starting position, of a Weak team.

n = 10000
length = rep(0, n)
for (i in 1:n){
  last = "Weak"
  k = 0
  while (last != "Strong"){
    p = runif(1)
    if (last == "Start") {
      if (p > 0.5) {
        last = "Strong"
        length[i] = k + 1
      }
      else {
        last = "Average"
        k = k + 1
      }
    } else if (last == "Average"){
      if (p >= 0.75) {
        last = "Strong"
        length[i] = k + 1
      } else if (p <= 0.25 ){
        last = "Weak"
        k = k + 1
      } else {
        last = "Average"
        k = k + 1
      }
    }
    else if (last == "Weak"){
      if (p >= 2/3) {
        last = "Average"
        k = k + 1
      }else {
        last = "Weak"
        k = k + 1
      }
    }
  }
}
print(paste("The average time until a Strong team occurs:",mean(length)))
## [1] "The average time until a Strong team occurs: 9.9899"
hist(length, main = "Histogram of years until a strong team occurs")

plot(ecdf(length), main = "CDF of years until a strong team occurs")