samedi 12 novembre 2016

How tweaking the voting system would have impacted the 2016 election

The United States' system to elect the president seems to be quite unusual, and quite subject to debate, as this year the president winning the election did not win the popular vote.

Here I'll focus on a few of this system's characteristics, and how changing some of them would have impacted the results of the 2016 presidential election.

The point of this post is not to evaluate whether the system is good or not, not to advocate alternate voting systems, and not to promote any particular candidate.  It's just a boring analysis of numbers.

A few probably unique characteristics of the US voting system to elect the president are:
  • Voting for electors: A citizen does not vote directly for the president/vice-president ticket.  Instead, the citizen votes for an elector, a member of the United States electoral college, who has pledged to vote for that president/vice-president ticket.  Cases of electors not voting for the expected candidate are extremely rare.  Some states legally bind the electors to vote for their given party.
  • Electoral college vote distribution: Each state has a number of electoral college votes, which are distributed partially based on population, as positions in Congress are apportioned: a total of 538 votes are distributed.  First, 102 votes are distributed evenly to each state plus the District of Columbia (2 per state/DC), and the remaining 436 votes are distributed to the 50 states plus DC, based on population. 
  • Winner-take-all: Finally, most states (all except for Maine and Nebraska) have a winner-take-all system.  The candidate who wins the largest portion of the popular vote in a given state receives all of the electoral college votes of that state.
After seeing the results of the 2016 elections, with conflicting outcomes between the popular vote and the current system, and witnessing discussions about alternate voting systems, I was curious to see how changing any of these characteristics would have impacted the election.  My goal was to complete this table:




Elector loyalty Congressional apportionment of votes Winner-take-all Winner?
Current system: Trump 306 vs Clinton 232
Popular vote: Clinton 47.7% vs Trump 47.4%
?
?
?

I used the data reported on politico for my analysis. As of the writing of this post, politico is reporting 290 electoral votes for Trump and 228 for Clinton, with New Hampshire (4, Clinton) and Michigan (16, Trump) as not finalized yet.  I consider these counts final just to simplify my analysis, hence the result of 306 to 232 in favor of Trump just above.

Elector loyalty

What if the electors weren't bound to vote for their party?  They will vote on December 19, so there is still time to find out!  In order to change the election outcome (to not guarantee a Trump presidency), 36 Republican electors would have to not vote for Trump in December.  That's 11.7% of the Republican electors. Is it likely or even possible?  I'm not in a gambling mood right now.  We'll see.

Apportionment of votes

What if we kept elector loyalty and the winner-take-all system, but distributed votes based purely on population?  Specifically, what if 436 votes were apportioned to the 50 states plus DC based on population?

To find the answer, I wrote a Python script to extract the data from politico in HTML format and to save it to an Excel file.  I calculated the following and saved my analysis for this blog into a new file.
  • Determined the number of "population-based electoral votes" for each state simply by subtracting 2 from the "total electoral votes" for each state.
  • Assigned all the "population-based electoral votes" to the candidate who got the highest percentage of the popular vote, in each state.
  • Tallied the "population-based electoral votes" for each candidate.
The result is: out of 436 total votes, Trump would receive 245 votes, and Clinton would receive 191.  No third party candidate would receive any electoral votes in this scenario.  Trump still wins in this scenario, but by a wider or narrower margin?

In this scenario, Trump is ahead by 54 votes, compared to the real scenario, where he is ahead by 74 votes (306 - 232).  But, since there are fewer votes to distribute, we can't compare the two gaps directly.  We can compare percentage of electoral college votes:
  • Congressional apportionment: 306/538 vs 232/538 is: Trump 56.9%, Clinton 43.1%
  • Population-based distribution: 245/436 vs 191/436 is: Trump 56.2%, Clinton 43.8%
Using a population-based distribution of votes instead of a congressional distribution of votes would have almost no impact on the result of this election.

Winner-take-all

What if we kept elector loyalty and the congressional apportionment of votes, but abolished the winner-take-all system?  How would the electoral votes for a given state be distributed, based on the popular vote?

This turned out to be a tricky question.  In Maine and Nebraska, in the current system, each district has one electoral vote, and that vote goes to the candidate winning the popular vote in the district.  The remaining 2 votes for each state are given to the state-wide winner.  Nebraska, for example, has a total of 5 votes: 3 votes apportioned to 3 districts based on population, plus 2 other votes. If Nebraska has a candidate A win one district, and B win the two other districts, the likely outcome will be 1 vote for A and 4 votes for B.

I didn't have data for each district for the 50 states, so I couldn't do an analysis on this method on a nation-wide level.  Maybe I'll do a follow-up if I can obtain this data at some point... maybe not...

So how do you go about distributing votes in one state if you don't have data per district?  We can attempt to divvy up our allocated electoral college votes to the candidates based on their popular vote share. Let's take one state as an example: California.



D. Trump H. Clinton G. Johnson J. Stein Other Total
Votes 3,021,095 5,589,936 288,310 155,706 38,880 9,093,927
Percent votes 33.22% 61.47% 3.17% 1.71% 0.43% 100.00%
Electoral votes 18.3 33.8 1.7 0.9 0.2 55
Electoral votes (rounded) 18 34 2 1 0 55

In California, we see an interesting distribution with a couple of third parties getting some electoral votes.

However, in West Virginia, we have a rounding problem:



D. Trump H. Clinton G. Johnson J. Stein Other Total
Votes 486,198 187,457 22,798 8,000 3,773 708,226
Percent votes 68.65% 26.47% 3.22% 1.13% 0.53% 100.00%
Electoral votes 3.4 1.3 0.2 0.1 0.0 5
Electoral votes (rounded) 3 1 0 0 0 4

After rounding the fractional electoral votes each candidate should receive based on his share of the popular vote, we see that we've only allocated 4 of the 5 electoral votes for the state.  What do we do with the last vote?  I couldn't find a solution for this that would grant whole votes to candidates, with a nice formula in my Excel file.  So, I decided to just not round.  In this scenario, we assume that the electors are loyal anyway, so we don't really need them to be humans.  We can just replace them with "points", which can be fractional.

In this scenario, the results are quite different from the real-life scenario.  Here are the fractional electoral college votes allocated to the candidates:




D. Trump H. Clinton G. Johnson J. Stein Other Total
Electoral votes 253.4 257.0 18.0 5.5 4.1 538.0
Percent electoral votes 47.1% 47.8% 3.3% 1.0% 0.8% 100.0%
Percent popular vote 47.4% 47.7% 3.3% 1.0% 0.6% 100.0%


Without the winner-take-all system, Clinton is ahead by 3.6 votes, with 27.6 electoral votes being allocated to third parties.  The share of electoral votes is nearly identical to the share of the popular vote.  Any difference between the percent electoral votes and the percent popular vote is due to the congressional apportionment of votes, which we saw earlier, seems to behave about the same as a distribution based only on population.

The Excel file containing these calculation experiments can be downloaded here.

 

Conclusion

I'm finally able to fill out my table:


Elector loyalty Congressional apportionment of votes Winner-take-all Winner?
Current system: Trump 306 vs Clinton 232
Popular vote: Clinton 47.7% vs Trump 47.4%
Let's see in December
Trump 245 vs Clinton 191
Clinton 257 vs Trump 253.4

The attribute of our current system which appears most responsible for the difference between the popular vote and the election result is the winner-take-all rule.  The allocation of votes based only partly on population behaves closely enough to a distribution based only on population.

While I'm happy to have some answers, I don't believe I can conclude that if we had a system without winner-take-all, that the result would have actually been a 257-253 win for Clinton.  Voters' behaviors may change if we eliminated this part of our voting system, perhaps being more willing to vote for third-party candidates.

mardi 12 avril 2016

Lettre ouverte au Sénateur Hervé Maurey (sur le port obligatoire du casque)

Le sénateur Hervé Maurey a introduit une proposition de loi pour rendre le port du casque obligatoire pour tout le monde.
Le texte de la proposition de loi : http://www.senat.fr/dossier-legislatif/ppl15-288.html

Bonjour Monsieur le Sénateur,

Pour me présenter : Je suis cycliste.  Je fais environ 70km par semaine pour me rendre au travail, et j'ai fait plusieurs milliers de kilomètres de voyages de cyclotourisme en France et ailleurs: Dunkerque-Hendaye, Paris-Bordeaux, Brest-Mont Saint Michel, Paris-Londres, Angers-Nantes...

Des études [1] ont montré qu'augmenter le nombre de cyclistes est la meilleure façon de réduire les accidents.  Vous pouvez prendre Amsterdam comme exemple. 

Lors de mes trajets et voyages en vélo, parfois je porte un casque, mais souvent je n'en porte pas, car c'est une contrainte. Mais la décision, bonne ou mauvaise, m'appartient.  Je m'identifie comme "pro-choix" : je crois au "droit de la femme de disposer de son propre corps", mais pas seulement pour les femmes, et pas seulement pour l'avortement : le droit des femmes et hommes de prendre les décisions concernant leur santé, leur nutrition, et leur corps.  Pour que chacun soit le maître de son propre corps.

Je serai très déçue et frustrée si l'état décide de prendre une approche "autoritaire" pour tenter (très probablement sans succès selon les informations et études qu'on a) de réduire le nombre d'accidents des cyclistes.  Ne punissions pas les cyclistes.  Laissons nos policiers se concentrer sur des problèmes et infractions plus urgents plutôt que de passer leur temps à donner des amendes aux cyclistes. 

Encourageons le cyclisme, ainsi augmentant le nombre de cyclistes et donc améliorant leur sécurité !

Merci de votre temps,
Carmen ALVAREZ



[1] Une étude en particulier mentionnée dans des articles traitant de la proposition de loi du Sénateur : http://www.cbc.ca/news/canada/british-columbia/bike-helmet-laws-have-little-effect-reducing-head-injuries-says-ubc-study-1.3308238

vendredi 7 août 2015

Republican presidential candidate debate speaking times - August 6, 2015

A couple of years ago, when meetings at work were dragging on, I created an Android app to track the time each team member was speaking: Scrum Chatter.  In a nutshell, "Scrum" is a buzzword name of an approach to manage software projects, and part of this approach involves having a status meeting every day with all the team members.  I'm not an agile buzzword expert ("agile" itself is a buzzword), but I declare that if this definition is technically incorrect in any way, it doesn't matter squat for the purpose of this post.  I'm just giving some context here for the non-technical audience.

These daily status meetings should last around fifteen minutes, but at that period, sometimes they would last 20 or 30 minutes, with team members treating the simple status meeting as a forum to describe in great detail the technical or other challenges they were facing.  I developed this app to objectively determine, in a fun way, who were the worst offenders of verbosity.

Note that the Scrum Chatter app does not do automatic speech detection, and requires manually tapping on play/stop buttons when team members speak.

Today, I applied the app to a slightly different use case: tracking the time spoken by each of the candidates on the Fox News Republican presidential candidate debate on August 6.

The results, in minutes per candidate, are:
Donald Trump: 10:20
Jeb Bush: 08:34
John Kasich: 06:40
Ben Carson: 06:39
Mike Huckabee: 06:36
Ted Cruz: 06:34
Marco Rubio: 06:17
Chris Christie: 06:00
Scott Walker: 05:46
Rand Paul: 05:04

I like charts, so here's the same information in a pretty visual format:
The caricatures in this image come from user DonkeyHotey on Flickr: https://flic.kr/p/wT4RqN , licensed under Creative Commons BY-SA.

Unfortunately the Scrum Chatter app does not generate these pretty graphs.  It does export the data to Excel format, which allows manually creating pretty graphs in your spreadsheet application of choice.  Implementing graph generation directly from the app has been on my "TODO" list for over two years.  Yeah, I don't think I'm ever really going "TODO" it.  However, since this enhancement request was the first enhancement request I ever received on any of my personal projects on GitHub, I keep it open for nostalgia.


This is how the debate looks like a meeting, inside the app:



When I look at this screen shot, I wonder what it would be like to work on a scrum software project with developers like Jeb Bush.  How harsh would Chris Christie be in his code reviews? What kind of crazy comments would Donald Trump slip in the code?  I'll bet Ben Carson could implement some excellent optimizations.

This is what happens when I write a blog post at 3:30 in the morning.

Returning back to the purpose of this post: As in the 2012 Republican primary debates, which I followed on my blog here, we see a speaking disparity here, with Donald Trump getting over twice as much time as Rand Paul to talk.

If I'm motivated, perhaps I'll watch the subsequent debates and track the progression of the speaking duration per candidate, over time.

vendredi 15 mai 2015

La Loire à vélo : Day 5 : Clisson to Nantes

Today we recruited a couple of friends from Clisson to join us in the last leg of our bike tour, a 30km ride from Clisson to Nantes. It was nice to be cycling in a small group for a change.

We saw a flying saucer on the road, at La Haie-Fouassière. Technically, though, it was a parked saucer, not a flying saucer. The driver of this saucer looks like an Earthling astronaut though, and he is holding a cookie typical of the region. Several interpretations are possible, one of which is "this is your tax euros at work".

Nantes is in the Loire-Atlantique department, in the Pays de la Loire region, but there are references to Bretagne (the neighboring region) everywhere: souvenirs, restaurants, building and tramway stop names, signs in Breton... After the ten minutes I've just spent trying to inform myself on this matter, I can say that the separation (or possible future reunification rather) of Loire-Atlantique from Bretagne has been a subject of debate for decades. In 1956, Loire-Atlantique was separated administratively from Bretagne, even though historically they were associated for hundreds of years. In recent months, the French government has been "redesigning" the organization of the regions in France. Apparently the people in Bretagne and Loire-Atlantique were mostly in favor of reunification, but it looks like it won't happen after all. To understand why is left as an exercise for the reader. 

For dinner, we wandered about the streets of Nantes, hesitating between all the choices of restaurants. Finally we saw a sign that said "No bullshit, just burgers." If this restaurant is targeting American tourists  they are doing a good job, because that is where we ate. 

Below is a photo I forgot to include from the castle in Yseron: an extremely friendly and adorable dog greeted us and couldn't get enough of our affection.

Tomorrow we'll bid farewell to the Loire and say hello again to the Seine. 








jeudi 14 mai 2015

La Loire à vélo: Day 4: Yseron to Clisson

Today we only cycled 14 km from Yseron to Clisson. This is the path: https://connect.garmin.com/modern/activity/774541246

Before heading out on the road, we had a little chat with the owner of the castle we stayed at. He detected a "slight accent" and asked where we were from. I'm used to hearing this, but this time he said that Benoit also had an accent. I guess he's been hanging around me too long :-) The castle owner mentioned that he used to work in California, on the high speed train project. Maybe one day it will become a reality :-)

We expected heavy rains, but fortunately only had a few drops. We spent the day visiting with some friends: playing board games and geocaching.  We found 10 geocaches today, which is the most we've ever found in one day. Geocaching is definitely easier with a  four person team than with just two people.




mercredi 13 mai 2015

La Loire à vélo : Day 3: Ancenis to Yseron

Today we probably cycled the least out of all the days on this tour so far, but it was the most tiring day. We said goodbye to the Loire river (for now) and headed south. We stopped to visit a zoo at La Boissière du Doré, where we spent the whole afternoon. Then we cycled over to Yseron, near Vallet, where we are spending the night in a castle. The roads were hilly, and there was a bit of traffic, but the weather was perfect. The path we took is here: https://connect.garmin.com/modern/activity/773588675

For dinner, we walked about 4 or 5 km to a pizzeria in Vallet, the closest city with restaurants. We found two geocaches on the route to the restaurant.

Tomorrow should be a nice and easy day: less than 15 km of riding planned,though the weather calls for rain!






mardi 12 mai 2015

La Loire à vélo : Day 2 : Saint Germain des Prés to Ancenis

Today we cycled from Saint Germain des Prés to Ancenis, stopping at Saint-Florent-le-Vieil. We had a delicious roasted chicken for lunch. I keep forgetting to take pictures of the food...

At Saint Florent, we tried to find a few Geocaches. If you don't know about Geocaching, it's a game in which people hide small boxes in miscellaneous public places, and publish the coordinates of the hidden boxes on a website. Geocachers try to find these boxes, and sign their names in tiny logbooks which are inside the boxes.

We only found one of the three we attempted. Yesterday, at Montjean, we also attempted to find a couple of Geocaches. We found both, but one of them was too high to reach to open to sign the logbook. We nevertheless marked it as "found" on the website, only to immediately receive a message from the owner of that cache saying we needed to mark it as "not found" since we didn't sign the logbook. Some people take this hobby way too seriously. On a previous trip to Amboise, we ran into a group of Geocachers who were in "speed"  mode, trying to find as many caches as possible, as quickly as possible, comparing their records (how many total caches found) with us.


There's not much else to say about today's trip: the weather was a bit cooler, but still pretty sunny. Tomorrow, we'll leave the Loire river and head south to Vallet. There is a zoo along the way: maybe we will visit it.