Skip to content

Issue #20: bimodal winner distributions, 3-2-1, partisan primaries, Score/STAR ranges#50

Open
endolith wants to merge 2 commits into
masterfrom
cursor/issue-20-winner-distributions-4616
Open

Issue #20: bimodal winner distributions, 3-2-1, partisan primaries, Score/STAR ranges#50
endolith wants to merge 2 commits into
masterfrom
cursor/issue-20-winner-distributions-4616

Conversation

@endolith
Copy link
Copy Markdown
Owner

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 ±separation on 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-only min_score; keeps positional max_score for backward compatibility; rows with no utility spread map to min_score.
  • Partisan helpers (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_electorate shape/means; three_two_one edge cases; extended invalid tiebreaker coverage.

All tests pass (pytest tests/).

Open in Web Open in Cursor 

…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
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.20%. Comparing base (8a7213f) to head (f24f6fb).

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              
Flag Coverage Δ
no-numba 96.58% <100.00%> (+1.08%) ⬆️
numba 91.78% <100.00%> (+2.62%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants