In: Math
Consider a baseball world series (best of 7 game series) in which team A theoretically has a 0.55 chance of winning each game against team B. Simulate the probability that team A would win the world series against team B simulating 1,000 world series. What is the probability that team A would win? (USE R - include R output)
Here is the code required:
set.seed(100) ## Setting
seed
## Generating 7000 games independently
tournament <- runif(7000)
tournament = as.integer(tournament<=0.55)
## Transforming into matrix so
that each row represents one 7-match tournament
tournament<- matrix(data=tournament, ncol=7)
## If team A wins >3 then wins tournament, calculating the
proportion
wins <- apply(tournament, 1, sum)
prob_team_a <- sum(wins>3)/1000
## Prinitng
print(prob_team_a)
Output: 0.62
Thanks
Please ask if you have any doubts, give me thumbs up if you like!