4 Case study 1 solution

 

This section covers

  • Card game simulations
  • Probabilistic strategy optimization
  • Confidence intervals

Our aim is to play a card game in which the cards are iteratively flipped until we tell the dealer to stop. Then one additional card is flipped. If that card is red, we win a dollar; otherwise, we lose a dollar. Our goal is to discover a strategy that best predicts a red card in the deck. We will do so by

  1. Developing multiple strategies for predicting red cards in a randomly shuffled deck.
  2. Applying each strategy across multiple simulations to compute its probability of success within a high confidence interval. If these computations prove to be intractable, we will instead focus on those strategies that perform best across a 10-card sample space.
  3. Returning the simplest strategy associated with the highest probability of success.
Warning

Spoiler alert! The solution to case study 1 is about to be revealed. I strongly encourage you to try to solve the problem prior to reading the solution. The original problem statement is available for reference at the beginning of the case study.

4.1 Predicting red cards in a shuffled deck

We start by creating a deck holding 26 red cards and 26 black cards. Black cards are represented by 0s, and red cards are represented by 1s.

Listing 4.1 Modeling a 52-card deck
red_cards = 26 * [1]
black_cards = 26 * [0]
unshuffled_deck = red_cards + black_cards

We proceed to shuffle the deck.

4.1.1 Estimating the probability of strategy success

4.2 Optimizing strategies using the sample space for a 10-card deck

Summary