Class GerrymanderingDetector

java.lang.Object
org.episteme.social.politics.GerrymanderingDetector

public final class GerrymanderingDetector extends Object
Provides algorithms to detect gerrymandering and partisan bias in electoral district maps. Includes implementations for Efficiency Gap, Mean-Median Difference, and Declination.
Since:
1.0
Version:
1.1
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • analyze

      Performs a multi-metric analysis of a set of districts to detect partisan bias.
      Parameters:
      districts - the list of districts in the map
      Returns:
      a detailed analysis result
    • polsbyPopperCompactness

      public static double polsbyPopperCompactness(List<double[]> polygon)
      Calculates geometric compactness using the Polsby-Popper method. PP = 4π × Area / Perimeter²
      Parameters:
      polygon - list of vertices
      Returns:
      compactness ratio between 0 and 1
    • seatsVotesCurve

      public static Map<Double,Double> seatsVotesCurve(List<GerrymanderingDetector.District> districts, int points)
      Simulates a seats-votes curve to visualize partisan lean.
      Parameters:
      districts - base districts
      points - number of points on the curve
      Returns:
      map of total vote share to resulting seat share