Saturday, September 28, 2013

Population Density compared to Partisan Lean

 So a website called "the atlantic cities" has a very interesting article about how the closer you live with your neighbors, the more left-leaning you're likely to be, and vice versa. What really raises my ire about their article, however, is the absolutely terrible plot they made published, which is a scatter-plot of congressional districts. Someone just spat the data out into Excel and went with the first image they could make. They did change the y-axis to a logarithmic scale, but they didn't change the fit to to match it! Here's my (much better) plot with the same data (or more accurate? their sources are slightly unclear).

 As you can see (because I literally spelled it out at the bottom), there's a significant correlation between population density and partisan lean. Every time you double the population density, the district is about 8.6 points more democratic. I made a similar histogram-type plot of the districts, sorting them into bins by density and reporting the average partisan lean of all congressional districts with similar densities (circle size is related to how many districts that circle represents).

As you can see, most districts are clustered between 100 and 10,000 people per square mile. If you examine the two trendlines I've drawn, the blue one represents how we should expect to find the districts, and the red one shows how it actually bends significantly. This demonstrates the level of gerrymandering that republicans have accomplished, maximizing the number of districts that are republican, even if just slightly, while shoving all democrats in their states into a few districts that are heavily democratic. This is how Republicans currently control the House of Representatives, despite receiving several million fewer votes in the House than Democrats received. 

(For more on the current Gerrymandered state of many districts, try this fun jigsaw-style quiz! It shows very well how ridiculously these districts' shapes have been contorted to skew the makeup of the House so much)

Saturday, January 5, 2013

Matt's probability question

A quick post since I don't have access right now to my beautiful plotting software.

My friend Matt asks a question: if I have 12 cards labelled 1-12, and each day I draw 3 without replacement, record which ones I've drawn, and then shuffle them back in for the next day, how many days should I expect to draw cards before I have drawn all 12?

Instead of doing actual math, I just used MATLAB and ran one million simulations (a nice round number). First I'll plot the probability of having drawn all 12 cards by day X

You can see that we cross 50% somewhere between day 11 and 12. Specifically, 46.4% of simulations were done by day 11, and 57.1% were done by day 12; Interpolating gives about 11.3. Even though I'm too lazy to do stat math for you, we can see the form of the equation if we plot the probability to not be done yet versus number of days (below). In a semilog (y) plot, it forms a straight line after about day 10.