Class GerrymanderingDetector
java.lang.Object
org.episteme.social.politics.GerrymanderingDetector
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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordData model for an individual electoral district.static final recordComprehensive analysis result for a full district map. -
Method Summary
Modifier and TypeMethodDescriptionanalyze(List<GerrymanderingDetector.District> districts) Performs a multi-metric analysis of a set of districts to detect partisan bias.static doublepolsbyPopperCompactness(List<double[]> polygon) Calculates geometric compactness using the Polsby-Popper method.seatsVotesCurve(List<GerrymanderingDetector.District> districts, int points) Simulates a seats-votes curve to visualize partisan lean.
-
Method Details
-
analyze
public static GerrymanderingDetector.GerrymanderAnalysis analyze(List<GerrymanderingDetector.District> districts) 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
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 districtspoints- number of points on the curve- Returns:
- map of total vote share to resulting seat share
-