Showing posts with label voting. Show all posts
Showing posts with label voting. Show all posts

26 May, 2014

D'Hondt results table for London MEP elections

There was just an election in the UK for the European Parliament (to elect MEPs), and it was interesting in the news because of the rise of one particular party, UKIP. The European elections use a proportional representation method, which UK general elections don't, so this doesn't mean that there will be a corresponding rise in UKIP members of parliament (at present, 0) at the next general election.

I voted in the London constituency, which has 8 MEPs elected in one ballot.

Wikipedia has a list of number of votes and number of MEPs elected, for each party.

Both the Green Party and UKIP got the same number of MEPs: 1 each. But their vote count was very different (371,133 for UKIP vs 196,419 for the Greens), and the liberal democrats, traditionally the third party in UK politics, got no seats at all.

I found myself playing with some "what-if" scenarios to better understand how the results came out.

The vote works like this: each elector chooses one choice on the ballot paper from a list of chosen parties - there were 17 parties on the paper, mostly small, fairly irrelevant ones.

The votes for each party are tallied, giving a vote count for each party.

Then, it is necessary to convert that vote count into a set of 8 MEPs that broadly reflects the proportion of votes. This is done here with the D'Hondt method which as an intermediate step needs a two-dimensional table. I'm going to omit the smaller parties here because they don't have an effect on my scenarios.

PartyCount /1/2/3/4/5/6/7/8/9/10/11/12
Labour806959806959 (1)403479 (3)268986 (5)201739 (7)161391 (11)13449311527910086989662806957335967246
Conservative495639495639 (2)247819 (6)165213 (10)1239099912782606708056195455071495634505841303
UKIP371133371133 (4)185566 (9)123711927837422661855530194639141237371133373930927
Green196419196419 (8)9820965473491043928332736280592455221824196411785616368
LibDem148013148013 (12)7400649337370032960224668211441850116445148011345512334

So the 8 seats were chosen as the top 8 "votes / seats" quotients. Those are coloured yellow in the table. I've also numbered the winning positions and the next 4 after that in order of "votes / seats".

So there's a difference there between the Greens and UKIP: UKIP was chosen 4th, with a solid block of votes to get its single seat. The greens were chosen last, and only just got a seat.

What do I mean by "only just"? Well, the next seat allocated if not for the Greens would have been a second UKIP seat (numbered 9 in the table) and to get that they would have needed 2 * 196419 = 392838 votes to beat the Greens: 21706 votes more than they actually got.

Or conversely, if the greens had got less than 185566 votes (so 10853 less than they really got), they would have taken 9th place, behind a 2nd UKIP seat taking the 8th seat. If that was the case, then the table would have looked like this:

PartyCount /1/2/3/4/5/6/7/8/9/10/11/12
Labour806959806959 (1)403479 (3)268986 (5)201739 (7)161391 (11)13449311527910086989662806957335967246
Conservative495639495639 (2)247819 (6)165213 (10)1239099912782606708056195455071495634505841303
UKIP371133371133 (4)185566 (8)123711927837422661855530194639141237371133373930927
Green185565185565 (9)9278261855463913711330927265092319520618185561686915463
LibDem148013148013 (12)7400649337370032960224668211441850116445148011345512334

Another thing that I think is interesting is just how badly the Lib Dems did. To get a seat, all other votes being equal, they'd have needed to get up to that 196419 to steal the 8th place off the Greens: that is 196419 - 148013 = 48406 more votes, 32% more than they actually got.

A different way of looking at that is considering if there were more than 8 seats, how many more seats would there need to be for the Lib Dems to get a seat to represent their proportion (about 6%) of the electorate?

The numbers in the first table above beyond 8 show that: the Lib Dems are 12th in line for a seat, after This table shows the 11 yellow coloured seats ahead of the lib dems, one more seat for each of Labour, the Conservatives, and UKIP.

PartyCount /1/2/3/4/5/6/7/8/9/10/11/12
Labour806959806959 (1)403479 (3)268986 (5)201739 (7)161391 (11)13449311527910086989662806957335967246
Conservative495639495639 (2)247819 (6)165213 (10)1239099912782606708056195455071495634505841303
UKIP371133371133 (4)185566 (9)123711927837422661855530194639141237371133373930927
Green196419196419 (8)9820965473491043928332736280592455221824196411785616368
LibDem148013148013 (12)7400649337370032960224668211441850116445148011345512334

So many election tea-leaves for staring into in this election!

You can get the Haskell code on GitHub that produced the above tables, if you want to fiddle yourself.

09 February, 2014

Range-weighted average-score voting at battle of the bands.

Went to a "Battle of the Bands" contest. It was in a bar and the audience got to vote. Everyone was given cards numbered 1 point, 3 points and 5 points. Voting happened after each band played. We'd all gone to see a friend of a friend so the obvious strategy was to vote 5 for that band, and not vote for the others.

Turned out they did the voting differently here: they computed the average score rather than the total score. In a fixed audience, both average and total would produce the same ranking. But in this situation the audience changed. Battle of the bands is really "who has the most friends?" and people turn up only to see and vote for their friend.

So normally you'd vote 5 points for your band, and ignore all the others (who might be playing when you haven't even arrived yet or after you've left) and that would be equivalent to voting 0.

Using an average vote penalises you for this, though: your absence didn't count as a zero vote because you weren't in the total vote tally. To downvote a band that isn't your friends, you have to be physically present.

That seemed a neat way for the bar to make you stay and drink more beer.

21 August, 2013

STV with restoration of eliminated candidates

STV eliminates candidates (and transfers their votes) until someone hits quota and win a seat. Then that winner's leftover votes are redistributed according to the next preference on those vote papers, and the process is repeated until there are no seats left to win.

One of the complaints about STV is that someone who is no ones first choice can get eliminated, even when it might turn out that they would get many second choice votes later on.

What happens if, after eliminating candidates enough times for someone to win, then in the next round those candidates are put back into the race, so can receive next-preference transfers?

It seems to make the counting process more complicated, but if you're doing this electronically, not devastatingly so. It puts candidates back in to receive transfers even if they weren't good enough to stay in the first round election.

What led me to wonder about this is some previous musing about proportional representation in the hereditary peers bit of the House of Lords, which is a bit like a stretched-out-over-time system that puts candidates back in for each seat.

30 July, 2013

Proportional Representation in the hereditary peers section of the House of Lords

The (UK) House of Lords has 15 seats elected by the approximately 800 hereditary peers, with a lifetime appointment.

As elections only happen on a seat by seat basis as they become vacant, for example through death; and never through general elections, many electoral systems cannot apply. The present system used is AV/IRV (single seat STV).

I'm not particularly interested in reform of the way this particular bit of the House of Lords, but I started wondering how one would achieve proportional representation in such a system: where you have seats where candidates are elected for life and do not stand for re-election.

To start with, why do I think there wouldn't be PR in the system described above? Because each seat is elected individually, by the same set of electors, so whichever power bloc was dominant in those electors would win every election. (so very similar to the problem of using First-Past-The-Post in House of Commons elections). Potentially 49% of electors could form a power bloc but end up with no representation. That doesn't seem to happen too much in the lords, though - the by-elections that have taken place seem to return a few different parties, but the turnout is low (50%) and so you only need 150 of the 800 potential votes to get a seat.

Because the seats are elected one at a time, many existing PR systems can't work. But I have been pondering if such systems could be adapted to this lifetime appointment, one seat at a time model.

Some PR systems (STV and Reweighted Range Voting) operate basically as:

  • Everyone starts with a vote worth 1.
  • A round happens, in which a single seat is filled. Any vote which was not used to elect that seat keeps its present value. Any vote which was used to elect that seat is reweighted to a lesser value so that it will have less impact in the next round; and ranking/choice information for that elected candidate is removed from each ballot.
  • Rounds are repeated until there are no free seats.
(Some other systems, such as CPO-STV, are not round-based and so not amenable to this treatment)

My idea for adapting any voting system which has that form into the Lords model is as follows:

  • Everyone starts with a vote worth 1, at the initial election of the first members.
  • In the initial election of first members, one round will happen for each seat (so 15 rounds)
  • Subsequently only one round will happen at one time, as a seat becomes vacant.
  • When a ballot is reduced in strength by a particular amount, because it was used to elect a candidate, then that reduction is recorded against the seat (so in the Lords case, 15 seats x 800 electors = 12000 numbers)
  • When a by-election happens, voters are given the new choice of candidates, but retain their weakened vote strengths from the previous round (previous by-election) except that any vote fractions recorded against the now vacant seat are added onto the vote strength of each voter.
  • This procedure continues forever, one round per vacant seat.

I haven't done any mathematical analysis of this. But it feels like it might give proportionality: two distinct power blocs A and B should end up with seats in proportion to their relative strengths. When an A seat comes up for election, it will release a bunch of votes to the A-bloc voters and they can elect a replacement, if 30 years later they're still in the same bloc.

How would you add this into the present system where the 15 seats are already elected? Give everyone a vote worth 1 and start as if the next by-election is the first. As time passes, more and more seats will be elected with this method until (assuming each lords is mortal) all the seats are elected this way.

It needs to store a lot of information between elections: the product of the number of seats and the number of electors. This is feasible in the above case because only about 12000 numbers need be managed. It does not seem so easy when the electorate is an entire population.

In the lords case, there are almost no new electors: the set of hereditary titles is basically fixed and vote strengths can be attached to those titles rather than to the individual with that title at any one time. In the case of changing membership, new members must be given an initial voting strength. Giving them an initial strength of 1 would mean that new members would be more powerful than existing members in their initial vote. Another approach would be to encumber their votes against the existing seats based on some kind of average so that their vote strength is released over time.

(modified with a few more notes on 2013-07-31) (modified with CPO-STV reference on 2013-08-12)

03 July, 2010

chess rankings for photos

I have a lot of photos - around 50000. I want to have some kind of scoring system for them.

The obvious one is something like a 5-star scale: when presented with a photo, you can award it from 0 to 5 stars, with 5 being best and 0 being worst.

But thats not very granular, and it is not clear to me that clearly defined standards for the 6 different scores will emerge.

I preferred something that says "this is better than that, so this should have a higher score than that".

But I don't want to have to manually make a strict linear order of all photos (despite the fact that a numerical score would do so), and I want the system to tolerate inconsistencies (eg. A>B, B>C, C>A) somehow.

Eventually I read about chess ranking, where each player is assigned a numerical score indicating their "goodness" and the scores are adjusted by pairwise comparisons between players - chess matches.

I adapted this for scoring my photographs. I started with the glicko system and modified it some.

The way this works is:

Photos compete against each other, as chess players compete against each other. The equivalent of a chess match is a presentation of two photos alongside each other in a web browser, with the user clicking on the photo they prefer. So, users do not assign an absolute score to a photo. Nor do they pick how much better one photo is than the other. They pick have a simple choice: "a>b" or "b>a".

Each photo is assumed to have a single numeric score, such that the difference in the score reflects the probability that one photo will win over the other photo. (this is affine: 900 vs 1000 is the same probability as 4000 vs 4100)

It is assumed that the score cannot be known exactly, but is approximated by a normal distribution (so there is a mean, and a standard deviation).

Adding a comparison between two photos gives information about the distributions for both photos causing the mean and standard deviation to be changed to more accurately reflect the score, as described in the glicko paper.

For my 50000 photos from the past 5 years, I have about 20% voted on at least once.

For a recent trip to rome, where I took about 1000 photos, it took a few hours to include each photo in at least one vote, where each comparison was an unvoted photo vs a random photo (which may or may not have been previously voted). This does not give a huge amount of information per photo.
Once that was done, I spent some hours making other votes: sometimes random vs random, sometimes random vs the photo with the closest mean. This caused rankings to become somewhat refined (sometimes causing surprisingly large changes in mean score)

So here are the top 3 photos from that trip:



and here are the bottom 3:



It seems to work reasonably well, though I think I need many more votes to get more accuracy. But that will come over time: as new photos are added, they'll get their scores by being compared against old photos, which will give more information about the old photos too.