Thursday, August 16, 2012

Checking in on Tim Lincecum

A month ago I wrote an article looking at changes in San Francisco Giants' starting pitcher Tim Lincecum's pitch command and velocity this season.  In particular, I found that the velocity on his fastball and slider had decreased by about a mile per hour, and that the average distance of his pitches from the edge of the strikezone had increased--assuming that, generally, pitches near the edge of the strikezone are better than those in the middle or nowhere near it.

Since the all-star break, though, Lincecum's ERA, at least, has been a respectable 3.66.  Have his command and speed improved as well?

It turns out that his speed is the same as earlier this year, with a fastball averaging around 90.4 mph, and about a mile per hour slower than last year.  So, no improvement on that front.

His average distance from the edge of the strikezone, on the other hand, has gotten a bit better--it's been at .940*, as compared to .923 last year and .961 for the first half of 2012**.

So, long story short, there are some signs that his pitching might be picking up but nothing conclusive.

By the way, I'll be announcing results from the second contest and introducing the third one in the next day or two.

The value for the second half of this year is only statistically significantly different from the value from last year, and from the value for the first half of this year, at the p= .30 level--so the jury's out on this one.

Monday, August 13, 2012

Checking in on the Giants' lineup

Earlier a wrote a few posts on what the SF Giants' optimal starting lineup should be using Basim, a baseball simulator I wrote.  A lot has changed since then, though--Posey has become much better, Blanco and Pagan have cooled off, and Hunter Pence and Marco Scutaro have joined the club.  So, what should the Giants' lineup look like now?  What lineup do I hope they start tonight?

First off, here was my guess at their best lineup (once again assumin Zito is the pitcher):

1.  Buster Posey
2.  Brandon Belt
3. Melky Cabrera
4. Pablo Sandoval
5. Hunter Pence
6. Marco Scutaro
7. Angel Pagan
8. Brandon Crawford
9. Barry Zito

Running this lineup through the simulator*, it scored an average of 4.03 runs per game.

I then found that a random lineup (i.e. random ordering of the nine players) scored about 3.89 runs per game.  The lineups that the simulator liked the best generally had Posey, Belt, Cabrera, or Pence batting leadoff, which is unsurprising--each has either a high OBP or a high ground into double play rate that would be very painful in the heart of the order.  The single lineup that the simulator liked best** was the following:

1. Buster Posey
2. Angel Pagan
3. Hunter Pence
4. Brandon Belt
5. Melky Cabrera
6. Marco Scutaro
7. Pablo Sandoval
8. Brandon Crawford
9. Barry Zito

It scored an average of about 4.035 runs per game***.

I then looked at two lineups that were close to what I predict the Giants will run; they differ only in whether the Giants play Theriot or Crawford; the lineup Pagan, Scutaro, Cabrera, Posey Sandoval, Pence, Belt Theriot, Zito scored an average of 3.96 runs per game, while the same lineup but with Crawford batting for Theriot scored 4.00 runs per game on average.  So, it seems like about half the difference between my lineup and the one with Theriot just comes fromt the fact that Craword is better than Theriot.

Anyway, here's to hoping the Giants will do something smart.

*: For Pence and Scutaro I used their pre-Giants numbers.

**: This should be taken with a grain of salt--to actually find the best would take days of simulation; treat this as a lineup that is pretty close to the best.

***: FWIW, the ten best starting lineups, according to the simulatr (with the same caveat as **), in the form (lineup, average runs scored by lineup per game): [(['Buster Posey', 'Melky Cabrera', 'Brandon Belt', 'Marco Scutaro', 'Hunter Pence', 'Pablo Sandoval', 'Angel Pagan', 'Brandon Crawford', 'Barry Zito'], 4.0152400000000004), (['Brandon Belt', 'Buster Posey', 'Pablo Sandoval', 'Melky Cabrera', 'Hunter Pence', 'Angel Pagan', 'Brandon Crawford', 'Barry Zito', 'Marco Scutaro'], 4.0168675), (['Melky Cabrera', 'Buster Posey', 'Brandon Belt', 'Marco Scutaro', 'Pablo Sandoval', 'Brandon Crawford', 'Angel Pagan', 'Hunter Pence', 'Barry Zito'], 4.0179150000000003), (['Brandon Belt', 'Buster Posey', 'Pablo Sandoval', 'Melky Cabrera', 'Hunter Pence', 'Brandon Crawford', 'Angel Pagan', 'Marco Scutaro', 'Barry Zito'], 4.0218325000000004), (['Melky Cabrera', 'Brandon Belt', 'Marco Scutaro', 'Pablo Sandoval', 'Angel Pagan', 'Hunter Pence', 'Buster Posey', 'Brandon Crawford', 'Barry Zito'], 4.0219899999999997), (['Hunter Pence', 'Marco Scutaro', 'Buster Posey', 'Pablo Sandoval', 'Brandon Belt', 'Melky Cabrera', 'Angel Pagan', 'Brandon Crawford', 'Barry Zito'], 4.0253224999999997), (['Brandon Belt', 'Hunter Pence', 'Pablo Sandoval', 'Angel Pagan', 'Melky Cabrera', 'Brandon Crawford', 'Marco Scutaro', 'Buster Posey', 'Barry Zito'], 4.0315525000000001), (['Hunter Pence', 'Angel Pagan', 'Brandon Belt', 'Melky Cabrera', 'Buster Posey', 'Pablo Sandoval', 'Marco Scutaro', 'Brandon Crawford', 'Barry Zito'], 4.0322525000000002), (['Marco Scutaro', 'Pablo Sandoval', 'Brandon Belt', 'Melky Cabrera', 'Buster Posey', 'Hunter Pence', 'Brandon Crawford', 'Angel Pagan', 'Barry Zito'], 4.0353874999999997), (['Buster Posey', 'Angel Pagan', 'Hunter Pence', 'Brandon Belt', 'Melky Cabrera', 'Marco Scutaro', 'Pablo Sandoval', 'Brandon Crawford', 'Barry Zito'], 4.0365225000000002)]

Second contest ends tonight (Monday night)

Last week I announced the second contest, to solve this intimidating puzzle:

Details are at the first link.  So far no one has fully solved it, so send in your partial solutions--they'll probably make it to the top three.

The contest ends tonight (Monday night) at 11:59 pm.  I'll announce the third contest sometime Tuesday.

Friday, August 10, 2012

Swing Vote!

Hey everyone. Sam made a post a couple weeks ago analyzing votes (and money) for congressional elections. This is a post about analyzing votes for US Presidential elections. This is the result of a 2am conversation-calculation with Sam and a mutual friend Gary Wang. Also, we base a lot of intermediate steps in the result comes from the website FiveThirtyEight.

The question we're going to try to answer is the following. You are Joe Smith from Iowa (or, insert your favorite state here), who decides to stay home on November 6, election day. What's the probability you wake up the next morning, open up Google News, and feel really stupid? Or more succinctly, what's the probability that a single vote in Iowa will make the difference in November?

Thursday, August 9, 2012

Traditionball: the most unenlightened area of baseball strategy

About ten years ago, baseball started to undergo a statistical revolution: youth became valued, OPS was born, and walks finally became valued.  Fast forward a decade and OPS is now a mainstream stat, multiple sites are constructing competing ways to summarize the total value of a player, and even in baseball clubhouses sabermetrics are the new cool kid on the block.

But there are still a few areas of baseball strategy stuck in the dark ages of gut instincts and wild speculation, and chief among them is use of pitchers.

Right now it baseball there are three types of pitchers: starters, relievers, and closers.  Starters come in to pitch the start of the game, stay in for at least five innings, and are eventually taken out.  They pitch every five days.  Closers come in in the ninth inning with a lead of between one and three runs.  They never pitch more than an inning, and never come in otherwise.  Middle relievers pitch in between starters and closers.

These roles bear an uncanny resemblance to two of the stupidest pitching statistics, wins and saves.

This system is, of course, not close to optimal.  Frequent pitching changes at the beginning of the game would allow a manager to get better matchups, keep pitchers fresher from stopping them from having to throw too many pitches in one day, and allow pitchers to throw however many pitches is best for them--not a bimodal distribution with centers at fifteen and one hundred.

It would also give an NL team another advantage--they could always pinch hit for their pitchers (or at least as long as it wasn't a two out, none on situation).

I'll look at the first effects in a later post, but for now, how much would always pinch hitting help?

Well, first I found the number of runs scored by an average NL lineup from 2011 using Basim; it was 3.799.

Then, I substituted the average substitute player for the league in for the ninth spot in the lineup; Basim then simulated it and found an average of 4.006 runs per game.

That's roughly a 3.2 win difference right there--the difference between a .500 team and a .520 team.

It's true, of course, that implementing such a system could incite a revolt from pitchers--but it seems like there is too much to be gained for it to be worth ignoring as a manager.

Tuesday, August 7, 2012

Utilitarianism, part 6: To do, or not to do

This is the sixth post in a series about utilitarianism.  For an introduction, see the first post.  For a look at total vs. average utilitarianism, see here.  For a discussion of act vs. rule, hedonistic vs two level, and classical vs. negative utilitarianism, see here.  For a response to the utility monster and repugnant conclusion, see here.  And for a look at whether to count lives not yet in being, see here.

Also, note that I'm now putting page breaks in the middle of my posts so that you can see more than one on the front page...


I'm going to start off by making a note about something slightly different from the content of this post.  Earlier, I defined a philosophy as a preference ordering on all possible universes; the ordering had to be transitive, reflexive, etc.  Basically, a philosophy is something that compares any two possible universes;  in other words, it tells you which options are the best (if you have complete information, that is).  Perhaps for you a philosophy is something different.  Maybe it's something that compares some situations but doesn't say anything about other comparisons.  Maybe it's a binary function that calls all actions either morally permissable or impermissable.  Maybe it is a framwork to look at actions that doesn't necssarily tell you which are best, but instead some other difficult to define properties of them.  Probabily it's a mechanism to justify your current way of life.  Anyway, if you don't think a philosophy should be a preference ordering on possible universes, there's probably very little I can do to convince you, just as if you think faith is more important than evidence or that gut instincts are more important that statistics in baseball there's probably little I can do to convince you.  But from now on I am using that definition, and will look critically upon philosophies that fail to create a preference ordering.

Act and Omission

Anyway, there is a large debate in philosophy about whether taking an action should be treated asymetrically from failing to take an action--the act/omission distinction.  There are many phrasings of the problem, but here is one of the more famous ones: the trolley problem.  The trolley problem is a thought experiment in which you, the actor, are near some trolley tracks.  The tracks split, and past the split there are currently five people tied to one of the tracks, and three tied to the other.  You're standing next to the lever which controls which path the trolley takes; in the first version of the problem the lever is currently such that three people will do, and in the second version of the problem the lever is currently such that the trolley will run over and kill the five people.  A trolley is coming.  You have time to pull the lever, if you want, but not to untie any of the people.  In the first version it's pretty clear you don't pull the lever--not only are you causing the death of five people, but you're only saving three by doing it.  But how about the seond version?  Do you pull the lever and switch the trolley, kiling three other people, or not do anything and let the first five people die?  That is, do you act, or not?  And should morality treat the omission of action, which results in two extra deaths, the same way it would the action of killing two people?  In other words, are these two scenarios the same?  Does it matter which way the lever is currently pointing?

Contest Number Two: Two Degrees of Separation

Last week I introduced the contest of the week: each week I will propose a contest, and award Shadow-points to the winners; every two months the person with the most Shadow-points (in the period) will geet their name posted on the side of the blog, a $2 reward, and the chance to write any article they want for the blog.  The results of the first week's contest are here.


I'm going to try to alternate types of contests, so this week's will be a little bit different from last week's.  This week, the contest is a word puzzle of sorts.  The first person to solve it will get first place, second person second place, etc.

Without further ado, here's the puzzle:

Two Degress of Separation*

Results from the First Contest

A week ago I proposed a contest for readers to construct the best possible lineup from the 2002 Giants roster; the rules are here and here.  The winner of the contest gets 3 Shadow-points; second place gets 2; and third place gets 1.  In addition everyone whose entry beats my own entry gets an additional Shadow-point.  Every two months the person with the most Shadow points gets their name on in the Shadow Hall of Fame, $2, and the ability to write any one article for the blog.


Today, I'm announcing the winnners of the contest.  The average submission scored somewhere around 4.9 runs per game, and the best scored above 5.  I have more comments to make, but without further ado, the three winners:

Monday, August 6, 2012

Last Chance for Contest

A week ago, I introduced a contest to design the best lineup from the 2002 Giants roster; details are here and here.  Submissions for the contest are due tonight, so if you want  to participate but haven't given me a lineup, either post it as a comment here or email it to me by 11:59 tonight.

I'll announce the results of the contests sometime tomorrow.

Also, I've run some more simulations with Basim on the 2000-2011 season; it looks like the correlation between RAA* and runs scored by a team is .963; without very many simulations (20,000 per player) the correlation between eWAA and runs scored is .952, but that number should go up with more simulations as the noise goes down (due to limited computing power it's taking a while to get a fuller result).

Also, if anyone has a suggestion for what I should write on (baseball, philosophy, or anything else), let me know.


RAA, runs above average, is the baseline offensive stat used to construct WAR; I'm using a modified version that removes ballpark advantage, etc. to do an apples-to-apples comparison.

Friday, August 3, 2012

Examining eWAA: The Fifteen Best Players of the Decade

A while ago I wrote a python program, Basim, that simulates baseball games, and used to construct a statistic for the offensive output of a player: eWAA.  Also, check the bottom of the post for a few notes on the contest of the week.


I've run a Basim simulation on all player-years from 2000-2011, inclusive, and used it to calculate the eWAA (empirical wins above average) for all player-seasons; think of this as the number of extra wins a team would be expected to get in the season if they replaced an average player with the given player.  Below, I've listed something close to the best 15 player-seasons in the 2000-2011 period.  I say "something close to" because, due to lack of available computer power, I haven't run enough simulations to get a stable result; so, the numbers below should be taken with a standard deviation due to limited simulations of something like 0.33 eWAA.  (Once I've run enough simulations I'll do a more in-depth look at eWAA, including its predictive power.)  For fun, I also put the spot in the batting order that Basim thought they should hit that year*.

Best Spot
Barry Bonds
Barry Bonds
Barry Bonds
Todd Helton
Sammy Sosa
Barry Bonds
Luis Gonzalez
Alex Rodriguez
Albert Pujols
Todd Helton
Albert Pujols
Todd Helton
Jose Bautista
Albert Pujols
Jason Giambi

I then computed the best total eWAA throughout the period (summed over the years 2000-2011); if you want, the best offensive players (again, with roughly a 2.5% error) of the decade:

Albert Pujols
Barry Bonds
Alex Rodriguez
Todd Helton
Lance Berkman
Manny Ramirez
Chipper Jones
Bobby Abreu
Vladimir Guerrero
Jim Thome
Jason Giambi
Carlos Beltran
Miguel Cabrera
Brian Giles
Gary Sheffield

My initial reactions:

1) Bonds was, in fact, really good.  Not only did he have the best seasons by far, but he has the second highest total eWAA despite retiring halfway through the period.

2) Pujols, unsurprisingly, is the man of the decade; he's been an mvp-level player for most of the years.

3) Coors field is really friendly.  (Also, Helton is really good.)

4) Berkman, Abreu, Thome, Beltran, and Giles are really underrated.


A few notes on the contest of the week (a contest to create the best lineup you can from the 2002 Giants roster; see here for details).

1) For fun, I'm going to create a lineup submission of my own; it won't be in the contest, but in addition to the normal Shadow-point payout, I'm giving one extra Shadow-point to everyone who submits a lineup that does better than mine.

2) To clarity, the numbers I'll be drawing the stats from are the ones listed here; they are the players stats from their time on the Giants in 2002.

3) So far there are 12 entries, all of which are unique.

4) I'm not going to show my lineup until I run the results, but as a teaser I'll say that there's one thing I think a lot of people are forgetting to think about.

Anyway, good luck in the contest; submissions are open until this coming Monday, August 6th at 11:59 pm.

*: I suspect that right now Basim is biasing too much toward having good hitters hit first and bad hitters hit last when calculating eWAA; I'll change that soon.

Thursday, August 2, 2012

The Fetishization of the Old

In about eighty years I will be dead, and in another eighty everyone who ever really knew me will be too.  I will be at risk of being forgotten; everyone alive now will be, but most importantly for me, I will be.  I would like to think that I will be remembered.  We all would.


-Beatrice (F) and Benedick (M) and fiances; so are Hero (F) and Claudio (M).  The men are best friends, as are the women.  Claudio believes Hero is cheating on him and breaks of their engagement.  Beatrice tells Benedick, in retaliation for casting shame upon Hero, to kill Claudio.  Benedick eventually relents, and agrees to murder his best friend.
-Stradivarious string instruments are instruments made by Antonio Stradivari.
-"A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed."

The objects referenced above share three similarities.  

The first is that they're really old.  The first, a summary of a key plot point in William Shakespeare's Much Ado About Nothing, was written sometime in the late sixteenth century.  The second, the most famous string instruments ever made, were constructed sometime around 1700.  And the third, the second amendment to the constitution of the United States of America, was adopted on December 15th, 1791.

The second commonality is that they are revered.  Shakespeare is widely considered to be the best author ever to have lived.  His works are required reading at almost every level of school, the subject of quite a lot of academic research, and the focal point of many theater festivals around the world.  Stradivarius violins sell for a few million dollars each, and cellos an order of magnitude above that--both an order of magnitude above the cost of other professional-level instruments.  The constitution has become the focal point for almost every public policy debate in Washington, by far the most ubiquitously cited source, and it was the interpretation of the constitution that rested at the heart of the recent supreme court case on Obamacare.  The second amendment itself has determined the balance of gun control laws in America, has been used to limit local attempts to ban certain guns and to determine which attempts to limit access to guns are allowed.

The third thing that these three old, revered works share in common is that they are ridiculous.  The plot twist  in Much Ado--typical of Shakespeare--relies on simultaneously one-dimensional and unrealistic characters, illogical plots, and obvious endings.  I mean, come on--kill someone because he thinks, with good reason, that his fiance is cheating on him?  Beatrice is absurdly out of line in an unrealistic way; Benedick is absurd for listening to her, and this is all supposed to be taken in stride.  Professional violinists don't show preferences for Stradivarius violins in double blind tests versus newer instruments.  And we as a country should be able to decide what the best gun control laws are and enact them democratically, instead of listening to vaguely worded commands about gun laws from people who lived two hundred years ago when we were in open rebellion against a foreign occupier and didn't yet have a reliable police force or army.  Instead of making decisions about what laws make sense in a country with internal security, a police force, and an army, we have to constantly make sure that "A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed."  Whatever the fuck that means.  All of Shakespeare's plays are like that, too, and the problem with the constitution is more general than the second amendment.

I could go on and on about the failings of Shakespeare and the constitution and Stradivarius violins, and at the bottom of this post I do*, but really I shouldn't need to: the Bayesian priors are pretty damning.  About half of the people born since 1600 have been born in the past 100 years, but it gets much worse than that.  When Shakespeare wrote almost all of Europeans were busy farming, and very few people attended university; few people were even literate--probably as low as about ten million people.  By contrast there are now upwards of a billion literate people in the Western sphere.  What are the odds that the greatest writer would have been born in 1564?  The Bayesian priors aren't very favorable.

And take a look at string instrument creation.  Not only does current society have much more expendable income and energy to devote to things like creating instruments, but we now have machines capable of cutting wood with micrometer level precision available to consumers; what are the odds, really, that the best violins have been made by a human hand in 1700?

The problem is much more systemic than plays and violins and laws.  Citizen Kane was finally unseated as the best film of all time and bumped to number two--still quite an achievement for an almost unwatchably empty film.  Old wines sell for ridiculous prices despite the lack of correlation between price and taste.  (See here for recently disgraced Jonah Leherer's attempts to salvage expensive win.)  The framers of the constitution are easily the most revered people in America and--importantly--those most often looked to for advice on public policy--despite being, you know, people with slaves who wouldn't understand a thing about the modern economy or technology or society.  I spent a fair chunk of my childhood trying to decide who the best ten baseball players ever were--how does Gehrig compare to Bonds?--even though any of the players from 1920 would flunk if forced to play against modern teams.  Again and again in our culture, the same theme pops up: we fetishize the old.

We like old plays and old movies and old wines and old instruments and old laws and old people and old records and old music.  We like them because they're old and come with stories but we convince ourselves that there's more: we convince ourselves that they really were better.  We don't just read stories about the framing of the constitution at bedtime, we use it as our guide for public policy.  We don't just like to listen to the Beatles but we convince ourselves that they are the best and that anyone who doesn't like them doesn't have good taste in music.  We don't just respect the old; we think that the old is right and that those who prefer the new to the old are wrong.

So why is it that we have become so enamored of things made in 1700?

There are many reasons.  One is that there is a whole lot of inertia in the system.  If Shakespeare is the most respected thing in 1900 then teachers will teach it in 1900 and academics will write about it in 1900 and if you're young in 1900 and want to be "in the know" and want to become an insider in academic literature, then, well, you'd better study Shakespeare; and so it's passed on from generation to generation.  Furthermore, once something acquires a label, it's very hard to dislodge the label--even if the label is as the best author ever and there are more and more authors every day giving the old one a run for its money (and then some).  I think there's one more reason, though, that we fetishize the old.  I was reminded of it about a month ago while in a taxicab heading toward the Atlanta airport, and I saw a billboard advertisement for a Church that said, superimposed on the pastor's face: "In these troubled times, some things never change."

In about eighty years I will be dead, and in another eighty everyone who ever really knew me will be too.  I will be at risk of being forgotten; everyone alive now will be, but most importantly for me, I will be.  I would like to think that I will be remembered.  We all would.  And if we as a society spend so much time looking backward, so much time romanticizing those who died two hundred years ago, so much time replicating traditions born hundreds of years ago, then the future doesn't look quite so divorced from the present.  And the thought that your society and your town and your way of life and maybe even you might be remembered in two hundred years doesn't seem quite so hopeless.

It's easy to get caught up in romanticization of the past and forget that it's the reason that 46% of Americans don't believe in evolution.

This is not, of course, to say that Shakespeare should be banned.  Everyone should be entitled to read what they want.  But our laws should not be based on two hundred year old unchangeable documents, and schools shouldn't base their curriculum around analyzing Shakespeare; and next time you want to go see Citizen Kane playing in your local artsy movie theater, I think I'll pass.


*: The recent ruling on Obamacare rested on the personalities of two judges--John Roberts and Tony Kennedy.  The reason that such an important case rested on personality instead of law or fact is because the vagueness of the constitution gives the justices free reign to rule as they wish.  Obamacare was originally believed to be extremely unlikely to be overturned, and then underwent a series of transitions in terms of likelihood of being overturned, peaking at almost 80% on Intrade, before being upheld.  And during this time, the constitution did not change; only one of the bumps even came from legal arguments in front of the court.  Instead a year of speculation over the personal opinions of John Roberts and Tony Kennedy occurred.  The constitution not only sets arbitrary and vaguely worded rules from a time when the nation was very different that are now almost impossible to change, but also allows people to judge the legality as they wish on almost any issue--even if they're a judge tasked with deciding whether a law will be upheld.  But, you say, wouldn't we become a police state devoid of free speech if we lost constitutional protections?  Look at the UK, whose constitution's main role is to establish a now-figurehead monarchy.  Look at almost any comparable country--it's not going to rely as much on their constitution as we do on ours.  If we want free speech--which we absolutely do--then let's have a law saying so.

Similarly, Shakespeare's non-comedies fix few of the flaws found in Much Ado About Nothing.  Romeo and Juliet are incredibly flimsy characters, and the plot is absurd.  (For those interested, the number of lines between when Romeo is first made aware of Juliet's existence and when he recites his first love sonnet about her is 32, and none of those involve any action on Juliet's part, let alone interaction between them.)  Sure, you could say that the play is attempting to highlight the immaturity of youth, but at that point you're attempting to cite the one-dimensionalness of the main characters of a work as a strength.

And Shakespeare isn't alone in being a shitty writer from hundreds of years ago.  The most ambitions woman in Pride and Prejudice has a life goal of marrying a rich, handsome man who is also intelligent--the thought that a woman could have a career or even hobby independent from her husband is outside the scope of the book.  And don't get me started on The Canterbury Tales.