Bayes at the Plate

Projecting a batter's end-of-season average, and its uncertainty, one 10-game window at a time.

BETA-BINOMIAL

Prior: Two Previous Seasons

Season 1 · two years ago
.280
Season 2 · last year
.288
Prior weights S1 0.40 · S2 0.50 → 460 pseudo-AB

Lower weights make the prior easier to move. Higher weights make it stubborn.

Prior θ ~ Beta(131.0, 329.0) · mean .285

Step Through the Season

After game 20
Pre4080120160
1 · 10-game avg
.344
11 H / 32 AB
2 · Season avg
.350
21 H / 60 AB
3 · Bayes final (G160)
.300
95%: .250–.352
True-talent θ
.292
α 152 · β 368

The Calculation, Step by Step

    4 · Uncertainty Curve: Final Average at G160

    Preseason Earlier windows Current window Season avg so far

    Season Trajectory

    10-game avg Season avg Bayes final 95% range Talent θ

    Current Season Log

    Edit any hits or at-bats. Click a row to jump to it.
    GamesHAB10-GSeasonBayes95% range

    6. Things to Try

    • Switch to Pooled 1.0 / 1.0 and press Play. The projection follows his hot season much more slowly.
    • Set both weights near 0. The prior almost disappears, and the projection just follows his raw average.
    • Edit games 1–10 to 18 for 28. Watch how little one hot window moves the final estimate.
    • Compare the 95% range at game 10 with the one at game 150. That gap is the cost of having a small sample.

    Input rules

    • Hits and at-bats must be whole numbers, hits ≥ 0, and hits ≤ at-bats.
    • Each prior season needs at least 1 at-bat unless its weight is 0. α₀ and β₀ are floored at 0.5 so the Beta stays valid.
    • Seasons above 700 at-bats get a soft warning. That's more than a realistic full season.

    7. Sources & Credits

    Cited in this guide

    • Tom Tango, Marcel the Monkey Forecasting System. The source of the 5:4 recency weighting used for the two-season prior. tangotiger.net/marcel · original description
    • FanGraphs Library, "Sample Size" (based on research by Russell Carleton). The source of the roughly 910 at-bat stabilization point for batting average. library.fangraphs.com

    Inspiration and further reading

    • David Robinson, Introduction to Empirical Bayes: Examples from Baseball Statistics. The Beta-Binomial batting-average framing was inspired by this book. Note that it builds its prior from league-wide data, while this app builds it from the player's own history. varianceexplained.org · book source
    • Bradley Efron and Carl Morris (1975), "Data Analysis Using Stein's Estimator and Its Generalizations." Journal of the American Statistical Association 70(350): 311–319. This is the classic study of predicting rest-of-season batting averages from early at-bats. DOI link

    Notes

    • Illustrative data. The default player and his seasons are illustrative and don't represent any real MLB player.
    • No affiliation. This app isn't affiliated with or endorsed by Major League Baseball, FanGraphs, or any author cited above.
    • Educational use only. It's a teaching tool for Bayes' theorem, not betting or fantasy-sports advice.
    • Code and fonts. All math and charts are original vanilla JavaScript and SVG, with no third-party libraries. The fonts are Inter and JetBrains Mono, used under the SIL Open Font License.