2.2 Tactile simulation: Boxes and spinners

While we generally use technology to conduct large scale simulations, it is helpful to first consider how we might conduct a simulation by hand using physical objects like coins, dice, cards, or spinners.

Many random phenomena can be represented in terms of a “box model25

  • Imagine a box containing “tickets” with labels. Examples include:
    • Fair coin flip. 2 tickets: 1 labeled H and 1 labeled T
    • Free throw attempt of a 90% free throw shooter. 10 tickets: 9 labeled “make” and 1 labeled “miss”
    • Card shuffling. 52 cards: each card with a pair of labels (face value, suit).
  • The tickets are shuffled in the box, some number are drawn out — either with replacement or without replacement of the tickets before the next draw26.
  • In some cases, the order in which the tickets are drawn matters; in other cases the order is irrelevant. For example,
    • Dealing a 5 card poker hand: Select 5 cards without replacement, order does not matter
    • Random digit dialing: Select 4 cards with replacement from a box with tickets labeled 0 through 9 to represent the last 4 digits of a randomly selected phone number with a particular area code and exchange; order matters, e.g., 805-555-1212 is a different outcome than 805-555-2121.
  • Then something is done with the tickets, typically to measure random variables of interest. For example, you might flip a coin 10 times (by drawing from the H/T box 10 times with replacement) and count the number of H.

If the draws are made with replacement from a single box, we can think of a single circular “spinner” instead of a box, spun multiple times. For example:

  • Fair coin flip. Spinner with half of the area corresponding to H and half T
  • Free throw attempt of a 90% free throw shooter. Spinner with 90% of the area corresponding to “make” and 10% “miss”.

Example 2.2 Let \(X\) be the sum of two rolls of a fair four-sided die, and let \(Y\) be the larger of the two rolls (or the common value if a tie). Set up a box model and explain how you would use it to simulate a single realization of \((X, Y)\). Could you use a spinner instead?

Solution. to Example 2.2

Show/hide solution

Use a box with four tickets, labeled 1, 2, 3, 4. Draw two tickets with replacement. Let \(X\) be the sum of the two numbers drawn and \(Y\) the larger of the two numbers drawn.

It’s also possible to use a spinner with 4 sectors, corresponding to 1, 2, 3, 4, each with 25% of the total area; see Figure 2.3. Spin the spinner twice. Let \(X\) be the sum of the two numbers spun and \(Y\) the larger of the two numbers spun.

Spinner corresponding to a single roll of a fair four-sided die.

Figure 2.3: Spinner corresponding to a single roll of a fair four-sided die.

The spinner in Figure 2.3 simulates the individual die rolls. We will see later spinners for generating values of \(X\), values of \(Y\), and values of \((X, Y)\) pairs directly.

Note that we are able to simulate outcomes of the rolls and values of \(X\) and \(Y\) without defining the probability space in detail. That is, we do not need to list all the possible outcomes and events and their probabilities. Instead, the probability space is defined implicitly via the specification to “roll a fair four-sided die twice” or “draw two tickets with replacement from a box with four tickets labeled 1, 2, 3, 4” or “spin the spinner in Figure 2.3 twice”. The random variables are defined by what is being measured for each outcome, the sum (\(X\)) and the max (\(Y\)) of the two draws or spins.

In Example 2.2 we described how to simulate a single realization of \((X, Y)\); this is one “repetition” in the simulation. A simulation general entails many repetitions. When conducting simulations it is important to distinguish between what entails (1) one repetition of the simulation and its output, and (2) the simulation itself and output from many repetitions.

Example 2.3 (Matching problem) Rocks labeled 1, 2, 3, 4, are placed at random in spots labeled 1, 2, 3, 4, with spot 1 the correct spot for rock 1, etc. Suppose that the rocks are equally likely to be placed in any spot. Let \(Y\) be the number of rocks that are placed in the correct spot, and let \(C\) be the event that at least one rock is placed in the correct spot. Describe how you would use a box model to simulate a single realization of \(Y\) and of \(C\).

Solution. to Example 2.3

Show/hide solution

Use a box with 4 tickets, labeled 1, 2, 3, 4. Shuffle the tickets and draw all 4 without replacement and record the tickets drawn in order. Let \(Y\) be the number of tickets that match their spot in order. (For example, if the tickets are drawn in the order 2431 then the realized value of \(Y\) is 1 since only ticket 3 matches its spot in the order.)

Since \(C=\{Y \ge 1\}\), event \(C\) occurs if \(Y\ge 1\) and does not occur if \(Y=0\). We could record the realization of event \(C\) as “True” or “False”. We could also record the realization of \(I_C\), the indicator random variable for event \(C\), as 1 if \(C\) occurs and 0 if \(C\) does not occur.

2.2.1 Exercises

  1. Flip a fair coin 3 times and record the results in sequence. Let \(X\) be the number of flips that result in H. Let \(Y\) be the number of flips that result in T, and let \(Z\) be the length of the longest streak of H in a row (which could be 0 if all T or 1 if no H is followed by H). Describe how you would use a box model to simulate a single realization of \((X, Y, Z)\).

  2. Two players, A and B, play a single game of rock, paper, scissors (RPS). One possible probability measure corresponds to each player being equally like to choose between rock, paper, and scissors, and the choices of the two players being independent. Describe how you would use a box model to simulate a single realization of \(A\), the event that player \(A\) wins the game.

  3. The probability measure in the previous exercise assumed equally likely outcomes. However, a recent rock, paper, scissors tournament conducted by FiveThirtyEight suggests that the following might be a more reasonable probability measure reflecting how people actually play. Suppose that the probability that player A throws rock is 0.319, and 0.402 for paper. Suppose that the probability that player B throws rock is 0, and 0.75 for paper. Also suppose that the probability that both players throw paper is 0.3015 and that both players throw scissors is 0.06975 (which corresponds to assuming that they make their choices independently). Describe how you would use a box model to simulate a single realization of \(A\), the event that player \(A\) wins the game.

  4. In Example ??, suppose we continue to purchase packages until we obtain a complete set of prizes and then we stop. Suppose that each package is equally likely to contain any of the 3 prizes, regardless of the contents of other packages. Let \(A\) be the event that we purchase more than 10 packages, and let \(Y\) be the number of packages than contain prize 1. Describe how you would use a box model to simulate a single realization of \((\textrm{I}_A, Y)\).

References

Freedman, David, Robert Pisani, and Roger Purves. 2007. Statistics. 4th ed. W.W. Norton; Company.

  1. Our use of ”box models” is inspired by (Freedman, Pisani, and Purves 2007).↩︎

  2. “With replacement” always implies replacement at a uniformly random point in the box. Think of “with replacement” as “with replacement and reshuffling” before the next draw.↩︎