The election will surely be a landslide for the Democrats with this crucial endorsement!
But seriously, I’ve been behind Obama since the primaries. My decision is based on his keen intellect, technological prowess, and inspirational charisma (and you know, the fact that I’m a Democrat). I often wonder how anyone in my field can even support McCain, who can barely use a computer, versus the young, ambitious, and intellectual spirit of most programmers that is embodied in Barack Obama.
I normally wouldn’t discuss politics on my website and have continually shaken off the urge to do so recently, but the fast yet seemingly endless approach of the presidential election has gotten me so excited that I’ve turned into a political junkie over the past few months. Every morning, I scour the web for hot political news; every evening, I’m fixed to MSNBC’s line-up; and every waking hour, I’m watching for new poll data. It’s gotten so bad, that I’m starting to do programs and spreadsheets with election data.
Friday, I randomly decided to start crunching numbers on the differences in spread between the 2004 election and 2008 election predictions. I grabbed the predictions with a Regex on Pollster.com‘s fine poll trend data and the results from the Federal Election Commission for 2004 and mashed them together in Excel to get the spreads. Then, I got the crazy idea of seeing the data visually. So from there, I made a VB.Net script to take the data and decide what color to make a state (with the typical Blue equals more Democratic and Red equals more Republican) by adjusting hue, saturation, and luminance. Unfortunately, the linear hue equation made the map mostly purple, which didn’t convey the key point that the country is turning Democratic this cycle. So I switched to a logarithmic hue equation that would keep the purples towards the very center. For any interested, here’s the code I used to find the colors. (Where “x” is positive for more Democratic and negative for more Republican.)
Dim MaxDemHue As Integer = 147 'hue when input is MaxShift in the democratic direction Dim MaxRepHue As Integer = 255 'hue when input is MaxShift in the republican direction Dim MaxSat As Integer = 255 'saturation when input is MaxShift Dim MinSat As Integer = 160 'saturation when input is 0 Dim MaxLum As Integer = 92 'luminance when input is MaxShift Dim MinLum As Integer = 207 'luminance when input is 0 Dim CenterHue As Integer = ((MaxRepHue - MaxDemHue) / 2) + MaxDemHue 'hue when input is 0 Dim MaxShift As Integer = 40 'the max spread in either direction Dim HueShift As Double = ((MaxShift * 0.262) * Math.Log(Math.Abs(x))) + 3.9138 If HueShift > 0 Then HueShift = 0 'possible that it could go negative with log hsl.H = CenterHue - (Math.Sign(x) * HueShift) hsl.S = ((Math.Abs(x) / MaxShift) * (MaxSat - MinSat)) + MinSat hsl.L = ((Math.Abs(x) / MaxShift) * (MaxLum - MinLum)) + MinLum
Initially, I manually put the state colors into an image. This proved to be a bit time-consuming, so I moved to a vector art format called SVG that, because it’s merely XML, can be changed programmatically. With each state shape having a unique ID, I can just XPath to it in code and Regex change the color. Now the results.
Looking at the map, it seems quite clear that indeed the majority of the country is trending Democratic this year. Most of the states are 5 to 10% more for Obama than they were for Kerry. There are some notable exceptions, though. The northeastern states are surprisingly not much more Democratic (or even more Republican in the case of Massachusetts and Rhode Island); I’m guessing this is because they already turned out very strongly for Kerry last election. Similar to Mass. is Arizona, where McCain has the home-team advantage. That leaves Tennessee and Arkansas as the only other states not trending more Democratic, which may be explained by racial factors and population demographics.
Just for the hell of it, I also plugged the raw prediction data into my script to produce a map with a bit more information than the standard electoral ones you see floating around.
I’ve worked on the new version of Cursor Lock recently and a release is eminent (hope I didn’t say that last time I mentioned Cursor Lock). A new installer is already made and all the known bugs are fixed, so there’s just the matter of documentation left. If I can peel myself away from the polls, I’ll hopefully have the new release done before November 4th.