The following piece is part of the Quest’s new series featuring final projects of Minerva students. This piece was written for Minerva’s Modeling, Simulation and Decision Making course, as well as Minerva’s Constructing Theories of Good Government course, by Rory Foulger, Minerva Class of 2019.  To view more final projects, click here. If you are a Minerva student and would like to have your final project published,  fill out this form

All code for this final project is available here.

Executive Summary

Gerrymandering, the practice of redrawing district boundaries in an area in order to distribute voters in a way which benefits a specific party, is a much discussed issue in the United States. In the US, district lines must be redrawn after every census, so once every ten years. In most states, the party in charge at the time gets to choose where those lines go. This has a huge impact on the results of any election, and is especially important in presidential elections.

One of the biggest problems in this space is that, although gerrymandering on racial grounds and violation of the One Person, One Vote rule has been ruled unconstitutional, no redistricting plan has been rejected by the Supreme Court. This is because they do not have a reliable method of finding if a district has been gerrymandered.

Gerrymandering is a highly quantifiable problem. In the 2012 election, despite the fact that the Democrats earned 1.17 million more votes than the Republicans (50.59% of the two party vote), they only received 46% of the seats in the House. The Democrats lost out on approximately 18 seats in 2012, which would have given them a House majority. Despite the fact that the country had voted for a Democrat House, Senate and President, they ended up with a Republican House (‘112th United States Congress’, 2018).

In 2016, Republicans gained as many as 22 additional House seats over what would have been expected given the popular vote. For the first time since 2005, the Republican party has a majority in both the House and the Senate, and they have the largest Republican majority since 1929 (‘114th United States Congress’, 2018).

In this essay, I will explain and demonstrate the concept and impact of gerrymandering on the outcome of an election, and how we can detect gerrymandering in a districted map.

There are two key stakeholders in this. First, the Supreme Court, which has to make judgements on districted maps if they are questioned. The Supreme Court needs to have a reliable test and metric in order to decide if a map has been subject to partisan gerrymandering. Second, the general public. In a democracy, it is important that the people’s will is reflected in their leaders.

My policy recommendations will be to the Supreme Court.

  • Use scientific methodologies in order to decide if a state has been gerrymandered 
  • Decide on thresholds for judging if a state has been gerrymandered 
  • Follow through on the 1986 Davis v. Bandemer ruling that gerrymandering is justiciable,
    and expand that definition beyond the size of the population and the districting of racial
  • Encourage states to use non-partisan, independent agents to draw district maps

How Does Gerrymandering Work?

Gerrymandering works by ‘cracking and packing’ the opposition party’s voters. Let’s look at a simple example.

The most obviously fair way of splitting the area is vertically, as in the first districted map. This means that 60% of districts vote for purple, and 40% vote for green, which is the same as the distribution of the general population’s votes.

However, if we are the purple party, and we want to maximise our districting, so that we get more seats in congress, we might want to draw the district lines horizontally, as in the second districted map. This ensures that we win in every district, so instead of getting 60% of the votes, we get 100%.

On the other hand, if we are the green party, we want to try to win the election, even though we only have 40% of the votes. If we’re in charge of drawing the districts, then we can do some creative redistricting in the third districted map, in order to pack purple voters into a small number of districts (2 districts have only purple voters), and then crack the remaining voters into green dominant districts, making it impossible for purple to win in those districts. The goal is not to try and minimise the number of purple voters in each district, but rather to waste their votes by packing them all into sure win districts. By cracking and packing, we have successfully won the election for a party with just 40% of the votes, just by changing the borders.

By using the basic principles of cracking and packing, the people doing the redistricting are able to have significant influence on an election result.

The Impact of Gerrymandering

Apart from the obvious impact of essentially rigging part of an election, there are other consequences of gerrymandering, the most important ones of which are loss of societal trust and less inclusive governance. Societal trust is vital for the continued integrity of a democratic system. In order for people to willingly give governments the legitimacy they need in order to function, they have to trust that the government is acting in the people’s best interests. People’s level of involvement with the government, with democratic processes, and even the level to which they obey the law, depends to some degree on their belief that the system is fair.

Even if gerrymandering is not occurring (and no one has proved that it is to the degree needed for the Supreme Court to make a ruling yet), the public believes it is. And even just the appearance of the government trying to ‘play’ its citizens can be taken very badly. This could result in a serious lack of engagement in democratic process on a large scale, a dramatic reduction in the level of trust we have in government, and a less inclusive government, due to the public not taking the agency to contribute to decision making.

The social contract works based on the idea that the system is fair, and that politicians are at least aiming to be working for the benefit of their constituents. If they are actually manipulating voters so that they are more likely to be able to continue to be in media spotlights or powerful positions, then we cannot trust that they will make any decision with the people in mind. If they got into government by manipulating votes, how can we trust that they will be able to make good decisions for us? If the politicians do not have the mandate and trust of the people, how are they supposed to govern at all?

Alongside this lack of societal trust, the government also becomes less inclusive. If the districts are being gerrymandered, then potentially millions of people are not being given a voice in the outcome of the election. This is not only important in presidential elections, where the people need to elect their representatives for the good of the country, but also for local and statewide elections. In order for people to be able to trust in, and be included by, the government at any level, representatives need to be representative of the will of the people. In a severely gerrymandered map, this is not possible.

Having any majority in the House allows one party to pass laws and enact policies. If the majority is in seats but not population, then these laws are going into effect without the mandate of the people. For example, in Michigan in 2012, despite the Democrats receiving 50.4% of the popular vote, the Republicans received 57% of the seats. This allowed the Republican party to advance a very conservative agenda, including forbidding contracts which require workers to pay union dues, higher taxes on pensions, lower taxes on corporations and a large spending cut. This policy was passed, despite not getting a single Democrat supporter, and having many of the Republican seats vote against.

On the other side, Vermont’s 1998 House of Representatives was majority Democrat due to a large efficiency gap, and they succeeded in passing a same-sex civil union bill with just 51% of the Representative votes. This was the first same-sex civil union bill in the USA. When the Republicans took back the House, they were not able to repeal the law.

Both of these examples show that once a law has been made or a policy enacted, it is very difficult to reverse it. So it is vital that the representatives are genuinely representative of the popular vote, and even more vital that representatives are not advantaged by fiddling with the maps.

Has This Map Been Gerrymandered? The Math.

In order for a district map to be fair, it should be geographically compact, and should not break up natural communities.

There are several metrics we can use in order to work out if a district map is fair, and I will discuss three key tools: the efficiency gap, actual vs expected seats, and compactness. The most important of tools is the efficiency gap. The efficiency gap finds the difference between the votes which each party wasted. In the example below, team purple’s wasted votes are all of the votes for purple (P) in a district where green (G) won, or a vote for purple in a district where purple got over 50% of the votes.

In other words, wasted votes are all of the excess votes (the number of votes for the winner – ½ the population of the district), and all of the votes which did not lead to a win for that team. Below, we can see three differently districted maps, with their associated efficiency scores.

An efficiency gap of 0 means that the two parties both wasted an equal number of votes. The higher the efficiency gap, the less fair the separation is. In this example, we can see that Map 3 has a very low efficiency gap, which tells us that neither party has an unfair advantage. In Map 2, which has an efficiency gap of 12, we can see that the green party has an advantage, because very few of their votes are wasted – they have no voters in the district where purple won, and they secured narrow victories in the other districts. This gives green a significant advantage over purple, and results in them getting 75% of the available power, when they only had 47% of the popular vote. This is calculated using the following pseudocode.

if b wins:

   wasted votes for b = total votes for b - population of district/2
   wasted votes for a = total votes for a

if a wins:

   wasted votes for a = total votes for a - population of district/2
   wasted votes for b = total votes for b

Efficiency gap = difference between wasted votes for A and wasted votes for 
B / total population

The second important test of gerrymandering is looking at the expected number of seats vs the actual number of seats won. We would expect the purple party to win 60% of the seats if they have 60% of the votes. If they actually win 40% of the seats, or 80%, then we can suspect that gerrymandering has occurred.

expected a wins  = (number of votes a / district population) × number of nodes in district

Third, we can look at the compactness of each district (to see if it has a congruent shape), as in the ‘Compact Division’ diagram to the right. The diagram demonstrates three ways (Polsby-Popper, Reock and Area/Convex Hull) in which we can calculate the compactness of a district using North Carolina’s District 12, one of the most gerrymandered districts in the USA.

Other methods of analysing real state maps include taking the districted map and changing it a tiny bit, over and over again. If the slightly changed districts dramatically change the result of the election, then it is likely that the map has been gerrymandered.

By coming up with metrics and formulas to quantify the level of gerrymandering in a state, we can begin to produce guidelines and be able to decide if a map which has been drawn is fair. The Supreme Court has not yet accepted a specific method for making this decision, but are currently debating using the efficiency gap.

My Model

In order to think deeply about this topic, I created a model to simulate districting and voting in a simple map. In my simulation, there are two parties, A and B.

I started with a 10×10 node map. Within each node, I generated a number of votes for party A, and a number of votes for party B. Both numbers are randomly generated, and can be between 100 and 1000. These two numbers sum to make the population of the node. If the population is greater than 1750, then the node is labelled as an urban area, and the number of votes for party A gets increased by 10%.

On the un-districted graph, you can see the party each node voted for (A or B).


The next step is to organise the nodes into districts. We choose a random node and look at its population. We also look at all the other nodes which are connected to our random node and look at their populations. We then select the neighbour with the most similar population to our node, and merge the two nodes into one district. Then we choose another 

random node and follow the same process. We continue until there are ten distinct districts in the map. Choosing to make the districts based on their population was based on the idea that ‘rural’, or low population nodes should be together with other  ‘rural’ nodes, and nodes with higher populations should also be together with each other.

To the right, we can see an example of a districted node map. The urban nodes have a black outline. Each colour represents a different district, and the letter on the node is the party which the whole district voted for.

There are a couple of issues with my districting function. First, it does not ensure geographic integrity. You can see on the map that one of the dark purple nodes at the bottom is separated from all of the other purple nodes. This would not usually be allowed to happen in the real world. It is not guaranteed that the districts have a similar population size. This is also a vastly simplified map. There are no geographic issues like rivers, mountains or city boundaries. There is no consideration of race or other demographic (which might be an explanation for results that look like gerrymandering in the real world – if everyone in an area is white, middle class, and 18-25, that area is very likely to vote Democrat, no matter where you draw the boundaries).

Analysing the Model

I ran this simulation 1000 times, and stored the number of times that party A would have won without districting, and how many times party A won given the districted model.

Over the course of 1000 trials, party A won 60% of the time by popular vote, but only 47% of the time using the districting map generated for that instance of the simulation. That means that party A didn’t get a majority in the House even half of the time when we used the districting model.

But, as we’ve already discovered, this is not the only metric to find if the district map has been gerrymandered. In order to work this out, we should analyse the model further and find measures like the efficiency gap and the difference between the expected wins and the actual wins for each party.

This graph shows the average efficiency gap in the model over the course of 1000 simulations. We find that this method of districting results in quite large efficiency gaps. This means that this is not necessarily a fair method of districting the map.

We can also look at the difference between actual and expected districts won. In the graph above, each bar represents one map, or one instance of the simulation. Negative values indicate that there were fewer districts won by party A than would be expected by their popular vote, whereas positive values indicate that party A won more seats than would be expected given their popular vote.

From this, we can calculate the number of districts which would have to change their votes in order for the result to be representative of the popular vote. On average, when party A was underrepresented in the map, they lost out on 6 seats, and when party A was overrepresented, they gained 8 seats. Overall, on average, in order for the districted maps to lead to the same result as the population vote, party B would have to win three more seats in each map.

Recommendations for the Supreme Court

In order to limit gerrymandering in the USA, the Supreme Court needs to decide on clear rules and metrics which inform us if a state has broken those rules. It has already been ruled unconstitutional to district a map based on race, or to fail to uphold 1 person 1 vote, but we should go a step further and declare that partisan redistricting is also a violation of voters’ rights.

When a case is brought to the Supreme Court, I recommend that experts in mathematical modeling are consulted, and that several tests are carried out on the offending map.

  1. The district should be tested for compactness and congruency
  2. The efficiency gap should be calculated
  3. The expected vs actual outcomes, and the net difference between the two, should be calculated

  4. The individuals who drew the boundaries should be questioned on their intentions and justifications for the map

The Supreme Court should endorse specific models, metrics and thresholds which will count as evidence in court.

Recommendations for States

The best way to avoid gerrymandering is to have the district boundries drawn by a non-partisan, independent body. Alaska, Arizona, California, Idaho, Montana, and Washington are currently the only states which employ an independent commission, and they have found that this has reduced the efficiency gap compared to when the lines were drawn by the politicians.


In conclusion, gerrymandering is a significant threat to the running of a democratic country. There are several ways to find out if a map has been gerrymandered, and they all compliment each other. The Supreme Court needs to decide on a threshold for saying with enough certainty that a state has been gerrymandered, so that they can throw out unfair maps before elections, and limit the damage that a party can do during a term without the public mandate.