Issue #20: bimodal winner distributions, 3-2-1, partisan primaries, Score/STAR ranges#50
Open
endolith wants to merge 2 commits into
Open
Issue #20: bimodal winner distributions, 3-2-1, partisan primaries, Score/STAR ranges#50endolith wants to merge 2 commits into
endolith wants to merge 2 commits into
Conversation
…ries - bimodal_electorate() for two spatial clusters; partisan primary/runoff helpers - three_two_one() with Good/OK/Bad ballots; honest_321_ratings() strategy - honest_normed_scores(max_score, *, min_score) with tied-utility rows at min - Examples: bimodal winner histograms (turnout variants), Score vs STAR ranges, bimodal approval strategy comparison - Tests for bimodal electorate, 3-2-1, and invalid tiebreakers Co-authored-by: endolith <endolith@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #50 +/- ##
==========================================
+ Coverage 96.31% 97.20% +0.89%
==========================================
Files 19 21 +2
Lines 489 645 +156
==========================================
+ Hits 471 627 +156
Misses 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Exercise nominee_restricted_plurality, pairwise_majority, open/closed primaries, top_two_runoff_reduced_turnout (including sntv edge cases) - Cover three_two_one pairwise branches and 2D validation - Cover honest_321_ratings and honest_normed_scores invalid min/max range Co-authored-by: endolith <endolith@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the simulations and mechanisms discussed in issue #20.
Library additions
bimodal_electorate(elsim.elections): two voter clusters and matching candidate pools at ±separationon the first axis (documented indexing convention for left/right voters and candidates).three_two_one(elsim.methods): 3-2-1 voting with ballots encoded as 0 = Bad, 1 = OK, 2 = Good (party-specific semifinalist rules omitted as optional for simulations).honest_321_ratings(elsim.strategies): per-voter tertiles → Good/OK/Bad.honest_normed_scores(utilities, max_score=5, *, min_score=0): keyword-onlymin_score; keeps positionalmax_scorefor backward compatibility; rows with no utility spread map tomin_score.elsim.methods): restricted plurality nominees, pairwise majority between finalists, open vs closed partisan flows, top-two runoff with a subset electorate in the pairwise round.Examples (same style as
distributions_by_method.py)examples/bimodal_winner_distributions.py: 5k+5k voters, two clusters of candidates, dispersion 0.5, reduced-turnout primaries (~3.8k each side) and runoff (~8.5k voters). Methods include FPTP, contingent runoff, IRV, Score/STAR (0–5), Black, open/closed partisan primaries, 3-2-1, approval (mean threshold and vote-for-half), reference histograms.examples/score_star_range_comparison.py: same unimodal spatial setup as existing 1D plots; compares Score vs STAR for ranges 0–5, 0–10, 1–10, five-grade (0–4), 13- and 15-point scales.examples/bimodal_approval_strategy_comparison.py: optimal approval vs vote-for-half vs vote-for-one on the bimodal electorate.Tests
bimodal_electorateshape/means;three_two_oneedge cases; extended invalid tiebreaker coverage.All tests pass (
pytest tests/).