Introduction
This vignette covers bouncer’s prediction capabilities: - Pre-match predictions: Who’s favored before the game starts? - In-match win probability: Live updates as the game progresses - Score projections: What’s the expected final score?
Pre-Match Predictions
Predict the outcome before a match begins:
library(bouncer)
# Basic match prediction
prediction <- predict_match("India", "Australia", format = "t20")
print(prediction)The prediction uses: - Team ELO ratings - Recent form - Head-to-head history - Team skill indices
Adding Venue Context
# Prediction with venue
prediction <- predict_match(
team1 = "India",
team2 = "Australia",
format = "t20",
venue = "Melbourne Cricket Ground"
)
print(prediction)In-Match Win Probability
Calculate live win probability during a match:
# First innings: batting team at 85/2 after 10 overs
wp <- predict_win_probability(
current_score = 85,
wickets = 2,
overs = 10.0,
innings = 1,
format = "t20"
)
print(wp)Second Innings (Chasing)
# Second innings: chasing 180, currently 100/3 after 12.4 overs
wp <- predict_win_probability(
current_score = 100,
wickets = 3,
overs = 12.4,
innings = 2,
target = 180,
format = "t20"
)
print(wp)
# The required run rate is factored into the probabilityScore Projection
Project the final innings score from any game state:
# Scoreboard: "Mumbai Indians 80/3 (10.0 overs)" in T20
projected <- calculate_projected_score(
current_score = 80,
wickets = 3, # wickets fallen (matches scoreboard)
overs = 10.0, # overs bowled (matches scoreboard)
format = "t20"
)
print(projected)Understanding Resource Percentage
The projection uses a resource-based formula similar to Duckworth-Lewis:
# Calculate resource percentage remaining
resource <- calculate_projection_resource(
wickets_remaining = 7, # 10 - 3 wickets fallen
balls_remaining = 60, # 10 overs left
format = "t20"
)
print(resource) # e.g., 0.65 = 65% of resources remainingResources depend on: - Wickets in hand (more wickets = more resources) - Balls remaining (more balls = more resources) - The interaction between them
Understanding ELO and Win Probability
ELO ratings convert to win probability using the standard logistic formula:
Formula:
P(A wins) = 1 / (1 + 10^((ELO_B - ELO_A) / 400))
Example calculations:
| ELO Difference | Higher-Rated Team Win Probability |
|---|---|
| 0 (equal teams) | 50% |
| +100 points | ~64% |
| +200 points | ~76% |
| +300 points | ~85% |
The 400 divisor means that a 400-point difference corresponds to roughly 10:1 odds (91% win probability).
In bouncer: - Starting ELO is 1500 for all teams - ELO updates after each match based on result vs expectation - Format-specific ELO tracks performance within T20/ODI/Test separately
Matchup Predictions
Predict specific batter vs bowler outcomes:
# What happens when Kohli faces Bumrah?
matchup <- predict_matchup_outcome(
batter = "V Kohli",
bowler = "J Bumrah",
format = "t20"
)
print(matchup)Team Comparison
Get a comprehensive comparison of two teams:
comparison <- compare_teams("India", "Australia", format = "t20")
print(comparison)
# Includes:
# - Current ELO ratings
# - Win probability
# - Recent form
# - Head-to-head record
# - Skill comparisonsPrediction Accuracy
The prediction models are calibrated on historical data. Typical accuracy:
| Prediction Type | Accuracy |
|---|---|
| Pre-match winner | ~65-70% |
| Score projection | RMSE ~15-20 runs |
| Win probability | Well-calibrated (50% events happen ~50% of time) |
See Also
-
vignette("getting-started")- Package overview and setup -
vignette("simulation")- Monte Carlo match simulation -
vignette("match-analysis")- Analyzing completed matches
