Skip to content

Fix winner distribution plots: center on voter median (#22)#45

Open
endolith wants to merge 3 commits into
masterfrom
cursor/issue-22-winner-distributions-median-center-df3e
Open

Fix winner distribution plots: center on voter median (#22)#45
endolith wants to merge 3 commits into
masterfrom
cursor/issue-22-winner-distributions-median-center-df3e

Conversation

@endolith
Copy link
Copy Markdown
Owner

@endolith endolith commented May 11, 2026

Summary

  • tomlinson_2023_figure_3_updated.py: Winner positions minus voter median per election; ideal = candidate nearest that median (issue Remove discrepancy from winner distribution plots #22).
  • tomlinson_2023_figure_3.py: Same anchoring idea for the Figure 3 reproduction: one voter-sample median ref translates both uniform draws on ([0,1]) so distances are unchanged but the realized median sits at 0.5 (consistent with the updated script).
  • distributions_by_*: Unchanged from master (no issue Remove discrepancy from winner distribution plots #22 centering there).

Closes #22.

Testing

  • python3 -m pytest tests/ -q (191 passed)
Open in Web Open in Cursor 

Benchmarks and histograms used the coordinate origin for "nearest
center", which misaligned Condorcet-style outcomes with the reference
ideal. Record winner locations minus the sample voter median and define
the ideal winner as the candidate closest to that median (issue #22).

Figure 3 reproduction anchors the uniform draws to the voter median like
the other examples.

Co-authored-by: endolith <endolith@gmail.com>
@what-the-diff
Copy link
Copy Markdown

what-the-diff Bot commented May 11, 2026

PR Summary

  • Introduction of Reference Calculation for Winner Positions
    This update introduces a new calculation for determining the winner positions in relation to the electorate center. This improvement provides a more accurate representation of the winner position.

  • Enhanced Accuracy in Appending Winners to Lists
    The approach for adding winners to the lists has been updated. This change makes it more precise and accurate by taking into consideration the reference points from candidate positions across various voting methods.

  • Modification in the Ideal Winner Method
    The description and logic of the ideal winner method have been altered. Now, it refers to the nearest voter median instead of the center, which helps in providing a more exact and realistic representation of the winner.

  • Improved Explanation via Comments
    The comments in the code have been updated to better explain that the winner positions are visualized in relation to the electorate center. These revisions provide a clearer background for the modifications implemented.

  • Consistency in Formatting and Naming
    There have been improvements in the formatting and naming related to reference calculations, ensuring a more readable and understandable code by enforcing consistency across all modified files.

@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 96.31%. Comparing base (8a7213f) to head (438e16c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #45   +/-   ##
=======================================
  Coverage   96.31%   96.31%           
=======================================
  Files          19       19           
  Lines         489      489           
=======================================
  Hits          471      471           
  Misses         18       18           
Flag Coverage Δ
no-numba 95.50% <ø> (ø)
numba 89.16% <ø> (ø)

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.

cursoragent and others added 2 commits May 11, 2026 23:37
Revert issue #22 coordinate centering for Merrill-style
distributions_by_* scripts. Keep median-centered winners and ideal
benchmark in tomlinson_2023_figure_3_updated.py; restore
tomlinson_2023_figure_3.py to mean anchoring for paper reproduction.

Co-authored-by: endolith <endolith@gmail.com>
Use one median ref for both voter and candidate uniforms on [0, 1]
so distances match the raw draw; drop incorrect Merrill mention in
the updated example comment.

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.

Remove discrepancy from winner distribution plots

2 participants