Chapter 2 Exercises — The Golf Analytics Toolkit
Difficulty: ⭐ recall and concepts · ⭐⭐ calculation or a short script · ⭐⭐⭐ analysis and judgment · ⭐⭐⭐⭐ open research
All real-data answers come from the ESPN snapshot through golfkit.data. All simulated answers come from golfkit.shotsim with the seed stated, and are labelled SIMULATED. Every numeric answer below was produced by code/09_exercise_checks.py or by the chapter's other scripts. Run them to check your work.
Part A — Concepts ⭐
A.1 Name the three kinds of numbers this book allows, and give one example of each from this chapter.
A.2 ESPN's hole records don't contain the par. How does the build get it, and what goes wrong for a quadruple bogey?
A.3 Explain the difference between a tidy (long) hole-score table and a wide scorecard. Which would you store, and which would you print for a golfer?
A.4 Why does the fetcher write every file to a temporary name and then rename it? What would go wrong with a plain write if the process crashed?
A.5 The final build labels 4,741 player-events as WD/DQ, but only 3,542 are genuine (and the first-pass build labelled even more). Give the two main reasons a finisher or a missed-cut player was mislabelled.
A.6 Why is ESPN's season the wrong column for counting majors per year? What happens to the 2020 Masters?
A.7 What is a course-round, and why is it the right group to compare players within?
A.8 In one sentence each, say what ShotLink, pgatour.com's statistics pages, ShotLink Intelligence and DataGolf provide, and which of them this book uses as data.
A.9 State this book's definition of an Around-the-Green shot. Why does the chapter call it "golfkit's definition" rather than "the PGA TOUR's"?
A.10 What does it mean that each cast member's default seed is "representative"? Why not use a random seed?
Answers to Part A
A.1 Real scores (the 2026 Masters leaderboard; McIlroy 276); simulated shots (Marcus's double bogey on water_right_approach_par4, seed 7); cited reference values (Broadie's E(fairway, 150 yd) = 2.943, HIGH).
A.2 par = strokes − (score relative to par). ESPN writes quadruple bogey or worse as the text OTHER, so the relative value is unknown. The build now resolves the par from other players' scorecards in the same event and round. The first fix, for OTHER alone, resolved 3,436 holes (8 not) and completed 3,196 rounds. The final build treats impossible tags the same way: 12,946 unknown pars resolved and 134 unresolved.
A.3 Long: one row per player-round-hole, which is easy to filter, group and join. Wide: one row per round with 18 hole columns, which is easy to read. Store long and print wide (rounds.wide_scorecard).
A.4 So that a file that exists is always complete. A crash during a plain write would leave a truncated .json file, and the resumable "skip existing files" rule would then skip it forever.
A.5 (1) A finisher's round can look incomplete in the build's tables (in the first pass, mostly because holes with an unusable to-par tag were set aside), and the build treats any incomplete round as a withdrawal. (2) Players who made the 36-hole cut but were removed by the second cut (MDF, 2008–2019) stopped early and looked incomplete.
A.6 ESPN's season wraps: autumn events belong to the next season. The November 2020 Masters falls in season 2021, which therefore contains six majors, while season 2020 contains one. Use year (the calendar year of the end date).
A.7 The group of rounds played on the same course in the same round of the same event (event, round, par signature). Within it, every player faced the same course and roughly the same conditions, so score differences reflect the players, not the course.
A.8 ShotLink: the TOUR's shot-by-shot tracking system (not free). pgatour.com: official season statistics, including strokes gained by category, free to view. ShotLink Intelligence: the TOUR's program for academic access to ShotLink data. DataGolf: a commercial subscription service with ratings, strokes-gained data and paid API access. This book uses none of them as data. It points readers to them for real category numbers.
A.9 A non-putt shot, other than a par-4/5 tee shot, starting within 30 yards of the green's edge. The PGA TOUR's exact boundary is not verified in the book's references, so the 30-yard rule is golfkit's stated choice.
A.10 Each default seed was chosen from 60 candidates as the 20-round block whose strokes-gained profile is closest to the golfer's 600-round long-run profile. A random 20-round block can hide the golfer's real biggest weakness, because 20 rounds is a small sample.
Part B — Calculations ⭐⭐
B.1 Deriving par. ESPN records these four holes for one player: (5 strokes, "+1"), (3 strokes, "E"), (4 strokes, "−1"), (8 strokes, "OTHER"). Derive the par of each hole you can. What extra information do you need for the fourth?
Solution
Par = strokes − relative: 5 − 1 = 4; 3 − 0 = 3; 4 − (−1) = 5. The fourth can't be derived from its own record: "OTHER" means quadruple bogey or worse, so with 8 strokes the par is 4 or less. You need the par from other players' scorecards for the same hole in the same round (what the build does), or from the course document.
B.2 Pricing shots with Broadie's baseline. Use these PGA TOUR expected strokes (Broadie, HIGH): E(tee, 400) = 3.990; E(fairway, 150) = 2.943; E(rough, 150) = 3.189; E(rough, 60) = 2.910; E(sand, 20) = 2.530; E(green, 20 ft) = 1.870; E(green, 5 ft) = 1.240. Compute strokes gained for: (a) a 150-yard fairway approach to 20 feet; (b) the same approach to 5 feet; (c) a 400-yard drive to the fairway 150 out vs to the rough 150 out; (d) a 150-yard approach from the rough into a greenside bunker 20 yards from the hole; (e) a 150-yard fairway approach into a penalty area, with the drop in the rough 60 yards out.
Solution
SG = E(start) − E(end) − 1 − penalty. (a) 2.943 − 1.870 − 1 = +0.073. (b) 2.943 − 1.240 − 1 = +0.703. (c) Fairway: 3.990 − 2.943 − 1 = +0.047; rough: 3.990 − 3.189 − 1 = −0.199. Same distance, different lie: a difference of 0.246 strokes. (d) 3.189 − 2.530 − 1 = −0.341. (e) 2.943 − 2.910 − 1 − 1 = −1.967. This is almost the same as Marcus's 8-iron in §2.9 (−1.971), because a water ball costs about two strokes against tour expectation.
B.3 Score differentials. On the member course (CR 70.8 / Slope 125, assumed values 🧪), compute the WHS Score Differential for adjusted gross scores of 85, 92 and 100, and the Course Handicap for a 15.4 index (par 72).
Solution
Differential = (113/125)(AGS − 70.8): 85 → 0.904 × 14.2 = 12.8; 92 → 0.904 × 21.2 = 19.2; 100 → 0.904 × 29.2 = 26.4. Course Handicap = 15.4 × 125/113 + (70.8 − 72) = 17.04 − 1.2 = 15.84 → 16. There is no 0.96 multiplier.
B.4 Compression. The raw JSON totals 1,085 MB and the seven parquet tables total 8.1 MB. What is the ratio? If you store only holes.parquet (4.90 MB) and rounds.parquet (1.32 MB), what share of the processed layer is that?
Solution
1,085 / 8.1 ≈ 134× (the script prints 133× from unrounded sizes). (4.90 + 1.32) / 8.1 = 6.22 / 8.1 ≈ 77%.
B.5 The two-course trap. In round 1 of the 2026 Farmers Insurance Open, 75 players on the South Course averaged 72.48 and 71 on the North averaged 69.13. (a) Compute the whole-round average. (b) A player shoots 71 on the South. What is his raw strokes gained against the whole round, and against his own course-round? (c) Which is right?
Solution
(a) (75 × 72.48 + 71 × 69.13) / 146 = (5,436.0 + 4,908.2) / 146 ≈ 70.85 (the script prints 70.85). (b) Whole round: 70.85 − 71 = −0.15, which looks slightly worse than average. Course-round: 72.48 − 71 = +1.48, a good round. (c) The course-round comparison. He faced the South Course, not an average of two courses.
B.6 How many rounds? A PGA TOUR player's rounds scatter around his level with σ = 2.756 strokes. How many rounds pin his level to ±1.0 stroke with 95% confidence? How many in each of two periods for a before/after change to be pinned to ±1.0?
Solution
Level: (1.96 × 2.756 / 1.0)² = 5.402² ≈ 29.2, round up to 30. Change: the variance doubles, so 2 × 29.2 = 58.4, round up to 59 per period. Amateur round-to-round spreads are larger (Rosa's 20 simulated rounds have an SD of 5.81), so amateurs need even more rounds.
B.7 Checking a hand-entered hole. A shot table for one par 4 reads: shot 1 tee 402 yd → fairway 151 yd; shot 2 fairway 141 yd → green 18 ft; shot 3 green 18 ft → green 3 ft; shot 4 green 3 ft → green 0.5 ft. List every validation error validate_shots would raise.
Solution
(1) chain_break at shot 2: shot 1 ended at 151 yards and shot 2 starts at 141, a 10-yard gap with no penalty. (2) not_holed_out: no shot ends holed, and the 0.5-ft tap-in is missing. If you add a shot 5 from 0.5 ft to holed, with holed = True, the hole validates.
B.8 The accounting identity. Marcus's simulated hole (§2.9, seed 7) began 412.1 yards from the hole, where E(tee) = 4.007, and he scored 6. (a) What must his shot values add up to? (b) His five shot values were +0.056, −1.971, +0.033, −0.119 and +0.008. Check the sum. (c) If the 8-iron had instead finished on the green 21.4 feet away (E = 1.889) and he had two-putted, what would his score and his 8-iron's strokes gained have been?
Solution
(a) E(tee) − score = 4.007 − 6 = −1.993. (b) 0.056 − 1.971 + 0.033 − 0.119 + 0.008 = −1.993. ✓ (c) Score 4 (drive, 8-iron, two putts). The 8-iron's SG = 2.951 − 1.889 − 1 = +0.062. The water ball turned a slightly-better-than-tour shot into a two-stroke loss: −1.971 against +0.062, a swing of 2.03 strokes on one swing.
Part C — Data & Code ⭐⭐–⭐⭐⭐
C.1 Analyze an event: the 2025 Masters ⭐⭐. Load the 2025 Masters (data.event_lookup("Masters", year=2025)). (a) Build the hole table with data.hole_scoring and list the three hardest holes and the easiest. (b) Compute the field's average to par by par type directly from data.holes. (c) Explain the odd result in (b), find the rows that cause it, and check them against data.courses.
Expected shape: (a) a sorted table with one row per hole. Hardest: hole 5 (+0.324), hole 18 (+0.243), hole 11 (+0.240); easiest: hole 2 (−0.385). (b) A dict by par: par 3 +0.127, par 4 +0.131, par 5 −0.253, and nothing else. (c) In the final build there is no odd result: no derived par disagrees with the course document. Before the label fix, (b) also showed a "par 6" at −1.0. It came from four hole rows on Matthieu Pavon's scorecard where a 5 was coded as "one under", one instance of a glitch that then affected 1,282 hole rows in 49 events. Run the check anyway (filter par == 6, or merge with courses and compare pars). It returns zero rows now, and it is the check that would catch the next glitch.
C.2 The two calendars ⭐⭐. Count, by calendar year, the events whose ESPN season differs from year.
Expected shape: nonzero only from 2013 to 2022: 7, 8, 8, 8, 9, 9, 12, 10, 11, 11, for a total of 93. Explain why the counts stop after 2022.
C.3 Build your model: three courses at The American Express ⭐⭐⭐. For the 2026 American Express, map each round's par_signature to a course name by hashing each course's par sequence the way the build does (code/05_multicourse_and_staggered.py has the function). Compute the mean score by course for rounds 1–3.
Expected shape: every signature matches a course (0 unmatched). La Quinta CC 67.94 (155 rounds), PGA West Nicklaus Tournament 67.65 (153), Pete Dye Stadium 70.76 (154). The Stadium Course plays about three strokes harder, so the same "−1.5 vs the round average" fallacy as at the Farmers applies.
C.4 Audit the outcome columns ⭐⭐. For calendar 2014, cross-tabulate the build's status against status_fixed for the player-events the build calls WD/DQ.
Expected shape: 218 build WD/DQ labels become 130 MDF, 83 genuine WD/DQ, 4 MC and 1 finished. Which of those would distort a "withdrawal rate" study most?
C.5 Compare two players: the 2026 Masters par 5s ⭐⭐. With rounds.wide_scorecard, print Scottie Scheffler's 2026 Masters scorecard, then compute McIlroy's and Scheffler's total strokes relative to par on the par 5s for the week.
Expected shape: Scheffler's rounds were 70, 74, 65 and 68 (277). On the par 5s McIlroy was −10 and Scheffler −5. Scheffler lost the tournament by one stroke. Write two sentences on what this does and does not tell you about either player's skill (sample size, one event, raw vs field-adjusted).
C.6 Variance on one hole (SIMULATED) ⭐⭐⭐. Play Marcus on water_right_approach_par4 with seeds 1 to 20 (shotsim.play_hole, one play per seed). Then replay 5,000 times (seed 2026) with marcus.with_(policy="center") and compare with the pin-policy replay in §2.9.
Expected shape (SIMULATED): seeds 1–20 give scores of 6, 5, 5, 4, 7, 4, 6, 7, 7, 5, 4, 8, 4, 6, 6, 4, 4, 5, 4, 5 (mean 5.3), with water in 10 of the 20 plays. Centre policy: mean 5.128, median 5, against 5.486 for the pin policy. That is 0.36 strokes per play from aiming at the middle of the green. Which number would you trust from 20 plays, and why?
C.7 Decode the zeros ⭐⭐. For 2019 and 2020, compute the share of player-statistics rows with driveDistAvg of 0 or missing, and the mean driving distance with and without the zeros.
Expected shape: 2019: 726 of 5,953 rows (12.2%); mean 258.5 yards including the zeros vs 294.5 excluding them. 2020: 152 of 4,123 (3.7%); 282.9 vs 293.7. Explain why the bias differs between the years, and what it would do to a "driving distance trend" chart.
C.8 Design your practice plan… for data entry ⭐⭐. Write the shot templates with rounds.write_templates, then enter one real hole of your own (or invent one). Deliberately make the three mistakes from B.7, run load_shots_csv, and read df.attrs["validation"].summary().
Expected shape: a report listing chain_break and not_holed_out errors at the hole and shot you edited; after the fix, "0 errors".
Notes on Part C
C.1 The phantom par 6 was a coding glitch, not a hole, and the consensus-par rule in the final build removes it (443 minority pars corrected across the snapshot). The habit is what matters: merge holes with courses on (event_id, hole) and count disagreements before you build any par-type table. If a future data refresh brings disagreements back, take par from the course document or drop the scorecards that disagree.
C.2 The TOUR returned to a calendar-year season starting in 2024. ESPN's 2023 season absorbed the autumn of 2022, which is why it holds 58 events, and from 2023 on the season and the year coincide.
C.3 A useful extra: compute each player's rounds 1–3 average and correlate it with how many rounds he played on the Stadium Course. In a rotation every player plays each course once, so the correlation should be near zero. If it isn't, the rotation wasn't balanced.
C.4 The 130 MDF players. They are not withdrawals, and in the second-cut era they would roughly double a naive withdrawal rate. The genuine 2014 rate is the 83.
C.5 One event, four rounds each, and raw strokes relative to par, with no adjustment for who else played or how hard the holes played that day. Chapter 10 shows that a single event says very little about skill (the within-event split-half correlation is low). It is a description of the week, not a skill estimate.
C.6 The 5,000-play means. Twenty plays have a standard error of about 1.97/√20 ≈ 0.44 strokes, which is bigger than the 0.36-stroke policy difference you are trying to measure.
C.7 2019 has far more zero rows (12.2% vs 3.7%), so including the zeros drags its average down by 36 yards against 11 yards in 2020. A trend line through "means with zeros" would show a fake jump from 2019 to 2020.
Part D — Judgment ⭐⭐⭐
D.1 A betting newsletter claims "pre-tournament favourites won 3 of the last 4 Opens", using a table built from ESPN data without the corrected columns. Which of the four events in §2.5 could make such a claim wrong, and what would you ask the author?
D.2 A club golfer shows you her app's strokes-gained report: "−2.4 approach, −0.6 putting". Her playing partner's app (a different brand) says "−1.5 approach". She concludes she is a worse iron player than him. What do you tell her?
D.3 You are building a "course difficulty" ranking of every PGA TOUR venue from 2004 to 2026 with raw scoring averages. List three quirks from §2.5 that would distort the ranking, and say how you would handle each.
D.4 A student wants to study morning/afternoon tee-time advantages and notices the timestamp in ESPN's round records. Before running any model, what three checks would you insist on?
Discussion notes
D.1 In the first-pass build, the 2022 and 2023 Opens both had the wrong winner in the raw won column (Cameron Young instead of Cameron Smith; Shubhankar Sharma instead of Brian Harman), so a table built from that version would score those two Opens wrongly. The final build's raw column agrees with won_fixed there, so also ask which version of the data the author used. Ask which columns were used, how "favourite" was defined before the event, and how many events the claim covers (four is far too few to say anything about prediction).
D.2 Different apps use different baselines and different category boundaries: Arccos defaults to a scratch benchmark, and Shot Scope counts every shot over 50 yards as approach. The two numbers are not on the same scale. Compare only within one system, against a stated baseline, and over enough rounds. Twenty rounds give category standard errors of about 0.3–0.7 strokes.
D.3 Field strength (strong fields at signature events and majors score lower), multi-course rotations (107 events: average by course-round signature, not by event), shortened events (11 with fewer than four rounds) and par differences (par-70 vs par-72 venues: compare strokes relative to a field model, not to par). Use field-adjusted course effects (Chapter 12) rather than raw averages.
D.4 (1) Coverage: in which years and events is the field present? (It appeared in our 2016 and 2026 samples, but not in 2004 or 2010.) (2) Meaning: does it match published tee sheets for a few events? (3) Structure: are there two-tee starts and split morning/afternoon draws, and does the timestamp's time zone match the course? Only then test for an effect, and use field-adjusted scores.
Part M — Mixed / Interleaved ⭐⭐–⭐⭐⭐
M.1 (with Chapter 1) Chapter 1's yardbook.ball_flight.load_launch_csv reads launch-monitor exports and recognises common column names. This chapter's load_shots_csv does the same for shot exports. Compare the two loaders' approaches to messy column names, and write one function normalise_columns(df, aliases) that both could share. What would you lose if a loader silently dropped unrecognised columns?
M.2 (with Chapter 1) Chapter 1 validated the flight model against TrackMan's published carries, and this chapter validated the simulator against Broadie's published expected strokes. In a short paragraph, compare the two checks. What was the reference in each, was the model fitted to it, and what does each agreement fail to prove?
M.3 (§2.5 with §2.9) The simulator's worst play (78 strokes) and the first-pass build's mislabelled 2023 Open withdrawals are both "tail" problems. Explain how each was found, and write a two-line rule for spotting such problems in any new dataset.
M.4 (with Chapter 1) Walt (Anchor C) has 20 simulated rounds in yardbook.cast and a driver scenario in Chapter 1 (178.7 yards of carry before fitting). Using cast.cast_rounds("Walt"), find his mean tee-shot distance on par 4s and 5s (the start distance of shot 1 minus the start distance of shot 2). Why can't this number be compared directly with Chapter 1's carry figure?
M.5 (§2.4 with §2.6) Write the pandas steps that would detect a multi-course event using only rounds (no course documents), and test them on the 2026 Farmers Insurance Open and the 2026 Masters.
Notes
M.2 Chapter 1: the reference was TrackMan's tour averages, and the aerodynamic coefficients were fitted to a set of TrackMan shots, so close agreement on similar shots is partly by construction. The out-of-sample long-drive check is the stronger evidence. This chapter: the reference was Broadie's 2003–10 baseline, and the tour preset was tuned to it. Neither agreement proves the mechanisms (dispersion shapes, flight details) are right everywhere, or that either model describes today's tour.
M.4 The shot table gives the distance to the hole, so drive length = start_dist(shot 1) − start_dist(shot 2). That is total distance including roll (and the simulator's distances are presets, not physics), while Chapter 1's 178.7 is a modelled carry. The cast's driver distances also include the deliberate "86% of preset" quirk.
M.5 Group complete rounds by (event_id, round) and count distinct par_signature values that have at least 8 rounds each. More than one means more than one course. The Farmers shows 2 in rounds 1–2 and 1 in rounds 3–4. The Masters shows 1 every round (signature b033ca4a).
Part E — Research & Extension ⭐⭐⭐⭐
E.1 Rebuild the corrections yourself. Starting from player_events.parquet and rounds.parquet (raw build columns only), write your own version of the outcome correction: classify each player-event as finished, MC, MDF or WD/DQ from round scores and the cut. Compare your labels with status_fixed over 2015–2026 and explain every disagreement category you find.
E.2 The tee-time field. Write a scanner, like code/02_build_rules.py, that records for every scoreboard file whether round records carry the timestamp field, and for what share of players. Report coverage by year. If coverage is good for a run of seasons, design (but don't yet run) a test of morning/afternoon scoring differences that compares players within course-rounds and handles two-tee starts.
E.3 Another tour. ESPN's API has other league paths besides pga. Without downloading more than one season, investigate whether hole-by-hole data exist for another tour, and list which of this chapter's quirks you would expect to meet there. Check the site's terms first, and keep the request rate as gentle as fetch_espn.py's.