Largest Remainder
The largest remainder method (also known as Hare–Niemeyer method, Hamilton method or as Vinton's method) is one way of allocating seats proportionally for representative assemblies with voting systems.
Installation
yarn add largest-remainder
Usage
const largestRemainder = const votes = Conservatives: 13636684 Labour: 12877918 SNP: 977568 'Liberal Democrats': 2371861 Green: 525665 Other: 746144const seats = 650 let government = console
Results
┌─────────┬────────┬─────────────────────┬──────────┬──────────────────────┬────────────────────┬─────────────────────┬───────┬──────────────────────┬──────────────────────┐│ index │ type │ party │ votes │ percentage │ distribution │ remainder │ seats │ error │ percentageSeats │├─────────┼────────┼─────────────────────┼──────────┼──────────────────────┼────────────────────┼─────────────────────┼───────┼──────────────────────┼──────────────────────┤│ 0 │ 'hare' │ 'Conservatives' │ 13636684 │ 0437973859064024 │ 2846830083916156 │ 06830083916155445 │ 285 │ 031699160838439866 │ 043846153846153846 ││ 1 │ 'hare' │ 'Labour' │ 12877918 │ 041360432222159416 │ 2688428094440362 │ 08428094440361633 │ 269 │ 015719055596377984 │ 041384615384615386 ││ 2 │ 'hare' │ 'Liberal Democrats' │ 2371861 │ 007617783878642748 │ 4951559521117786 │ 05155952111778532 │ 49 │ 05155952111778603 │ 007538461538461538 ││ 3 │ 'hare' │ 'SNP' │ 977568 │ 0031396872543024375 │ 20407967152965842 │ 040796715296584196 │ 20 │ 040796715296584196 │ 003076923076923077 ││ 4 │ 'hare' │ 'Other' │ 746144 │ 002396415192267175 │ 15576698749736638 │ 05766987497366376 │ 16 │ 04233012502633624 │ 0024615384615384615 ││ 5 │ 'hare' │ 'Green' │ 525665 │ 0016882955462258285 │ 10973921050467885 │ 09739210504678848 │ 11 │ 0026078949532115203 │ 0016923076923076923 │└─────────┴────────┴─────────────────────┴──────────┴──────────────────────┴────────────────────┴─────────────────────┴───────┴──────────────────────┴──────────────────────┘
Quotas
Available quotas are hare
, droop
, hagenbach-bischoff
and imperiali
. See Quotas
Not providing a quota, rounds the seats down before ordering by the largest remainder and incrementally increasing.
droop
quota defaults to hare
quota when quota <= seats
Results object
type
the quota usedparty
the original key namevotes
the original key valuepercentage
the overall percentage of votes receiveddistribution
how the seats should be distributedremainder
the remainder used to order the results before addition of new seatsseats
the seats allocated to the partyerror
how far off thedistribution
is theseats
percentageSeats
what percentage the seats now represent
Credits
Written by Nic Mulvaney @ Normally
Inspired by https://github.com/juliuste/hare-niemeyer