# Our Voting System Is STILL Broken!

Please take a moment to look at these two maps, especially if you voted in the recent General Election (#GE2017).

Just as I did for the UK General Election two years ago in 2015, I’ve taken it upon myself to analyse the results and highlight the differences (and imbalance) between the First Past the Post and Proportional Representation (D’Hondt) systems.

Again, after looking at the results of the General Election in some detail it is still apparent  that our voting system in this country is very, very broken! Just to remind everyone, we don’t actually vote for parties (and therefore governments), we simply vote for our local representative. The total number of votes a party receives is not taken into consideration at all, which seems a little strange, particularly when you consider that all through the election campaigns we hear ‘Vote Conservative’ or ‘Vote SNP’, not ‘Vote Bob Smith, your local MP’.

So, as I am still a tremendous geek, I got my hands on all the numbers, created a database and generated some maps!

The first image is the results as you will have seen them using the First Past the Post method. I merely created this one for reference.

The second image is the same numbers, this time evaluated using the D’Hondt method for calculating Proportional Representation. This method quite literally calculates the number of seats a party should get based on their proportion of the overall votes cast. I then assigned constituencies to each party (largest first) based on the constituencies in which they received the most votes, thus insuring that (for the most part and where possible) the local representative reflects the local preference.

Interestingly, the constituency of the Na h-Eileanan an Iar (Western Isles) in Scotland ended up with an MP from the Ulster Unionist Party… who only stand in Northern Ireland! This shows two things:

1. It is not appropriate for local issues parties to stand in a country wide election (IMHO).
2. My method for seat distribution under D’Hondt PR may be somewhat simplistic!

As can be seen, the difference is astounding! The Liberal Democrats would have 48MPs not 12, UKIP would have 12MPs not 0, the Green Party would have 10MPs not 1, the SNP would have 20MPs not 35! Most importantly, The Conservative Party would have had a much harder time finding an ally to form a minority as they would have had 38 less seats and only 16 more than second party Labour.

Seeing these results, I still really don’t understand how anyone can argue against the fact that, using PR, we would have a balanced, fairer and more representative government.

Also, consider getting involved by liking or joining the Electoral Reform Society (Scotland) and by lobbying your local representatives at Council, Local Assembly and Governmental level. Check out TheyWorkForYou to find out who they are!

NB. these images were made for demonstration purposes only, assumptions are made and errors happen, so if something is wrong its not intentional! These image were made my me (Rob Kent) using the Python programming language, PostgreSQL, NumPy and matplotlib with data from BBC News, the Office for National Statistics and the Ordnance Survey and OpenDataNI.

# Our Voting System Is Broken!

Please take a moment to look at these two maps, especially if you voted in the recent General Election (‪#‎GE2015‬).

After looking at the results of the General Election in some detail over the past few days it has become more apparent than ever to me that our voting system in this country is very, very broken! We don’t actually vote for parties (and therefore governments), we simply vote for our local representative. The total number of votes a party receives is not taken into consideration at all, which seems a little strange, particularly when you consider that all through the election campaigns we hear ‘Vote Conservative’ or ‘Vote SNP’, not ‘Vote Bob Smith, your local MP’.

So, being a tremendous geek, I got my hands on all the numbers, created a database and generated the following two images.

The first image is the results as you will have seen them using the First Past the Post method. I merely created this one for reference.

The second image is the same numbers, this time evaluated using the D’Hondt method for calculating Proportional Representation. This method quite literally calculates the number of seats a party should get based on there proportion of the overall votes cast. I then assigned constituencies to each party (largest first) based on the constituencies in which they received the most votes, thus insuring that (for the most part and where possible) the local representative reflects the local preference.

As can be seen, the difference is astounding! UKIP would have 83MPs not 1, the Green Party would have 25MPs not 1, the SNP would have 31MPs not 56!

Seeing these results, I really don’t understand how anyone can argue against the fact that, using PR, we would have a balanced, fairer and more representative government.

Also, consider getting involved by liking or joining the Electoral Reform Society (Scotland) and by lobbying your local representatives at Council, Local Assembly and Governmental level. Check out TheyWorkForYou to find out who they are!

NB. these images were made for demonstration purposes only, assumptions are made and errors happen, so if something is wrong its not intentional! These image were made my me (Rob Kent) using the Python programming language, SQLite, NumPy and matplotlib with data from BBC News, the Office for National Statistics and the Ordnance Survey.

# Pretty Math Formulae with PyQt4 and matplotlib

I recently found myself in need of a way of displaying mathematical formulae, in an accurate and visually pleasing manner, without resorting to the use of pre-rendered images. It turns out that if you have matplotlib handy you can do this with relative ease as it provides a version of TeX markup called MathText for doing just this.

The following is an example of a label widget displaying the Discrete Fourier Transform (DFT):

from PyQt4.QtCore import *
from PyQt4.QtGui import *

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas

class MathTextLabel(QWidget):
def __init__(self, mathText, parent=None, **kwargs):
QWidget.__init__(self, parent, **kwargs)

l=QVBoxLayout(self)
l.setContentsMargins(0,0,0,0)

r,g,b,a=self.palette().base().color().getRgbF()

self._figure=Figure(edgecolor=(r,g,b), facecolor=(r,g,b))
self._canvas=FigureCanvas(self._figure)

self._figure.clear()
text=self._figure.suptitle(
mathText,
x=0.0,
y=1.0,
horizontalalignment='left',
verticalalignment='top',
size=qApp.font().pointSize()*2)
self._canvas.draw()

(x0,y0),(x1,y1)=text.get_window_extent().get_points()
w=x1-x0; h=y1-y0

self._figure.set_size_inches(w/80, h/80)
self.setFixedSize(w,h)

if __name__=='__main__':
from sys import argv, exit

class Widget(QWidget):
def __init__(self, parent=None, **kwargs):
QWidget.__init__(self, parent, **kwargs)

l=QVBoxLayout(self)
mathText=r'$X_k = \sum_{n=0}^{N-1} x_n . e^{\frac{-i2\pi kn}{N}}$'