Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Metrics for quantifying gerrymandering

PyPI version

This repository contains:

  1. Python code for implementing a number of metrics for quantifying gerrymandering9:
    • Mean-median difference and variant:
      • Mean-median difference1,2
      • Equal vote weight2
    • Lopsided margins (two-sample t-test on win margins)1
    • Bootstrap (Monte Carlo) simulation1
    • Mann-Whitney U test
    • Declination variants3
      • Declination
      • Declination (buffered)
      • Declination variant
      • Declination variant (buffered)
    • Efficiency gap variants
      • Efficiency gap4
      • Difference gap5,6,7
      • Loss gap7
      • Surplus gap8
      • Vote-centric gap6,7
      • Vote-centric gap 26,7
      • Tau gap3
    • Partisan bias6,7
  2. Historical election results:
    • Congressional elections, 1948–2016 (CSV)
    • State legislative elections (lower house), 1971–2017 (CSV, full repository)
  3. Jupyter notebook demonstrating how to run the tests on all elections, as well as reporting the percentile ranking for all tests of any particular election.


If using pip, do pip install gerrymetrics


  1. Samuel S.-H. Wang. (2016). Three Tests for Practical Evaluation of Partisan Gerrymandering. Stanford Law Review.
  2. Michael D. McDonald and Robin E. Best. (2015). Unfair Partisan Gerrymanders in Politics and Law: A Diagnostic Applied to Six Cases. Election Law Journal.
  3. Gregory S. Warrington. (2018). Quantifying Gerrymandering Using the Vote Distribution. Election Law Journal.
  4. Eric McGhee. (2014). Measuring Partisan Bias in Single‐Member District Electoral Systems. Legislative Studies Quarterly.
  5. Whitford v. Gill, No. 15-cv-421, F. Supp. 3d. (2016). Griesbach, dissenting, 128.
  6. Benjamin P. Cover. (2018). Quantifying Partisan Gerrymandering: An Evaluation of the Efficiency Gap Proposal. Stanford Law Review.
  7. John F. Nagle. (2017). How Competitive Should a Fair Single Member Districting Plan Be? Election Law Journal.
  8. Wendy K. Tam Cho. (2018). Measuring Partisan Fairness: How Well Does the Efficiency Gap Guard Against Sophisticated as well as Simple-Minded Modes of Partisan Discrimination? University of Pennsylvania Law Review.
  9. Gregory S. Warrington. (2018). A Comparison of Gerrymandering Metrics. arXiv.


Lots of metrics for quantifying gerrymandering.





No releases published


No packages published