Skip to contents

Simulates a single delivery outcome using the full prediction model.

Usage

simulate_delivery(
  model,
  match_state,
  player_skills,
  team_skills,
  venue_skills,
  mode = c("categorical", "expected")
)

Arguments

model

XGBoost model from load_full_model()

match_state

List containing current match state:

  • format: "t20", "odi", or "test"

  • innings: 1 or 2

  • over: current over (0-indexed)

  • ball: ball within over (1-6)

  • wickets_fallen: wickets lost so far

  • runs_scored: runs scored so far in innings

  • target: target to chase (innings 2 only, NULL for innings 1)

  • gender: "male" or "female"

  • is_knockout: 0 or 1

  • event_tier: 1, 2, or 3

player_skills

List with batter and bowler skills:

  • batter_scoring_index, batter_survival_rate, batter_balls_faced

  • bowler_economy_index, bowler_strike_rate, bowler_balls_bowled

team_skills

List with team skills:

  • batting_team_runs_skill, batting_team_wicket_skill

  • bowling_team_runs_skill, bowling_team_wicket_skill

venue_skills

List with venue skills:

  • venue_run_rate, venue_wicket_rate, venue_boundary_rate, venue_dot_rate

mode

Character. "categorical" (draw outcome) or "expected" (use expected runs)

Value

List with outcome details:

  • runs: runs scored (0-6, or fractional if mode = "expected")

  • is_wicket: TRUE if wicket fell

  • probs: 7-class probability vector

  • exp_wicket: numeric wicket probability (expected mode only)

See also

simulate_innings to simulate a full innings, simulate_match_ballbyball to simulate a full match, load_full_model to load the prediction model

Examples

if (FALSE) { # \dontrun{
model <- load_full_model("shortform")
state <- list(format = "t20", innings = 1, over = 5, ball = 3,
              wickets_fallen = 1, runs_scored = 42)
player <- list(batter_scoring_index = 1.3, batter_survival_rate = 0.97,
               bowler_economy_index = 1.2, bowler_strike_rate = 0.03)
team <- list(batting_team_runs_skill = 0.05, batting_team_wicket_skill = 0,
             bowling_team_runs_skill = -0.02, bowling_team_wicket_skill = 0)
venue <- list(venue_run_rate = 0, venue_wicket_rate = 0,
              venue_boundary_rate = 0.15, venue_dot_rate = 0.35)
result <- simulate_delivery(model, state, player, team, venue)
} # }