Question
R code so that you can calculate the odds for each type of bet yourself. I need to change this in c++ and run this
R code so that you can calculate the odds for each type of bet yourself.
I need to change this in c++ and run this programs
## seed & libraries set.seed(230963)
## Win probs list wProb <- c(0.35, 0.2, 0.13, 0.15, 0.17)
## Bet calc placeFunction <- function(wProbs, horse) { placeProbs <- wProbs[horse] for(i in 1:length(wProbs)) { if(i != horse) { placeProbs <- placeProbs + (wProbs[i] * wProbs[horse] / (1 - wProbs[i])) } } return(placeProbs) } p <- placeFunction(wProb, 1) print(p)
showFunction <- function(wProbs, horse) { showProbs <- wProbs[horse] for(i in 1:length(wProbs)) { if(i != horse) { showProbs <- showProbs + (wProbs[i] * wProbs[horse] / (1 - wProbs[i])) } } for(m in 1:length(wProbs)) { if(m != horse) { for(n in 1:length(wProbs)) { if(n != horse & n != m) { showProbs <- showProbs + wProbs[m] * (wProbs[n] / (1 - wProbs[m])) * (wProbs[horse] / (1 - wProbs[m] - wProbs[n])) } } } } return(showProbs) } p <- showFunction(wProb, 2) print(p) forecastFunction <- function(wProbs, horseA, horseB, review) { if(review == TRUE) { forecasProbs <- (wProbs[horseA] * (wProbs[horseB] / (1 - wProbs[horseA]))) + (wProbs[horseB] * (wProbs[horseA] / (1 - wProbs[horseB]))) } else { forecasProbs <- wProbs[horseA] * (wProbs[horseB] / (1 - wProbs[horseA])) } return(forecasProbs) } p <- forecastFunction(wProb, 2, 1, TRUE) print(p)
tricastFunction <- function(wProbs, horseA, horseB, horseC) { tricastProbs <- wProbs[horseA] * (wProbs[horseB] / (1 - wProbs[horseA])) * (wProbs[horseC] / (1 - wProbs[horseA] - wProbs[horseB]))
return(tricastProbs) } p <- tricastFunction(wProb, 3, 10, 11) print(p)
triBoxFunction <- function(wProbs, horseA, horseB, horseC) { triBoxProbs <- 0 a <- horseA b <- horseB c <- horseC triBoxProbs <- triBoxProbs + wProbs[a] * (wProbs[b] / (1 - wProbs[a])) * (wProbs[c] / (1 - wProbs[a] - wProbs[b])) a <- horseA b <- horse C c <- horseB triBoxProbs <- triBoxProbs + wProbs[a] * (wProbs[b] / (1 - wProbs[a])) * (wProbs[c] / (1 - wProbs[a] - wProbs[b])) a <- horseB b <- horseA c <- horseC triBoxProbs <- triBoxProbs + wProbs[a] * (wProbs[b] / (1 - wProbs[a])) * (wProbs[c] / (1 - wProbs[a] - wProbs[b])) a <- horseB b <- horse C c <- horseA triBoxProbs <- triBoxProbs + wProbs[a] * (wProbs[b] / (1 - wProbs[a])) * (wProbs[c] / (1 - wProbs[a] - wProbs[b])) a <- horseC b <- horseA c <- horseB triBoxProbs <- triBoxProbs + wProbs[a] * (wProbs[b] / (1 - wProbs[a])) * (wProbs[c] / (1 - wProbs[a] - wProbs[b])) a <- horseC b <- horseB c <- horseA triBoxProbs <- triBoxProbs + wProbs[a] * (wProbs[b] / (1 - wProbs[a])) * (wProbs[c] / (1 - wProbs[a] - wProbs[b])) return(triBoxProbs) } p <- triBoxFunction(wProb, 3, 10, 11) print(p)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started