ndarville / d3-charts

Collection of small, reusable charts created with d3.js
7 stars 1 forks source link

JS function for calculating Danish mandates #14

Open ndarville opened 10 years ago

ndarville commented 10 years ago

Links

Denmark's mandate calculation:

Votes Selection
4 Chosen overseas
135 D'Hondt
40 Sainte-League

mandates = dHondt(votes, 135) + sainteLeague(votes, 40);

var partyAmount = null, // 12 --- for each row where vote share is above threshold
    seatAmount = null, // 179
    population = null, // 5000000
    threshold = null, // in per cent; e.g. 2
    columns = function(seatAmount) {}; // find more optimal value than seatAmount

Steps

1

D'Hondt

Create a table with

Create a table with

Pick the {{ partyAmount }} largest values

Party Votes 1 2 3 ... seatAmount
A v_A *v_A/1 *v_A/2 v_A/3 ... v_A/seatAmount
B v_B *v_B/1 v_B/2 v_B/3 ... v_B/seatAmount
C v_C v_C/1 v_C/2 v_C/3 ... v_C/seatAmount

3

Summary:

ndarville commented 10 years ago
  1. http://politiskkompas.blogspot.com/2014/04/lidt-valgmatematik-i.html
  2. http://politiskkompas.blogspot.com/2014/04/lidt-valgmatematik-ii.html
  3. http://intranet.odensekatedralskole.dk/~ph/matematik/2007g/Elklit_Valgsystemer_2005.pdf