March 20, 2008

lineup optimization using Cubs 2008 ZiPS projections

Back in 2006, I got it into my head to try my hand at writing a simulator for the express purpose of optimizing lineups. It would go through all 9! permutations of the lineup and actually play simulated games, and then output the average runs scored for each lineup. You can see the original post here and the follow-up using stats taken from the 2005 Astros here. I never did get around to updating the algorithm (although it's still on my to-do list), but since I finally got myself a new computer I decided to try something that my friend suggested, which was to run a set of projections through the program in order to predict what the optimum lineup would be for the forthcoming year.

The program finally finished the run (marginally faster - about 50 hours run time) using the 2008 ZiPS projections for the Cubs. I used the projections for the following eight players: Lee, Ramirez, Fukudome, Soto, Pie, DeRosa, Theriot, and Soriano; and then summed up the actual 2007 lines for the five pitchers with the most ABs (Z, Lilly, Hill, Marshall, Marquis) to make a sort of "average" pitcher. I'd like to reiterate that this algorithm doesn't take into account errors, steals, player speed, GIDP, handedness, sacrifice flies or sac bunts, and baserunning is strictly station-to-station. The algorithm also does not take into account any other strategy - i.e., it doesn't pitch around guys to get to the pitcher. In addition, ZiPS doesn't project hit-by-pitches.

That said, here are the results for the top 10 and bottom 10 lineups, as well as the results for the starting lineup from the March 18th spring training game.

Continue reading "lineup optimization using Cubs 2008 ZiPS projections" »

December 12, 2007

hot stove roundup

As anyone who knows me knows, I'm a Cubs fan, but I also follow the Astros simply by dint of living in Houston. So far, I haven't been too terribly impressed by Ed Wade (the new Astros GM's) and his deals.

Let's see:

  1. Trade RP Brad Lidge for CF Michael Bourn, RP Geoff Geary, and prospect Mike Costanzo, and then trade CF Josh Anderson for RP Oscar Villareal. What? Bourn is probably better than Anderson, but both Geary and Villareal are definitely worse than Lidge. Two mediocre relievers don't add up to one decent one.
  2. Sign 40 year old RP Doug Brocail. Again, what?
  3. Sign 2B/SS Kaz Matsui for 3 years/$16.5 million. This is either a horrible, horrible signing or the Astros front office believes his Coors Field/rest of the ballparks in the nation split is a total aberration. (It's not.)
  4. And today, they decimated the already thin farm system by trading OF Luke Scott, SP Matt Albers, minor league SP Troy Patton (a top prospect), minor league SP Dennis Sarfate (also a good, but not great prospect), and 1B/3B/DH Mike Costanzo (another top prospect, acquired from the Phils in the Lidge trade) to the Orioles for 2 years of 3B/SS Miguel Tejada.

What I want to know is, where does Ed Wade get his drugs, and how do I get some?

October 6, 2007

100 years

Well, that was brutal. Cubs get swept, grounding into 4 double plays and leaving 10 men on base in the final game alone. Depressing.

September 28, 2007

2007 NL Central Champions

current Chicago Cubs logo

Now on to the postseason...

September 27, 2007

three is the magic number

It felt a little weird rooting for the Cardinals, but if the Cubs can't do it themselves...

Go Padres! Beat the Brewers!

September 5, 2007

baseball, baseball, baseball

cover to "Moneyball" cover to "The Cheater's Guide to Baseball"

I finally got around to reading "Moneyball" by Michael Lewis. If you're a sports fan in general, you should read this book, but if you're a baseball fan, this is a must read. Even non-sports fans who have an analytical mind should consider reading this book; the principles Billy Beane brought to Major League Baseball are applicable in many fields, and Lewis has a breezy writing style that makes for an easy, engaging read. He shows us an insider's look into the workings of a major league ballclub.

"The Cheater's Guide To Baseball" by Derek Zumsteg (one of the proprietors of the U.S.S. Mariner website, and a contributor to Baseball Prospectus) is an in-depth look at the vast history of cheating in the game of baseball. Brawling, gambling, steroids, corking bats, the spitball, and other methods of cheating, both tacitly approved and patently illegal are examined. Zumsteg writes with an irreverent and humorous voice, and does a great job of illustrating where the line is drawn for most hardcore baseball fans with respect to cheating. All in all, a fun read, though probably less so for someone completely uninterested in baseball.

And one last thing - the Cubs are going to give me a coronary by the end of September:

NL Central standings, end of 5 September 2007

August 2, 2007

division leader

Boo-ya.

Unbelievable.

June 26, 2007

swing and a miss

turner_field_500x204.jpg

Well, the baseball season is nearly halfway finished already, and the Cubs are 3 games under .500 and 7.5 back from the Brewers. Frankly, the entire NL Central is terrible, with the possible exception of Milwaukee. I didn't expect too much out of the Cubs, but I did expect them to be better than this. The bright spot has been that I have managed to get out to a few games here and there, and already this year have been to four different ballparks (Turner Field is pictured above) with a fifth (and maybe sixth) to come later in the year.

Anyway, check out my baseball photos, and if you're coming to Houston and want to catch a game, drop me a line.

April 10, 2007

we paid how much for these guys?

Well, the 2007 baseball season is off to an unusual start, what with Cleveland being snowed under in April, resulting in the next series being played in Milwaukee. Neither the Cubs nor the Astros are doing particularly well, although the Astros are currently teeing off on Cubs pitchers. Anyway, in case you missed it, the New York Times ran an article last week about a college pitcher at Creighton who can pitch with both arms. It's an interesting read; and I'm somewhat surprised it hasn't happened more frequently. They're saying he make may the late rounds of the draft this year. I would love to be in the ballpark when he throws; that would be interesting to score...

March 19, 2007

the great American pastime

Well, we're about two weeks away from the start of the major league baseball season. Now that I have a real income, I can actually afford to go to games. And now that it seems all my friends are busy getting married, I may be able to knock off a few more ballparks from the list. If you're coming into Houston and want to catch a ball game, let me know, I'm usually happy to go.

Currently, Baseball Tour 2007 looks like this:

  • Chicago - May 25 - June 3 <- these will not be new ballparks for me
  • Atlanta - June 22-24 <- Turner Field, new
  • New York - September 7-9 <- Shea Stadium, new; if I come early I might be able to go to Yankee Stadium as well

November 10, 2006

another photo Schmap'd

shortly before the blown save

Another one of my photos has been included into an electronic travel guide produced by Schmap, but this time it's for Houston. (The last three were from Chicago.) They've chosen a picture I took from the third base side of Minute Maid Park during the 9th inning of a Dodgers-Astros game earlier this year. Just prior to this picture, Kenny Lofton hit a triple off of Brad Lidge, who went on to blow the save.

October 17, 2006

there goes 2007

And with this announcement, the Chicago Cubs 2007 season is probably flushed down the toilet. Lou Piniella is basically a whiter, older, louder, in-your-face version of Dusty Baker. They're even saying he might bring back much of the coaching staff, including Rothschild, which means our young pitchers continue to be doomed. The only good thing about this announcement that I can find is that A-Rod likes Lou, so maybe we'll be able to get him in a trade. That would fill the giant sucking sound you hear coming from the shortstop position.

Crap.

July 31, 2006

who's captaining this ship?

Today is the non-waiver trade deadline in baseball. The Cubs made two trades. Separately, they're not horrible, but taken together they suck. Todd Walker (good hitting, sub-par fielding 2B) went to the Padres for a 19-year old rookie league pitcher Jose Ceda. Not horrible; Walker's contract is up this year and it was unlikely he would be resigned due to the ridiculous abundance of cheap mediocre middle infielders with the Cubs both at the MLB and AAA levels (Perez, Cedeno, Theriot, Fontenot). Plus it would encourage Dusty to actually play the young players for evaluation purposes, as 2006 is a lost season.

The worse deal was Greg Maddux to the Dodgers for César Izturis (SS, Gold Glove winner, sub-par hitter), contingent on approval from the commissioner's office due to the amount of cash that is also trading hands. We already have defensive middle infielders - a lot of them (see above) and now it suggests playing Izturis at starting SS and Perez or Cedeno at 2B, negating the major plus of the Walker trade; namely, the chance at evaluating Theriot or Fontenot at the MLB level. Plus losing Maddux just sucks. I know that he's not the pitcher he used to be, but he's still a serviceable 4th or 5th starter, and the mentorship he provided for the rookies (Sean Marshall and Carlos Marmol both have been quoted many times this season as picking Maddux's brain while sitting on the bench together) is invaluable. He started his career in a Cubs uniform, and I would have liked to see him finish it in one.

July 11, 2006

my new favorite MLB player, Corey Hart

Jon Corey Hart - Brewers OF Corey Mitchell Hart - Sunglasses At Night

I don't even know if this kid is any good - he's a 24 year old 4th outfielder for the Milwaukee Brewers - but I crack up everytime I see his name because I keep thinking about that old 80's song "Sunglasses At Night."

June 23, 2006

one more ballpark down

Fenway panorama

I was in Boston over the weekend for business and got a chance to go catch a Red Sox game vs. the Nationals. Lots of actual baseball fans who know their stuff, as opposed to the casual viewer you get here in Houston. And some of the best ballpark food I've seen (at least, outside the ballpark). I'm steadily knocking ballparks off the list; hopefully I'll get to a couple more before the summer is over.

So far:

  • Wrigley Field
  • U.S. Cellular Field (new Comiskey)
  • Minute Maid Park
  • Fenway Park
  • Angel Stadium

I have a long way to go; only 5 of 30 down...

June 12, 2006

the road to Omaha

The Rice Owls just beat Oklahoma 9-5 in the rubber match of the 3-game series. At least one baseball team I like is doing well.

June 8, 2006

waiting for the 2007 Cubs

Ticket to the 5 June 2006 game between the Houston Astros and Chicago Cubs, signed by Matt Murton (19)

I went to the ballpark twice this week to watch the Chicago Cubs take on the Houston Astros. On Monday, the Cubs dominated the Astros in an 8-0 victory, displaying a glimpse of the true potential of certain members of the team. Most notably, Carlos Zambrano pitched 8 innings, giving up only 2 walks with 8 strikeouts. He carried a perfect game through 4, and the no-hitter through 7 1/3. Ohman came in and finished with a perfect 9th inning. Zambrano even hit one out, making that the second home run I've seen him hit in Minute Maid Park. Before the game, I managed to get my ticket signed by Matt Murton, #19. Clicking on the photo above will take you to my pictures of the game.

Unfortunately, the Cubs turned around and dropped the next two to the Astros, wasting some great outings by some young pitchers. Carlos Marmol, called up from AA, pitched two solid innings in relief of Kerry Wood on Tuesday, striking out three, walking none, and giving up two hits with no runs; Sean Marshall, also called up this year from AA to slot into the starting rotation (as the Cubs #3!), went seven on Wednesday giving up four hits (one a solo shot by Ausmus; the only run scored all day) with five Ks and three walks; and Rice alumnus David Aardsma pitched 2/3 in relief with zeros across his line.

This has been the story of the 2006 season; taking games from good teams (2 of 3 vs. the Cardinals over the weekend, 6 of 9 so far this season) and blowing games against mediocre teams and rookie pitchers. The Cubs batters have a strong tendency to hack away with no plate discipline, a philosophy that is just as likely due to crappy management (Fire Dusty Baker!) as it is to having players with historically crappy OBP (see: Neifi Perez). I'm still rooting on the Cubs, and I'm still going to go to games, but 2005 Astros aside, I've pretty much written off the season. I just hope that the management sees it too and starts building for the future, rather than trying to put a finger into the hole in the dike when the whole foundation is crumbling.

March 26, 2006

preliminary results

As mentioned previously, I wrote a lineup simulator in C to run through all 9! permutations. I tested it against the 2005 Astros. The full results are here (6.8 MB gzipped text file), but here are the top 10 and bottom 10 lineups.

The classic lineup:

This lineup clocks in about 1 run per game lower than was actually scored last year. Part of this probably is due to not accounting for steals, defensive errors, or sacrifices.

Continue reading "preliminary results" »

March 22, 2006

my first step into sabermetrics

In a true display of my extreme geekiness, I have written a baseball simulator to run through all 9! (9 factorial = 362,880) permutations of the lineup in order to determine which one is optimal. There was a bit of talk on some of the sabermetric sites about lineup optimization a few weeks ago, and someone suggested that the best way would be to write a simulator, so I did. It's been a pretty good opportunity to brush up on my programming skills.

It's basically a Monte Carlo simulator that generates a random number and compares it against a player's statistics to determine whether the result of that particular at bat should be a walk, single, double, etc. This simulator doesn't take into account sac flys, sac bunts, steals, or double plays, so it consistently underestimates the run totals, but it should provide a reasonable first order approximation. I've written in a hook for a possible routine for double plays, and it ought to be possible to take sacrifices and speed into account as well, but that would probably require a significant rewrite and consequently increase the run time. I've spent the last few days tweaking the code to get it to run as fast as possible, but for any sort of statistical validity it still takes about 2 1/2 days to run through all the permutations (at about 150,000 to 250,000 games per lineup, we're talking about 72 billion simulated games). Currently I'm testing it out against the 2005 Astros, using the aggregated stats for the pitchers in one slot.

The current version of the code is here; I compile it with the following command on Mac OS X running on a G4-based machine:

gcc -o simulator_gsl simulator_gsl_switch.c -lgsl -mdynamic-no-pic -fast -mcpu=7450 -g

It requires the GNU Scientific Library (hence the -lgsl option on the command line) because it uses the GSL random number generator library; the Mersenne Twister random number generator helped shave a few percent off the overall run time. I originally wrote the scoring function using if/else statements, but have rewritten the subroutine using the switch/case conditionals, which is also slightly faster. I'm trying to see if there are any other places I can eke out a little better performance, but I think the real project will be to rewrite the code so that it can run in parallel on multiple CPUs. Parallel processing should provide nearly linear acceleration (this problem is, as they say, "embarrasingly parallel"), and I have a few older computers around that could contribute CPU time...

Anyway, once I'm done running the program against the 2005 Astros lineup, I'll post the results here.

Update: For those who want to download and compile the program to run it themselves, feel free. It will ask you for a tab-delimited text file with the player statistics in it. It should have the extension .txt, and each player should be given their own line in the file with stats in this order: name, plate appearances, walks, hits, doubles, triples, homers, strikeouts, GIDP, hit by pitch.

October 25, 2005

the fall classic

fall_classic_logos.png

Well, this year's World Series has already proven to be an exciting one. I'm not going to comment too much on it; it's a shame that the Astros are down 2-0 at this point. Both games could have gone the other way very easily. I expect to see this series go out to at least six games, and possibly seven. You may want to pop over to South Side Sox or Crawfish Boxes to read about what's going on, but basically, we're seeing some pretty exciting games that are coming right down to the wire. I won't be able to watch all of tonight's game due to my radio show, but I'll be following the action as best as possible.

Update (1:54 am): Well, that was depressing. A 14-inning game loss, after being up 4-0. Unless the Astros pull it together tomorrow (how many men were left in scoring position? Why can't anyone hit a goddamn sac fly?) they might get swept.

October 12, 2005

better the Astros than the Cards

ticket to the 6 hour, 18 inning game 4 of the 2005 NLDS between the Astros and Braves

I was actually at Minute Maid Park on Sunday for the amazing 6 hour, 18 inning marathon of a baseball game between the Houston Astros and the Atlanta Braves. I've seen plenty of games at Minute Maid with the roof closed, but I have never heard the crowd that loud. It was definitely the most exciting game I've ever been privy to see.

Anyway, today the Astros face off against the hated Cards; it should be a good match. I'm afraid that the Astros will lose the series - their bats just aren't consistent enough - but I'd hate to be the Cardinals facing off against the big three (Pettitte, Clemens, and Oswalt). Even Backe is a pretty decent pitcher, and the Houston bullpen is very deep - Sunday's game illustrated that. We'll see what happens...

October 9, 2005

goin back to cali

Sticker_YankeesLogo_inv.gif

And congratulations to the Astros. I didn't get to see it, but it sounds like it was a hell of a win.

August 11, 2005

finally, a Cubs win

current Chicago Cubs logo
The Cubs snapped their eight game losing streak with an 11-4 victory over the NL Central division leading Cardinals. Maddux threw a complete game, and with the win ended up tying Gaylord Perry at 16th on the all-time wins list with 314 career wins. Derrek Lee added two home runs to his total, keeping his Triple Crown dream alive, but realistically speaking, this season is pretty much over for the Cubs. I'm going to go watch them play the Astros next week, and I'll be rooting for them, but they're 7.5 games back from the Astros for the wild card and 5 other teams _besides_ the Astros are standing in the way. I did find a pretty funny Cubs joke, though, at the WGN Sports Cubs Baseball Blog. It goes like this:
A Chicagoan dies and is sent to the great below. He had been a horrible man throughout life and even the devil wanted to punish him, so he puts him to work breaking up rocks with a sledgehammer. To make it worse he cranks up the temperature and the humidity. "Love my kingdom!" laughs the devil. After a couple of days the devil checks in on his victim to see if he is suffering adequately. The devil is aghast as he looks at the Chicagoan happily swinging his hammer and whistling a happy tune. The devil walks up to him and says, "I don't understand this. I've turned the heat way up, it's humid, you're crushing rocks; why are you so happy?" The Chicagoan, smiling big, looks at the devil and replies, "This is great! It reminds me of August in Chicago. Hot, humid, a good place to work. It reminds me of home. This is fantastic!" The devil, extremely perplexed, walks away to ponder the Chicagoan's remarks. Then he decides to drop the temperature, send down driving rain and torrential wind. Soon, hell is a wet, muddy mess. Walking in mud up to his knees with dust blowing into his eyes, the Chicagoan is happily slogging through the mud pushing a wheelbarrow full of crushed rocks. Again, the devil asks how he can be happy in such conditions. The Chicagoan replies, "This is great! Just like April in Chicago. It reminds me of working out in the fields with spring planting!" The devil is now completely baffled. Angry, and desperate to make things really awful, he tries one last ditch effort. He makes the temperature plummet. Suddenly the devil's lair is blanketed in snow and ice. Confident that this will surely make the Chicagoan unhappy, the devil checks in on the Chicagoan. He is aghast at what he sees. The Chicagoan is dancing, singing, and twirling his sledgehammer as he cavorts in glee. "How can you be so happy? Don't you know its 40 below zero?" screams the devil. Jumping up and down, the Chicagoan throws a snowball at the devil and yells, "Hell's frozen over!! This means the Cubs are in the World Series!!!

June 9, 2005

the great American pastime

I've been experiencing renewed interest in baseball of late; part of it has to do with the fact that I was attending Rice University (whose baseball team won the NCAA Division I championship in 2003) and the other part of it is probably just due to the fact that I have a job now and can actually afford to catch a couple of ball games here and there. In a roundup of baseball-related news that interests me, Rice will be playing Tulane in New Orleans this weekend in a best-of-three NCAA Super Regional tournament to see who gets to go to Omaha. Tulane is ranked number one in the nation, and as much as I hate to say it, will likely beat Rice. Rice pitching has been solid, although not as good as the 2003 team, but more to the point, the offense has been a little like the Astros in not coming up with runs when they need them (at least when I've been listening to the games). The Cubs host the Red Sox this weekend; the last time they faced each other was in the 1918 World Series, when the Red Sox won in six. I thought the Cubs had turned it around on their west coast road trip, but back at Wrigley them seem to be tanking again. Although they're above .500, they're still seven games behind the Cardinals. And Houston is once again at the bottom of the division... The Yankees have an interesting problem on their hands - too many starting pitchers. They called up Taiwanese pitcher Wang Chien-Ming from the minors about a month ago when Jaret Wright injured his shoulder. Surprisingly, Wang has probably been their most consistent starter of late, among a rotation that includes Randy Johnson, Mike Mussina, Kevin Brown, and Carl Pavano. Wright is scheduled to return to the rotation soon, which would mean that someone would have to be sent down (or tapped to be a reliever). They already have enough problems with a five-man rotation - Randy Johnson insists on pitching on four days rest, and with travel days thrown into the schedule, which of the multi-million dollar pitchers do you choose to skip?

May 20, 2005

the rocket's fizzled out

Lopez's sidearm delivery
Last night I went to go see the Astros play against the Diamondbacks. Thanks to my boss, we had good seats - 28th row behind the plate. On paper, the matchup should have been a no-brainer - Halsey is a rookie pitcher, Clemens has over 300 wins - but the reality of the game showed otherwise. Clemens posted 2 earned runs and a third unearned on 3 errors in the 1st inning. He shut them down after that, but the damage was done. The Astros are having a real problem with run support this year - there were a couple of great opportunities to score but hit into double plays quite a bit - and then Burns gave up 3 in the 9th to really push the game out of reach. I got some decent pictures, though - you can see them up at Flickr.com. The picture above is of Diamondbacks lefty specialist Javier Lopez just after releasing the ball from his sidearm delivery. You may be interested in checking out The Crawfish Boxes and Bleed Cubbie Blue; they're two blogs started under the umbrella of the SportsBlog empire (founded by Daily Kos' Markos Moulitsas). Right now there's not too much traffic to either - they're relatively new - but if you're a fan of the Astros or the Cubs you might be interested in stopping by.