# The closeness of the 2015 Alberta election

Posted in civics on Thursday, May 07 2015

I was thinking, while I drove home today, about how close so many of the ridings seemed, and whether or not voter turn out was correlated to how contested a riding was. Are the uncontested ridings because nobody really showed up, say only the WRP supporters cared enough to vote in a given riding and so they won, but the total number of voters was super low. It seemed that the NDP had a lot of close races, was that just because they were winning a lot more seats, or was life actually harder for them?

These questions can be answered with data. And yes, I do love python so much that I more or less make excuses to fire up an ipython notebook and noodle around.

I want to know how close the ridings were, so I just count the number of votes difference between the winner and the runner up, I also take the time to store who the winner was and the total number of votes in the riding. Below are the first few rows of the election results table.

2 AFP LIB AP SC CP-A GPA NDP PC WRP IND total close win
ED Name
DUNVEGAN-CENTRAL PEACE-NOTLEY 0 0 0 0 0 0 3694 2756 3143 0 9593 551 NDP
LESSER SLAVE LAKE 0 0 0 0 0 0 3908 1950 3196 0 9054 712 NDP
CALGARY-ACADIA 0 764 0 0 0 0 5503 4604 4981 0 15852 522 NDP
CALGARY-BOW 0 683 466 0 0 447 5680 5417 3753 0 16446 263 NDP
CALGARY-BUFFALO 0 3274 0 0 0 263 4671 3740 1354 0 13302 931 NDP

The closest riding was Calgary-Glenmore which was tied NDP/PC as of the time I wrote this

AFP          0
LIB       1344
AP         718
SC           0
CP-A         0
GPA          0
NDP       7015
PC        7015
WRP       5058
IND          0
total    21150
close        0
win         PC
Name: CALGARY-GLENMORE, dtype: object


The furthest riding was Rachel Notley, she trounced everyone in her riding

AFP          0
LIB        659
AP           0
SC           0
CP-A         0
GPA          0
NDP      13597
PC        2242
WRP          0
IND          0
total    16498
close    11355
win        NDP
Name: EDMONTON-STRATHCONA, dtype: object


I have theory that there is a correlation between how many people showed up and how close the riding was. If nobody showed up I expect it was an easy victory, people who would have voted against the winner gave up in a cloud of pessimism and apathy.

My theory is probably wrong, there is no real correlation here. Two things pop out, though:

1. The total number of votes cast appears normally distributed , which makes some sense
2. The "closeness" of the races is not at all normal. In fact it looks like most races were pretty close.

I can plot a histogram of general closeness and find that about a third of ridings had less than 1000 votes between the winner and the next runner up. On average, the total number of votes cast in a riding was 17066, so a third of ridings had less than a 6% difference between the leader and next runner up.

I am not a politically learned person so I have no idea how that compares to the usual, but it seems like a pretty small difference to me.

My other theory was that the NDP had a harder fight, so ridings where the NDP won should have higher "closeness" than ones where the WRP won. So I expect a histogram for the NDP to peak at a lower value of "closeness" than the WRP.

To answer that I can divide up the data based on who won and plot a violin plot.

A swing and a miss again. It looks like all three major parties fought mostly tight races, with the NDP having a fatter tail than the PCs or WRP. In fact if you were to pick an easily won riding at random, odds are it was won by the NDP.