Date of Completion


Degree Type

Honors Thesis


Mathematics (MATH)

First Advisor

Robert Rovetti


In electoral politics, gerrymandering is the phenomenon of creating electoral district partitionings that are often not geographically compact for the unfair benefit of one political party over another. Researchers have proposed several methods to quantify compactness, but identifying gerrymandering using these measures is an open problem. We analyze the possible distributions of compactness scores by exploring “Squaretopia,” a square n x n grid that we must partition into n equally-sized contiguous districts that each contain n cells. However, even in this simplified model, the number of possible partitions of a Squaretopia of size n = 9 exceeds 700 trillion, rendering the generation of all possible partitions a computationally expensive task and leading us to consider sampling. We develop Partitioner, a recursive algorithm written in the Java programming language, to randomly generate samples of 10,000 partitions by choosing an unoccupied cell and then randomly adding contiguous neighbor cells until the district contains n cells—a process that is repeated until the grid is completely partitioned. The first version of this algorithm produced samples that overrepresented high compactness scores; we reduced this bias by adding a weighting factor to the district-creation process to increase the probability that Partitioner generates straighter districts, thus shifting the compactness score distribution as expected. The optimal weighting factor minimizes the difference between the populations and their samples for the Reock and Length-Width scores. Using these weightings, we generate samples of larger Squaretopias and demonstrate how we can detect likely gerrymandering by statistically identifying unreasonably small compactness scores.