Outcomes

Background

As promised, in this assignment we will use the functions representing random variables that we developed in the previous assignment to explore different strategies for playing the game of roulette.

Instructions

Below are some functions and code you can use to complete the assignment.

Questions

1 - Simple strategies

Create at least one visualization for at least one of the betting strategies above. For example, we can simulate how much a single player wins at each time if she sits down and plays 20 games, always betting one unit of money on even, as follows.

One fun visualization is to draw many partially overlapping opaque lines, with each line representing a sequence of winnings by a single player. You can also add:

  • A line for the expected value of winnings at each point in time
  • A line for the actual simulated average won by each player at each point in time
  • Labeled vertical and horizontal lines representing typical player behavior, or casino betting limits.

Comment on your visualization(s). What does it show? What questions does it answer?

d_su = play(strategy = simple_strategy(straightup), nplayer = 1, ntimes = TIMES)

d_h = play(strategy = simple_strategy(high)
          , nplayer = 1, ntimes = TIMES)
    
d_su$strategy = "straight up"
d_h$strategy = "high"

d = rbind (d_su, d_h)
    
g = ggplot(data = d, mapping = aes(x = time, y = winnings)) +
    geom_line(aes(color = strategy)) +
    labs(title = "Single game of roulette: 35-1 vs 1-1", caption = "Simulated winnings over time for a single roulette player betting one dollar on straight ups and high every time.")
print(g)

Data shows the risk comparison between a straight up play (35 to 1 payout) and a high play (1 to 1 payout). I wanted to show the jump a straight up strategy can affect how you play in long term. As you can see, the high straight has almost a linear winnings, for which in the long play of roulette will have the same winnings.

2 - Martingale strategy

The simplest martingale strategy for betting on a game with nearly equal chances of win and loss is to start with the minimum bet, and then double your previous bet every time you lose. If you win, then you again start fresh by betting the minimum amount. It’s possible to use this strategy in roulette, but what will happen?

doublebet = function(x, initialbet = 1, strategy = even)
{
    winnings = rep(NA, length(x))
    betsize = initialbet
    current_winnings = 0
    for(i in seq_along(x)){
        if(strategy(x[i]) == 1){
            current_winnings = current_winnings + betsize
            betsize = initialbet
        } else {
            current_winnings = current_winnings - betsize
            betsize = 2 * betsize
        }
        winnings[i] = current_winnings
    }
    winnings
}

doublebet implements the basic martingale doubling strategy (very inefficiently đŸ˜¬, but that’s fine for now). Describe in detail what this function does, and how you believe it works. What are the arguments? What kind of objects makes sense to pass in as arguments?

doublebet is safe and less risky of a strategy. The argument is to double the betting of player’s total net loss if you lose. Else if win, player can bet betsize. This makes sense because your net will reset back to the initial bet betsize.

3 - Analyzing the martingale strategy

We can simulate from the martingale strategy as follows.

Simulate and investigate different scenarios to create at least one visualization of the martingale strategy. Comment on your visualization(s) and address the following.

  1. Under what assumptions does the martingale strategy work in theory?
  2. Could the martingale strategy work in practice, given table limits?
  3. Is it good or bad for casinos if players use the martingale strategy? Does it depend on whether the casino is large or small?
doublebet_2 = function(x, initialbet = 1, strategy = column1)
{
    winnings = rep(NA, length(x))
    betsize = initialbet
    current_winnings = 0
    for(i in seq_along(x)){
        if(strategy(x[i]) == 1){   #win
            current_winnings = current_winnings + betsize
            betsize = initialbet
        } else {                    #lose
            current_winnings = current_winnings - betsize
            betsize = 2 * betsize
        }
        winnings[i] = current_winnings
    }
    winnings
}
d1 = play(strategy = simple_strategy(doublebet), nplayer = 1, ntimes = 30)

d2 = play(strategy = simple_strategy(doublebet_2), nplayer = 1, ntimes = 30)


d1$case = "even"
d2$case = "column"

d_m = rbind (d1, d2)


g = ggplot(data = d_m , mapping = aes(x = time, y = winnings)) +
    geom_line(aes(color = case)) 
    labs(title = "The Martingale Strategy in Roulette", caption = "Simulated winnings over time for a single roulette player following the basic martingale betting strategy.")
## $title
## [1] "The Martingale Strategy in Roulette"
## 
## $caption
## [1] "Simulated winnings over time for a single roulette player following the basic martingale betting strategy."
## 
## attr(,"class")
## [1] "labels"
print(g)

In theory, if the player has sufficient money to play with Martingale Strategy with winnings 3 to 1 payout, then the player may have a chance for net win. However, observing from the visual data above, a player rather not sink their losings exponentially.

It’ll be bad for a casino to have all players to use the Martingale Strategy since the player will come out to an initialbet winnings.

4 - Advising a friend

Suppose someone you care about is going to visit Las Vegas, and is enthusiastic about the martingale strategy, but they have no background in math and logic. Explain to this person, in simple terms, what the best strategy is for them to play roulette and why.

Someone I care is going to Vegas, my genuine advice is to not gamble. Suppose if this person has to gamble, I would advise the Martingale Strategy with winnings bet 1:1 payout. That way the player can always reset to the intial initalbet when player loses; therefore will have some winnings in the end.