Another new Plutor.org

This morning you may notice some changes to plutor.org (unless you’re reading this in an RSS reader, in which case I invite you to check out what I’m talking about). For the past few years, my Twitter posts, photos, links I’ve found interesting, and occasionally music that I’m listening to have all been intermingled here as a life stream. I will no longer be featuring those things so prominently on this blog. Oh, they still exist, on Pinboard and Twitter and Flickr and elsewhere (you can find links to all of them on the bottom of the homepage).

But I’ve decided that this website should be more focused on my nerdly projects. You know, the visit all MLB parks and expected value of a Powerball ticket things. I’ve heard that people like those posts, and I like those posts, and I’d like to encourage myself to make more of them. And rearranging my online life is the best way I know to do that.


Reactions from PAX East 2012

Along with the pictures I took at PAX East – mostly of the predictably solid tabletop and arcade sections – here are some brief thoughts and reactions:

  • Played a couple hours of D&D with some pre-rolled characters. That was more fun than I expected.
  • The expo floor and PC freeplay were both a lot bigger this year, which meant that the storefront and tabletop areas got shrunk. In fact, the tabletop area was packed for most of both Saturday and Sunday.
  • Tried to get into the Diablo III line, but it was super long every time we showed up, even first thing on Easter Sunday.
  • In fact, the PC freeplay sessions were limited to a mere 30 minutes this year, which was really not long enough to get a good session in. We heard rumors of a lot of political turmoil around the PC
  • Driver: San Francisco has a really cool premise, and I enjoyed the driving physics a lot.
  • We played a whole lot of tabletop. Power Grid is interesting, but it's lonngggg, and I can understand the criticism of calling it "Excel: The Game".
  • Small World is fantastic; I would have bought it immediately if it wasn't $60.
  • Magical Athlete is way more fun than it deserves to be.
  • Saboteur was a wonderful game for a group of 8 people who all only sorta knew each other.
  • The Omeganaut finale of Crokinole was inspired.
  • Boy am I glad PAX East will be in Boston for ten more years. I was worried that after this year, it'd move elsewhere on the east coast. Nice to know it's staying.

2011 in books

It is now March, and I have somehow never posted my reading log for 2011. Last year was a light one for my reading, and I’m not entirely sure why. The books below represent a thousand pages less than in 2010 (4794, or an average of ~13 pages a day).

See also 2010, 2009, 2008, 2007, 2006, and 2005.


I'm an image meme

Three winters ago, I took this picture while I was working from home, waiting for the icy roads to warm up. Since then, it’s become a fairly common photo to accompany blog posts about working from home. (Thanks, in part, to my very friendly Attribution-only Creative Commons licensing.) Here are a couple examples.

But now it’s come back to bite me. I’m now an image meme called “Freelancer Fred”. It’s on quickmeme, and BoingBoing covered it yesterday.


Watching every MLB team play a game

Last April, to no one in particular, I asked the following question:

"What's the shortest possible trip (in miles) to see every MLB team play at least one game this season?"

It became clear, after a brief discussion with some friends, that the shortest possible trip is somewhere on the order of a hundred miles. Citi Field in the Bronx and Yankee Stadium in Queens are only 6 miles apart. Since the Mets and the Yankees are in different leagues and each team plays one series at home against every other team in its own league, you could just spend the whole season going back and forth between the two stadiums. (In fact, I’d be surprised if at least one New Yorker baseball fan with time and money to burn hadn’t done exactly this.)

In order to avoid this “trivial” solution, a modification to the puzzle would have to be introduced. After throwing around a bunch of attempts, I hit upon the perfect goal: 15 games, 15 stadiums, 30 teams. You’d see no team play more than once, you’d be in no stadium more than once.

Now that I had a problem worth solving, how to solve it? The sheer number of games makes it pretty clear that this is a task that can’t be solved by brute force. There are 2430 games in a regular season of baseball. The possible number of any selection of 15 of those games is 4.45 × 1038. Even if I could check a trillion schedules a second (which I can’t), it would still take 14 billion billion years (at which point, even the Red Sox would probably have a new stadium). If you visualized the problem as a graph, each game would be a node and each travel day would be an edge. The problem was that every game had an edge that led to every game that came after it. What I needed to do first was prune this tree.

So I made some assumptions for the sake of making a reasonable road trip. I wouldn’t want more than 2 days off between games, and I wouldn’t want to travel more than 500 miles on any given day. This change trimmed the 3-million-plus edges into a mere 86,000. But an exhaustive search would still take a prohibitively long time: at that same impossible speed, I’d have my answer in merely 11 billion years. I made the problem more than a billion times smaller, but realistically I wasn’t any closer to the solution.

It was about this time that I decided I was never going to get the perfect answer. I would have to resign myself to a Good Enough plan that could be calculated before the heat death of the universe (or better yet, before Opening Day). I brushed up on my Traveling Salesman Problem and pathfinding algorithms like A*, Dijkstra’s, and Floyd-Warshall. But my problem had a couple of quirks that made those approaches unsuitable:

  • With both A* and Dijkstra's, you have defined starting and destination nodes. I did not want to specify either. I wanted the schedule (and the map) to dictate the best time of the season to take the trip.
  • Pretty much every algorithm I read about optimizes for total distance, and nothing else. A perfect road trip might start at Wrigley and end at US Cellular a month later, but it most definitely would not be the shortest distance between those two points.
  • Most importantly, I was very particular about exactly which nodes could be on the same schedule. Two games might not have an overlap, but once I decided to go to both of them, the options for the third game get narrowed down. Likewise for every step along the way.

After three or four false starts (and one moment where a bug in my data structure made an exhaustive search running a couple quadrillion times faster than it should), I happened upon a promising technique. A commenter on Stack Overflow recommended (in response to a purposely vague question) doing a sort of prioritized breadth-first search. What I ended up doing was starting with a list of all of the one-game plans (2430 plan, one for each game). And then I did this:

  1. Remove the plan with the shortest average leg length from the list (ties are unimportant -- pick arbitrarily)
  2. Look at every game that you could add to the end of that plan that meets the restrictions: 2 or fewer off days, no more than 500 miles of travel per day.
  3. For every one of those games, check if it's legal to add to this plan (check for team duplications against every game already on the plan)
  4. If there are no duplicates, add it to the list of plans. Since each game has a couple dozen possible "next" games, this will likely result in the number of plans in the list growing.
  5. If there are more than some number of plans in the list, discard the longest ones. (After some experimentation, I went with about half a million. Much more on this another time.)

And I repeated until the “shortest plan” was 15 games long. On the first try, it took about 3 and a half hours on my laptop (Core i5 with 4GB of RAM) and had to inspect more than 12.5 million potential plans before finding one that was a full 15 games long. The solution was almost 5,500 miles long, and included back to back 800-mile legs from Los Angeles to Denver and then to St. Louis. That did not strike me as optimal. I considered what could be preventing the discovery of a good plan: the problem is that the shortest eight-game plan might not yield any short nine-game plans, and if the list is full and discards the longer eight-game plans before they can even be checked, then it will never pursue the most promising leads. In truth, I run four lists in parallel, and they fit 219-1 elements each (a little over 500k). But the lists are full after only three minutes of inspecting plans (less than half a million). These lists take up more than 2GB of memory right now.

I chose to try the script on an Extra Large Amazon Elastic Compute Cloud instance. This includes not quite as much CPU power as my laptop, but four times the memory. I also changed the way the algorithm treated “the shortest average leg length”, by giving plans with more legs a bonus. It found this schedule in less than ten minutes, and failed to find a better one even after searching through 20+ million more. (This is a thousand miles shorter than the one I found earlier, and the only really long leg is from Boston to Minneapolis.)

2012-07-18: Blue Jays @ New York Yankees

  • Travel 6.5 mi 2012-07-20: Dodgers @ New York Mets
  • Travel 91.2 mi 2012-07-21: Giants @ Philadelphia Phillies
  • Travel 121.6 mi 2012-07-22: Braves @ Washington (DC) Nationals
  • Travel 306.6 mi 2012-07-24: Tigers @ Cleveland Indians
  • Travel 309.9 mi 2012-07-27: Cardinals @ Chicago Cubs
  • Travel 76.4 mi 2012-07-30: Astros @ Milwaukee Brewers
  • Travel 326.4 mi 2012-07-31: Padres @ Cincinnati Reds
  • Travel 250.6 mi 2012-08-03: Angels @ Chicago White Sox
  • Travel 408.8 mi 2012-08-06: Diamondbacks @ Pittsburgh Pirates
  • Travel 196.9 mi 2012-08-07: Mariners @ Baltimore Orioles
  • Travel 358.4 mi 2012-08-08: Rangers @ Boston Red Sox
  • Travel 1128 mi 2012-08-11: Rays @ (Minneapolis) Minnesota Twins
  • Travel 414.8 mi 2012-08-14: Athletics @ Kansas City (Missouri) Royals
  • Travel 564.5 mi 2012-08-16: Marlins @ (Denver) Colorado Rockies Total distance: 4560.5 mi

Remember, this isn’t the best you could do, but it’s probably close, and it was computable in a very reasonable amount of time. Interestingly, the shortest 13-game road trip is about half as long (about 2400 miles, with no leg longer than 350). Picking up those last couple of games is quite expensive. It’s been suggested that seeing a team more than once for the sake of saving several hundred miles might be acceptable – but establishing an algorithmic rule might take some time. Stay tuned for further tweaks!

Now: time to rent a car and block off a month of vacation.

Here is the final version of the code that I used for this post.


NFL records - 2011 first two weeks

The following records have been set in the first two weeks of the 2011 NFL season:

  • Most total yards passing in a game by both teams - Brady and Henne, week 1 (906)
  • Most yards passing by a rookie - Newton tied it week 1 (422) and then broke it week 2 (432)
  • Most yards passing in the first two weeks of a season - Newton (854), and then a couple hours later Brady broke it (940)
  • Most total touchdowns by all teams in the first two weeks of a season (172)
  • Most total passing yards by all teams in the first two weeks of a season (15,771)
  • Most consecutive 400+ yard passing games - Newton and Brady tied it at 2
  • Most QBs with 300+ yard passing games in one weekend - week 1 (14)
  • Longest field goal - tied by Janikowski (63 yards) week 1
  • Most penalties by both teams in a single game - Raiders vs Broncos (25)

There’s more if you count near-records. Brady’s week 1 performance of 516 passing yards was a team record and a Monday Night record, but only the fifth-best ever. And his 940 passing yards over two games was the most in the first two weeks of a season, but was five yards short of the record for any two consecutive games.

So far, a weird high-scoring season. It’ll be left to be seen if this is just a result of the shortened offseason (thanks to the lockout), or bigger strategic changes across the league.


Expected ERA

Imagine two hypothetical pitchers. Their ERAs are very close together and both pretty average: 3.40 and 3.41. They’ve both pitched just over 200 innings in 30 starts with just a couple weeks of the season remaining. But one pitcher has had some pretty advantageous matchups: he’s played the Padres four times, the Reds and Rockies twice each, the Pirates, the Mets, the Royals – all teams with records under .500. The other pitcher, on the other hand, has had a harder schedule: four games each against the Yankees and the Red Sox, two against the Rangers, and one in Detroit. Are these equivalent pitchers?

I set out to determine if pitchers we accept as “elite” are truly that great, or if some might have an unfair advantage due to schedules. I downloaded all of MLB’s gamelogs for the 2011 regular season up through yesterday, and then I parsed them, tracking a few key pieces of information. First, the number of innings each pitcher pitched against each team. Second, the average number of earned runs each team scores per inning. Then, for each pitcher, I calculated what their ERA would be if they allowed exactly their opponent’s average for each appearance. Here are the results (for pitchers who have enough innings pitched to qualify for the ERA title):

Expected ERA - after 2011-09-12

One interesting takeaway is that there aren’t any huge surprises. Of the pitchers with the ten best actual ERAs, only one of them (Cole Hamels) isn’t in the top ten for the best differential. Another interesting fact is how much a pitcher’s expected ERA is affected by simple rotation timing, and not just the team’s schedule. The Phillies have played against a lot of sub-.500 teams this year, and Cole Hamels has one of the lowest expected ERAs. But his teammate Cliff Lee hasn’t been so lucky – his expected ERA is higher than most.

But there are some people who get a nudge from good to great with this analysis. Oh, and those two hypothetical pitchers I mentioned? They aren’t hypothetical. They’re Daniel Hudson of the Diamondbacks and David Price of the Rays, respectively. This puts a little context on the fact that Price’s record is 12-12 and Hudson’s is 16-9.


Mass Brewers Fest

The following is a full list of all of the beers I tried at the second annual Mass Brewers Fest last night:

  1. 6:20 PM - Blue Hills Black Hops - ★★★★
  2. 6:24 PM - Cape Cod Beach Blonde - ★★★
  3. 6:29 PM - Haverhill Leatherlips - ★★★★
  4. 6:42 PM - Watch City Monkey Monk - ★★ - Probably the worst beer of the night. Too bad, since I like Watch City.
  5. 6:48 PM - Amherst Raspberry Wedding White - ★★★★ - Cask conditioned but really foamy. I wish I had gone back to give it another try later. It was very tart, not sweet at all.
  6. 6:52 PM - Rapscallion Blessing - ★★★★
  7. 6:58 PM - Gardner Summer's End - ★★★
  8. 7:09 PM - Clown Shoes Black Ale - ★★★★★
  9. 7:18 PM - Ipswitch Oatmeal Stout - ★★★★
  10. 7:33 PM - Harpoon UFO Pumpkin - ★★★★
  11. 8:03 PM - Notch Pils - ★★ - Both this and the Notch Saison were very mediocre beers. Wish they hadn't run out of their Session before we got there.
  12. 8:15 PM - Northampton Magic Carpet Rye - ★★★
  13. 8:23 PM - Jack's Abbey Smoke & Dagger - ★★★
  14. 8:35 PM - Samuel Adams Sample A - ★★★★
  15. 8:37 PM - Samuel Adams Sample B - ★★★ - Sam Adams was doing a contest/drawing/vote for a new flavor. Sample A was a really fantastic red: sweet, toffee-like flavor. Sample B was a black ale. Also good, but not as much personality.
  16. 8:49 PM - Blue Hills Antimatter - ★★★★
  17. 8:59 PM - Wormtown Pumpkin Ale - ★★★★★ - I had tried a taste of this earlier in the night, and was amazed. It's head and shoulders over the Harpoon UFO Pumpkin, but I'm betting I would only be able to drink about 8 ounces before I got sick of it.
  18. 9:06 PM - Frosty Knuckle Sea Spray IPA - ★★★★★ - My choice for Beer Of The Night. A very well balanced IPA. Heavy on the hops but still enough maltiness to be flavorful.
  19. 9:19 PM - Gardner Belgian Chair - ★★★
  20. 9:39 PM - Harpoon Uncle Fester - I refuse to rate this beer. Just for this event, Harpoon took a year-old keg of Oktoberfest and mixed it with a six-month-old keg of Munich Dark. The result was wild and strange and honestly tasted kinda like blue cheese.

Yes, I used Remembeer to track my beers and ratings. Also, I wore my Utica Club t-shirt to the event, and kept track of the number of comments I got. Final score: 12, about half from brewers and half from attendees.


These people are not me

The following people are not me:


Texterity FedEx Day proposal

I just started the wheels moving for a FedEx Day at work. Here’s what we wrote up for it:

We would like to propose taking a page from Atlassian's playbook and instituting a "FedEx Day". The idea is that for one day, all of the developers and QA would be free to work on a product or feature of their own choosing. The only rules would be that they have to work with someone who they don't normally work with and that the next morning they have a finished product to demo to the whole team, something that they can “ship”, ergo “FedEx Day”. This is a lightweight version of Google’s 70/20/10 policy, where the majority of an employee’s time is spent doing their traditional job, 20% on company related innovation, and 10% on anything.

People don’t stay at Texterity because of the money. We pay our developers competitively, but not lucratively (nor should we). People stay here because they like the stuff we’re working on and the people they’re working with. We haven’t lost a lot of developers, but when we do, the very competitive job market makes it a challenge to fill those positions. Jason A, Vijay, Arun, Dasheng; each of those losses has been painful in its own way. The best way that we can encourage tech workers to stay is to make them feel needed and give them purpose. The most exciting projects I’ve ever worked on were the ones where I had pretty much complete autonomy and was passionate about the end result. It’ll give all of the team members a chance to try something new and challenging and maybe even give us some outside-of-the-box features and products.

A FedEx Day would have some other benefits, too. For a day, the developers would be decision makers where they typically are not. They’d be able to see what it looks like from the product owner’s point of view. What’s a valuable feature? What’s worth spending time and testing on? How do you sell its value to management when you demo it? And there’s a good chance we’d end up with some features or products that we wouldn’t have come up with otherwise – Atlassian says they end up shipping about half of the FedEx Day projects.

We have plans for making sure that emergencies get handled and we have ideas for scheduling so that day-to-day operations are impacted as little as possible, but those discussions can come later.

If you’d like to hear more about motivation and purpose in preparation for the meeting, I suggest watching this fantastic ten minute presentation by Dan Pink:

www.youtube.com/watch

Here’s a post on Atlassian’s blog about their first FedEx Day: http://blogs.atlassian.com/rebelutionary/archives/000495.html

Here’s an article from Inc. magazine on the topic: http://www.inc.com/news/articles/2010/01/side-projects.html


The Eternal Shame of Your First Online Handle

Inspired by The Eternal Shame of Your First Online Handle, here’s my story. My first online handle was simply Pink Floyd. I was somewhat obsessed with them when I connected (via 2400 modem) to C-C-Chat, a ten-user simultaneous chat system. This was probably 1994. Within not too long, I was going by Pinky more than the full version. I bounced back and forth between Pinky and Zamboni Man on local BBSes.

When I logged into IRC for the first time in 1996 or so, “Pinky” and “Pink Floyd” and many derivatives thereof were taken on the quite busy EfNet. So to come up with a unique name, I just concatenated the first two things I came up with. And CheesePez was born. I finally stumbled upon Plutor in a fit of sleep deprivation the summer between High School and college. I think nowadays the most promising online handles aren’t words or names, but rather simply pronounceable strings of letters.

What’s yours?


Cloud confusion

I have more than 40GB of music I’ve ripped from my own CDs, purchased from a variety of locations (eMusic, Amazon, iTunes, some musicians' own websites) and in a few cases, yes, pirated. I listen to music at work, at home, in my car, and while running, and it’d be really nice to be able to take advantages of these new recently-announced cloud services (Google, Amazon, Apple) to store and access my music from anywhere. But no company is forever. IBM and HP are shells of once-invulnerable corporations. Microsoft no longer innovates – they follow. None of these companies (as large as they are right now) will necessarily be around in twenty years, and there’s no guarantee that any of their services will be around in even five.

I’ve got a limited connection, which means uploading music to Amazon or Google would take something like a week. And my Android phone and Linux work computer will almost certainly not cooperate with Apple. So what’s a guy to do? For now, I plan on continuing to do things the old fashioned way. I’m not sure what kind of cloud service would make me feel comfortable spending the time uploading all of my music, but so far, it’s not any of these.


Work laptop decision

My laptop at work is getting a bit long in the tooth and is due to be replaced in the next couple of months. I currently run Ubuntu on a Dell laptop. The laptop is elevated on a dock next to another screen. I have two choices:

Choice 1: MacBook Pro. Arguments in favor:

  • Apple makes the best laptop hardware anywhere. Period.
  • I'd be able to dual-boot to OSX, which I have nothing against, it's just not my preferred environment. I could hypothetically do things like play Steam with my OSX partition.
  • Multitouch mousepad is so nice.

Choice 2: Dell E5520. Arguments in favor:

  • The Linux support for the MacBook Pro is imperfect, especially wifi.
  • I like the way I do stuff in Linux, and if I switched to OSX (for wifi, for instance), there will be a learning curve.
  • There are docks (whereas MacBooks have some third-party stands but no real dock solution).
  • 15.6 inch widescreen, instead of 13" (which I'd have to get to keep the MacBook Pro under budget).

What are your thoughts?


Why We Watch, and NERD

While looking for a little preview on tonight’s Red Sox - Angels game (which I’ll be heading to), I happened upon these blog posts about Why We Watch baseball and a neat statistic to help find the great matchups. I read them in reverse, but here they are in chronological order:

Tonight’s pitchers are Clay Buchholz (with bad year so far and a NERD of 0) and Jared Weaver (7), both of whom were scheduled to start Sunday but were pushed back a day for (unrelated?) illnesses. Both teams have a NERD of 4, which gives the game a NERD of 4. I’m hoping that Clay pitches like he did last year, and it could turn out to be more exciting game than the stat predicts.


My Fantasy Baseball Team

I just finished my Fantasy Baseball league draft. Every time it was my turn to pick, I picked the highest remaining guy from my scientific list. (Except I didn’t pick anyone for my bench until I had a full roster.) Here’s my resulting team:

Name Position WOA
Joe Mauer C 14.69
Pablo Sandoval 1B,3B 3.47
Aaron Hill 2B 2.38
Mark Reynolds 3B 6.02
Jason Bartlett SS 1.63
Jayson Werth OF 11.03
Bobby Abreu OF 7.14
Torii Hunter OF 6.55
Rajai Davis OF 5.26
Denard Span OF 5.21
Roy Halladay SP 21.03
Felix Hernandez SP 20.46
Chris Carpenter SP 11.96
Matt Cain SP 9.95
Mat Latos SP 8.6
Ted Lilly SP 6.39
Rafael Soriano RP 5.41
Brian Fuentes RP 0.06
Adam Jones Bench (OF) 3.59
Johnny Damon Bench (OF) 2.54
Raul Ibanez Bench (OF) 2.43
Miguel Olivo Bench (C) 2.34
Marlon Byrd Bench (OF) 2.32

My co-workers think I’ll be crawling to them for offense in a few weeks, but I think they’ll be crawling to me for pitching.


Two Hundred Thousand Miles

My 2003 Nissan Altima passed 200,000 miles this morning. I bought it new on April 30, 2003. Not only was it the first new car I ever bought, but it’s survived much longer with far fewer major repairs than any other car I’ve ever owned. It needed a new axle at about 160k, and the O2 sensor is currently complaining about the catalytic converter. But that’s really it.

  • I bought it 2,865 days ago. That's an average of 69.8 miles per day.
  • I've tracked the last 50k miles on Fuelly. I've average 26 mpg, so I've used about 5.1 million 7,800 gallons of gasoline.
  • It costs me about 10 cents of gas to drive this car one mile. That's just under $7 a day.
  • The good news is I haven't spent as much on gas as I spent to buy the car. Yet.
  • The most surprising thing to me is that other than Parking By Braille, this car has never been in an accident, despite my less-than-defensive driving.

M and I are discussing buying a new car this spring. Anyone want an aged workhorse?


Cowboy Stadium vs. NASCAR

NASCAR uses about 6,000 gallons (of 110-octane E15 fuel) per race week. The United States averages 386 million gallons of gasoline per day. NASCAR runs 39 races per year (including the pre-season and All-Star races), so their usage only accounts for 0.000166% of fuel consumption in the United States (or about one out of every six-hundred-thousand gallons used).

Cowboy Stadium spends about $200,000 per month on utilities. If we assume that’s mostly electricity, that’s about 25,000 MWh, or the equivalent of an 80,000 person city.

A gallon of gas contains about 35-40 kWh of energy. So Cowboy Stadium consumes 32 times as much energy as all of the cars in NASCAR.


Fantasy Baseball Nerd Overload

This year will be the fourth season that I’ve played Fantasy Baseball. I’m a baseball fan, and I have a pretty good knowledge of the most prominent players of the game. But it’s far from encyclopedic. I have at least a couple of co-workers who can walk into draft night with no real preparation at all, and end up schooling me. What I do have, though, is an analytic mind and a desire for rigor (albeit half-assed rigor). The last couple of years, I’ve been pulling down players stats from the season before, doing a little magic, and coming up with some sort of an order. But I’ve finished in sixth place and then in seventh (out of 12).

There are some complexities in fantasy baseball that make an accurate analysis difficult. As a manager, you need to draft at least one player at each position, a couple general “hitters”, a couple starting pitchers, and a couple relief pitchers (the exact numbers vary from league to league). But there are some positions (catcher and second base in particular) that have very concentrated hitting skills. There are probably three catchers who could be considered “great” hitters. Does the scarcity increase the value of those catchers? How much?

Not all of the stats that are tracked by fantasy leagues can be considered equal. Compare, for instance, RBI and stolen bases. Just about any player that gets drafted will have a minimum of 40 RBIs, but only about half a dozen players will finish with that many stolen bases and at least half will probably have less than 10. So any specific stolen base is more likely to make the difference, since teams' numbers in that stat are more likely to be low. Is a base-stealing average-hitter worth more than a slow heavy-hitter? How much?

And every time it’s your turn to draft a player, you can choose any available player at any position. If you take one of the great catchers early, you might not get a premiere starting pitcher. How can you be sure the tradeoff you made was wise? Hitters and pitchers are scored on completely different criteria, making comparing them even harder.

So how can we possibly take this kind of system and predict how much a player is worth? At the end of the day, what you want in a head-to-head league is “wins”, so the most useful end statistic would be one that you can use to determine “If I drafted Player A instead of Player B, I’d end up with (on average) this many more wins”. After spending some abortive attempts trying to come up with an algorithm, I realized it didn’t have to be that hard. I could throw computing power at it and run a Monte Carlo simulation.

So that’s what I did. I started with someone else’s player-by-player predictions for 2011 stats (the Marcel the Monkey Forecasting System, specifically). Then I wrote a script that would simulate a ten-team league over and over. I had to simplify the rules a little bit – figuring out what to do about benching players and trades and pitcher off-days was just too much. After each simulated season, I determined how many wins over exactly average each team was, and I credited every player on that team with that many wins. Over time, good players would more likely to be on good teams than bad ones, and their averages would be high. Less-good players' averages would be low.

After two million one million (see update below) seasons, I had some pretty firm numbers, and some surprising results.

See the full results

Keep in mind the caveats: This was a ten-team five-by-five head-to-head league. The WOA column (“Wins Over Average”) is the most useful number, and it’s what the spreadsheet is sorted by. It’s scaled for a nine-week season (each team played each other team once), which obviously is not standard, but it’s directly proportional to a real 24-week season.

Multiply by 2.66, and you see that drafting Albert Pujols is worth almost 26 wins over the average player and 2.44 wins over the second-most-valuable player, Hanley Ramirez. After those first two infielders, there’s a lot of pitchers, which goes counter to a lot of the common advice out there. Which I like. Joe Mauer is the first catcher, at 27th (third round in a ten-team league).

Here’s the code and source files that I used, if you’re interested in giving it some tweaks of your own. I used the standard 5x5 stats, but you can change those pretty easily. It took about 90 minutes to run a million seasons on my not-state-of-the-art computer.

Update 11 Feb: This morning, I realized that these numbers were off, in particular those of pitchers. I had been miscalculating team ERA: just averaging all of the players together. The problem is that the true team ERA value is IP-weighted: Total team ER divided by total team IP. So it was over-valuing players with good ERA and few IP, like relief pitchers. The same was similarly true about WHIP and BA, so everyone who didn't play much was being given too much credit. I've updated the code and re-run a million seasons. There are a lot of starting pitchers rated highly now, 8 of the top 10 and thirteen of the top twenty. But actually, the top hundred players are exactly 50/50 batters and pitchers.

Update 14 Feb: I changed the spreadsheet so it includes Marcel's predicted stats for each player. This should make it easier to see why each player might be ranked where he is, plus make it easier to use on Draft Day. I updated the code linked to above, as well.

Update 22 Mar: A couple of last minute tweaks before my draft tonight. I couple weeks ago I added code to remove the "chaff" players (really, only the top couple hundred players will be drafted in a fantasy league, so I shouldn't be comparing Pujols against the 1000th-best batter). And a co-worker noticed David Ortiz missing from the list, which revealed a bug in the way I was dealing with players who play no positions. Also, I've removed hands-down first-round pitcher Adam Wainwright from the stats list.


2010 Oscars scoresheet

It’s Academy Award nomination season again – the time of year I reveal how few new movies I watch. Let’s just hope I have improved on last year’s dismal record.

Category # seen
Best Picture 1
Best Actor 0
Best Actress 0
Best Director 0
Best Screenplay 1
Best Adapted Screenplay 0

Thank goodness for Inception. If it weren’t for that, I’d have been shutout two years in a row. I want to see Toy Story 3, Black Swan, 127 Hours, The Fighter, and True Grit, which would bring my grand total up to a monstrous (for me) 17. But only the first of those is out on DVD (it’s at the top of my queue). Maybe it’s time to go to the theater. Or search for leaked screeners.


2010 in books

I tried to make a conscious effort to split my time half-and-half between fiction and non-fiction this year. I started out the year with three non-fiction books in a row, so I obviously didn’t get off to a great start. But I ended the year with 6 fiction and 9 non-fiction (if you count my still-ongoing reread of Lord of the Rings as a single book), so I don’t think I did too bad.

See also 2009, 2008, 2007, 2006, and 2005.


Perl backticks and open files

When trying to write some debugging code, I noticed something very strange. I could never get fuser to admit that its parent had a file open when called from a Perl script:

$ perl -e ‘open(F, “» /tmp/foo”) or die; fuser -a /tmp/foo;’ /tmp/foo:

But when I replaced the fuser call with a sleep, and then called fuser from a different shell, I’d get Perl’s pid, as expected. I was about to post this question to SuperUser and decided to try this just to make sure:

$ fuser . | grep -c $$ 1

Wait, what? That worked? So I asked myself: Is this something specific to Perl? Is this something about the way Perl is running child processes? If only There Was More Than One Way To Do It. Oh wait, there is.

$ perl -e ‘open(F, “» /tmp/foo”) or die; system(“fuser -a /tmp/foo”);’ /tmp/foo: 3733

I haven’t been able to find documentation about what exactly backticks do with open filehandles that makes fuser report the wrong information, but system() clearly doesn’t do it. I just thought I’d document it here for the next person who is trying to do the same thing.


Patriots late game problems

Yesterday, the Patriots went into halftime with a 14-10 lead. They didn’t score once in the second half, and went home on the wrong side of a 14-28 game. I said at the time that it reminded me a lot of last year. I pulled up some numbers to be sure. (The following stats are for all of 2009 and 2010, including both regular and post-season games. That’s a total of 19 games.)

  • In regulation over that period, we were 11-7-1. The one "tie" went into overtime and the Broncos won on a field goal. (Don't get me started on sudden death overtime.)
  • If the games had ended after one half, we would have been 14-3-2 over that period. If they'd ended after three quarters, we'd have been 14-5-0.
  • Our total point differential has been 154 points in the first half, and -28 in the second half.
  • The point differentials have been 38 in the first quarter, 116 (!!) in the second, 3 points in the third, and -31 in the fourth quarter.

Maybe we can lobby the league to switch to a 45-minute clock when they go to a 20-week/18-game schedule?


The Red Sox haven't been bad

Since April 19, the Yankees are 71-47, Rays are 72-47, and the Red Sox are 70-48. It’s not that the Sox have been bad. In fact, in 2009 between games 13 and 131 they were 70-48, and in 2008 they were 69-49. They have been just as good as in previous years. The problem is that the team fell to a quick deficit and has been trying to catch two other extremely good teams. There’s a good chance the AL East will finish the year with two teams with 100+ wins, and Boston with 90+ wins. I’m almost certain this hasn’t happened as long as there have been divisions (1969). The closest I can find is 1977, when the top three teams in the AL East finished with 100, 97, and 97 wins respectively. But remember, that was a six-team division, not four.

To look at this season and draw the conclusion that we’ve had a bad year is to ignore the actual facts. We just haven’t had as good of a year as we needed to have in order to make up our losses in the first couple of weeks.


StarCraft 2 review

I’ve now played StarCraft 2 for two days. I’ve finished five missions on the single-player campaign, and played a handful of co-op multiplayer games. If you had asked me to describe the game based on the Beta, I would have said it was just StarCraft HD. Higher resolution, more beautiful, some new tech, but the gameplay is identical. The single player campaign, though, is where this game really shines. The original StarCraft’s single player was essentially a series of levels that got steadily harder and had some story connecting them. The sequel turns makes the stages non-linear, introduces credits as reward for some stages that you can then use to hire mercenary units when you’re in a bind for near-instant help or spend on research to improve units, and secondary objectives in some missions allow you to earn alien research points you can use to improve buildings. The original game only had ten Terran missions, and I’m willing to bet there are triple that in this game. Plus there are probably seven hundred achievements.

The multiplayer is fun, but you kinda need to be a semi-professional to do well at it. As Splatta said the other day, that seems too much like work.


Diamond Age review

I wrote about the failings of The Diamond Age in a message to my brother a week ago. Now that I have actually finished the book, I can say that my problems with it are still valid. First, the good: I don’t think there’s anyone better than Neal Stephenson when it comes to creating a believable universe around a technologically advanced future. In both this and Snow Crash, his world is fully realized and–more importantly–socially complex.

But The Diamond Age clearly is affected by Stephenson’s ongoing scatterbraineditis in a way that Snow Crash was able to avoid. It’s actually a pretty clear progression from the great plot of Zodiac through to the spaghetti nonsense of Cryponomicon. He creates this nanotech-infused world, introduces us to a few characters and gets us to love them and root for them. Hackworth vanishes from the storyline, then Miranda, then Nell seems to be the central character. Then she disappears when Hackworth reappears and now we’re supposed to care about Fiona for a chapter or two. Then Carl Hollywood becomes a central character. And what ever happened to Dr. X? What’s up with the Fists? Oh, here comes the Mouse Army seemingly from nowhere (or more accurately 200 pages ago). The conflict that supposedly gets resolved doesn’t even begin to appear until three-quarters of the way through the book. And now that I think about it, I’m not sure what the conflict was or even if it was resolved.

I really wanted to love this one, especially since I liked the world so much more than the virtual reality world of Snow Crash. But at least in that book, there was more or less a single conflict, clear protagonists (one was even helpfully named Protagonist). When Stephenson writes sprawling epics, he forgets to put in a direction for the story to go.