Racquetball, One Rally at a Time
Debrief of the pre-class simulation: the model, the code, and how sure to be of the answer.
The rules (from the pre-class work)
- Only the server can score. Win a rally on your serve: +1 point, and you keep serving.
- Lose a rally on your serve: no point, and the serve passes to your opponent.
- You win a rally on your serve with probability 0.6; on your opponent's serve, with probability 0.5.
- You serve first. First to 21 points wins.
1. What did your simulation say?
From your pre-class simulation (or your best guess): what is the chance you win the game, in percent?
Step 2 plays one game rally by rally; step 3 runs thousands in R.
2. One game, rally by rally
The game is a machine with two states: who is serving. Each rally follows one of the two arrows out of the current state; only the thick arrows score a point.
Step through a game. How many rallies does it take to finish? Why can a game run long without the score moving?
3. The model in R
The starter gives every rally on your opponent's serve to your opponent.
Fix the line marked # fix: with probability p_return you win the rally and take the serve (no point); otherwise your opponent scores.
Then Run.
Hint 1
Copy the shape of theif (you_serve) line: one if … else … on one line, with p_return instead of p_serve.Hint 2
if (runif(1) < p_return) you_serve <- TRUE else opp <- opp + 1The code the dials run
At 0.6 and 0.5, serving first is worth only about 3.5 points (82.6% against 79.1%). Why so little?
New case: the same players play a short game, first to 5 points. Compared with the game to 21, serving first is worth…
Your estimate
1,000 simulated games, serving first: the share you won. —
Exact (by solving the game, no simulation): 82.6%.
4. How sure is the simulation?
How far off can 1,000 games be? Each game is a win (1) or a loss (0). For one game, the typical distance from the true chance p is √(p(1 − p)). Averaging n games shrinks that by √n, the same √n that settled the coin's share of heads in Lesson 7. So a simulated probability's typical miss is √(p(1 − p) / n). You don't know the true p, so use your estimate.
As a group: a classmate's 1,000 games gave 81.2%. What should they report?
5. Where else?
As a group: pick something from your own studies or life that unfolds one chance event at a time (a best-of-seven series, say, but find your own). What states would your model have? Which assumption, such as fixed, independent chances, would you check first against real records?
Points to compare
- A good model names the states (here, who serves) and the chance of each move out of each state (step 2). The simulation then plays those rules many times (step 3).
- Fixed, independent chances are the usual weak spot: tiredness, momentum or a big lead can change them. A check compares the model's output, such as how often long streaks happen, with real records.
You should now be able to:
- describe a game as states and the chances of moving between them (step 2);
- fix and run an R simulation of it, and say why serving first matters less in a long game (step 3);
- report a simulated probability with its typical miss (step 4).
Assumptions
- parameterYou win a rally with probability 0.6 on your serve and 0.5 on your opponent's (the pre-class problem); the dials range 0.3–0.8 and 0.3–0.7. First to 21; no win-by-two rule.
- distributionRallies are independent. The exact win probabilities (82.6% serving first, 79.1% receiving) solve the two-state game backwards from 21 points, without simulation.
- simplificationStep 2's game uses a seeded JavaScript generator (shared, so a group sees the same game); step 3 runs the students' own R with
set.seed(seed). - interpretationTypical miss of a simulated probability: √(p(1 − p)/n), about 0.012 for 1,000 games.
Left out: the extensions (expected rallies per game, the analytical solution's algebra).