Julien's Faster than Light Blog
Jump to top
Friday, March 05, 2004
the simulator
the baseball pod project
the algorithm
the famous simulator. the simulator follows an algorithm of its own, obviously; that's what programs do. it's a larger algorithm that includes the smaller algorithm we lovingly call "the algorithm". at this point it uses a simplified version of the algorithm, but we're getting ahead of ourselves.
no we're not. the sim as it is now takes as input a comma-separated file whose first line is a pitcher and next nine lines are batters. then it takes another comma-separated file whose first line is a pitcher and next nine lines are batters. i could have said that more efficiently. the lines contain the following five pieces of information:
wal
con
hrp
xbp
1bp
as it develops, each line will contain many more pieces of information, each of which helps answer one or more questions in "the algorithm". or in the larger, all-encompassing algorithm that cradles "the algorithm" like a baby. oops, it burped.
wal is walks per plate appearance. con is contacts per at-bat.
"contacts isn't a word."
"yes it is. you put them in your eyes."
"no i don't. i wear glasses."
hrp is home runs per contact. it's good if it's large. unless you're a pitcher. xbp is extra-base hits per ball in play. home runs are not balls in play, so they are not included. 1bp is singles per non-extra-base-hit-ball-in-play. ain't it great? in other words, it's singles over singles plus outs in the field.
we're doin science here! the batter steps to the plate. imaginary batter. imaginary plate. check for a walk:
batter v pitcher wal = (bwal*pwal/lwal)/(bwal*pwal/lwal + (1-bwal)*(1-pwal)/(1-lwal)),
where bwal = batter wal, pwal = pitcher wal, and lwal = league wal.
then it's a simple percentage. generate a random number. presto bingo.
did he walk? he's on first. did he not? check for contact:
batter v pitcher con = (bcon*pcon/lcon)/(bcon*pcon/lcon + (1-bcon)*(1-pcon)/(1-lcon)),
where bcon = batter con, pcon = pitcher con, and lcon = yo mama (watch out for dickie.)
no contact? strikeout. contact? check for home run:
batter v pitcher hrp = (bhrp*phrp/lhrp)/(bhrp*phrp/lhrp + (1-bhrp)*(1-phrp)/(1-lhrp)).
i think you see the pattern.
home run? great. no home run? check for extra bases. you know how to do that. no extra bases? check for single. no single? out.
fielding is included in the pitcher's xbp and 1bp, but that's an imperfect system. we are ever-evolving. also we don't do any baserunning. hits move runners over as many bases as they move batters. there are no stolen bases. these things will come in time. as will pitcher changes, manager tantrums, and fans charging the field (look for version 173.0).
propigate through the lineups zappa-dappa you got a game. do it 10,000 times. who's the winner?
we are. with correct baseball prognostication, everyone wins.
Comments:
Post a Comment