Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Question 1 -------------------------------------------------------------------------
- attach(results)
- summary(X)
- summary(Fav.Odds)
- #Mean of both
- #X: 4.257 Fav.Odds: 6.72
- For<- 6.72
- Against<- 4.257
- print(Against/Against)
- print(For/Against)
- #4.257 / 4.257 = 1
- #6.72 / 4.257 = 1.578576462
- #1.578576462 : 1
- #2 : 1
- # odds rounded up are 2:1 when in reality they are more close to 3:1 as
- # we have 192 losses to 108 wins
- #Question 2 -------------------------------------------------------------------------
- Summary(results)
- Wins <- 108
- Losses <- 192
- TotalRaces <- 300
- ProbOfFav <- Wins/TotalRaces
- print(ProbOfFav)
- #108/300 = 0.36
- #36% probability of the favourite winning
- #Question 3 -------------------------------------------------------------------------
- #1- P(win / %Odds ) = answer for question 3, bookies gain
- #P(win) = win / total races = 108/300 = 0.36
- #%odds = ( for/ for + against ) = ( 1 / 2+ 1) = (1/3) = 0.33
- probwin <- 0.36
- print(probwin)
- percentodds <- 0.33
- formula <- probwin / percentodds
- print(formula)
- #[1] 1.090909
- answer<- 1 - formula
- print(answer)
- #the bookies are making a 9% loss or a 0.09 loss on every 1 bet
- # Question 4 -------------------------------------------------------------------------
- bet<- 1
- loss<- 0
- wins<- 0
- return<- 0
- # a for loop that runs through all 300 races and uses the double up betting strategy and records the end profit
- for (i in 1:300) {
- if (results$win[i]=="y"){
- wins <- bet - loss
- return <- return + wins
- bet <- 1
- wins <- 0
- loss <- 0
- TRUE
- }
- if (results$win[i]=="n"){
- if (results$place[i]=="n"){
- loss <- bet + loss
- return
- bet <- bet * 2
- FALSE
- }
- else{
- TRUE
- }
- if(i==300){
- return<-return-loss
- TRUE
- }
- FALSE
- }
- }
- print(return)
- # Question 5 -------------------------------------------------------------------------
- # this for loop determines the total amount of capital we need at the start to get the 1 return
- bet<- 0.01
- loss<- 0
- wins<- 0
- return<- 0
- capital<-0
- for (i in 1:300) {
- if (results$win[i]=="y"){
- wins <- bet - loss
- return <- return + wins
- bet <- 0.01
- wins <- 0
- loss <- 0
- TRUE
- }
- if (results$win[i]=="n"){
- if (results$place[i]=="n"){
- loss <- bet + loss
- bet <- bet * 2
- FALSE
- }
- if(i==300){
- return<-return-loss
- capital<-capital*2
- TRUE
- }
- FALSE
- }
- }
- print(capital)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement