Function to simulate one round with betting
Now let us write a function that simulates one round under the von Neumann model, with betting incorporated.
Player B will observe their value, and decide whether to bet $1 or not. If the decision to bet is made, then the two players compare values and the higher value wins. Note that if Player B bets and wins, the result is positive 1; if they bet and lose, the result is negative 1. If Player B decides not to bet, then no money is won or lost by either player.
Here, we will assume that Player B has a fixed strategy: if their value is above a certain cutoff, then they will bet. This cutoff, bet_cutoff, will be the argument to the function.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Probability Puzzles in R
अभ्यास निर्देश
- Determine whether Player B will decide to bet.
- If they do bet, return the result of the bet using the
ifelsefunction.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
one_round <- function(bet_cutoff){
a <- runif(n = 1)
b <- runif(n = 1)
# Fill in betting condition
if(___){
# Return result of bet
return(___)
} else {
return(0)
}
}