Friday, 10 July 2015

George Osborne, Emma Way fanboi

In 1920, the government decided to introduce a tax for cars for their road use, called the road fund. It didn't work, because it was inefficient at allocating government resources, the road tax returned a surplus each year, which couldn't be spent on other things. Worse still, it incited by poor behaviour by drivers as they began to think they owned the roads, as pointed out by Winston Churchill in 1926.

So, the reversion of VED into a road tax is regressive and penalises future cleaner cars [which currently represent just 0.5% of newly registered cars in the UK ] as well as potentially affecting cyclists.

The idea is to get all road users to contribute to the maintenance of our crumbling road system on the principle that you pay for what you use[1].

However, if the purpose of the tax was to pay for road use, then the levy ought to be determined by the weight of the vehicle x its size x the distance traveled per year; since these factors govern the vehicle's usage of the road in terms of its occupancy and maintenance.

I did some searching and found that an average UK car is 1500Kg, 4.7m long and travels 12700Km per year.

Let's look at what happens if we apply that thinking to different cars:

For example, my Smart FourTwo weighs 740Kg and is 2.7m long and I drive it about 5000miles per year. I should therefore pay 740Kg/1500Kg x 2.7m/4.7m x 8000Km/12700Km= 0.179 x £140 x = £7.11, i.e. much less than I currently pay. Great, I'd be for that!

A VW Golf owner who drives an average amount should pay: 1300Kg/1500Kg x 4.3m/4.7m = 0.793 x £140 = £111.01, i.e. significantly less than the new VED.

A Land Rover Discovery driving 16K miles/year: 2150Kg/1500Kg x 4.7m/4.7m = 1.81 x £140 = £254.01. An entirely fair contribution.

But because the Chancellor lumps 95% of cars as needing to contribute as much to roads; what he means is that: smaller, lighter, cleaner cars are subsidising the VED. That's UNFAIR - even by his own criteria.

But the reversion of VED to a road tax raises the question of whether cyclists should pay. Studies have shown that this would discourage people from cycling, if they had to pay a cycling tax. Worse still, it validates the attitude of people like Emma Way who bragged about knocking cyclists off the road:
"Definitely knocked a cyclist off his bike earlier - I have right of way, he doesn't even pay road tax #bloodycyclist. " [2]
Osborne's redefinition of VED means her justification for injuring someone on a bike is now rewarded - we're currently not paying road tax. Given that cycling is facing an increasing backlash and despite a decrease in incidents, expect cycling injuries to go up.

Expect also calls for zero-emission cars to be taxed (they're not yet) on the grounds they use roads and therefore cyclists to be taxed on this basis.

But of course cyclists won't be taxed on the basis of their use of the road. Consider an above average cyclist who travels 15Km/day in a working week (x48 weeks): 14Kg/1500 x 1.72m/4.7 x 1m/2m (width) x 720Km/12640 => 0.00009727982763 x £140 = £0.01 . Yep, I'd pay that. I bet the government won't introduce a bike tax of 1p/year.

And that's the other practical problem. When you look at this tax, and the implications of it as it currently stands, even by the chancellors criteria; it's regressive: penalising people more if they want to travel healthier and cleaner, subsidising people who damage the environment as much as possible.




Monday, 11 May 2015

Thrifty Business

In the run-up to the UK General Election 2015, I ended up writing so many similar posts on facebook on why Austerity doesn't work that I thought I'd turn it into a blog entry.

Nobel Prize-winning economist Paul Krugman has written an excellent piece in the Guardian about the Austerity delusion. He covers the historical developments over the past 5 years and provides evidence for a negative correlation between austerity and economic growth.

All I want to do is show why the common-sense argument of the analogy from thrift isn't correct.

 The thrift argument is that, if I'm in debt, I have to cut back on my own spending until everything's under control and I can (and have) paid it off.

[*]And that's the right thing to do, however, it's not the whole story. In reality what happens is that when you cut back to pay off your debt, the people you trade with lose income. In a sense, they're soaking up the imbalance of your finances, but it works, because they're only losing a little bit when you cut back by a lot. The key thing is that your income stays the same while your outgoings shrink (a lot), and their income shrinks (a bit) while their outgoings stay the same - so you're passing on your debt, they take a bit of a hit too.
And therefore, it won't work if everyone is simultaneously in debt. When everyone starts cutting back, everyone's income shrinks and so they become less able to repay their debts. That's what happens when governments enact austerity: the private purse shrinks, internal trade stalls (and this in fact is what happened - banks stopped lending and started calling in debts, which is why businesses failed) and if the government acts along with it by reducing its spending in accordance with its lower tax revenue, it just adds to the problem.

The right thing to do then, if private lenders won't lend, is for the government to provide the cash to keep the economy going - and that means public borrowing during a financial crisis. That's half of Keynesianism, in essence.

Keynesianism, relies on another insight - that cash isn't a substitute for goods as we normally think, instead, cash is a medium for exchange. That is, cash operates as a pipe for transporting goods; the size of the pipe is the amount of cash we have, it determines the rate we can exchange and trade; it's not a representation of what we have.

So, if we go back to [*], we can see that's what's happening in the example. Your original debt is distributed across the entire system. It's the capacity of your input pipes (income+loans), which is the same as your output pipes capacity (spending), which determines the sizes of others' input pipes (income). When you cut back, the whole network capacity shrinks. Which is to say your debt was distributed everywhere all along. It's a really powerful concept to get one's head around, I've barely scratched the surface.

Friday, 20 March 2015

Arctic Attacks

Arctic Sea Ice has reached a new record low maximum. The Guardian covers it quite nicely in this article.

Arctic sea ice extent hits record low for winter maximum

In writing a reply to a comment for the article I ended up listing a number of major reasons why the Arctic is under attack. It turns out there's an awful lot of mechanisms and feedbacks that are making Arctic Sea Ice increasingly vulnerable. Off the top of my head I could think of these:

1. Most of the ice is now easily melted first-year ice, which even when it melts is less likely to refreeze, because it doesn't change salinity of the top layer of water much.

2. The Arctic sea surface temperatures are rising, and will be hit harder again, now we are in an El Nino phase; so melting from below is becoming more of an issue. [This is the primary cause of this years record low Arctic Maximum]

3. The increased amount of open water in the Arctic ocean means that Arctic sea ice is being affected more by storms. In the past the ice itself dampened waves; the effects of currents and could distribute the force of storms across the ice pack. Now there are open waves and the structural integrity can't withstand the currents nor storms. One the effects of this is 'flash melting' where stunning amounts of sea ice can suddenly melt by being submerged during a storm (this was a contributory factor to the summer record in 2012).

4. The increased amount of energy in the atmosphere around the Arctic ocean means that storms are becoming more common and stronger.

5. The increased humidity above the arctic has numerous effects. (a) Water vapour is a greenhouse gas and therefore it acts as a positive feedback on melt. (b) Increased cloud cover reduces direct levels of radiation acting as a negative feedback (though it's understood less than (a)). (c) Regular air temperatures above 0ºC means that rain is increasingly likely and rain is a much more effective thermal conductor than air (because water has a much higher specific heat capacity).

6. Arctic melting is starting to reach the coasts of the Greenland and Canadian Archipelago. This means that the multi-year ice is no longer held fast to the land and is therefore more easily transported.

7. Increased outflow and calving from Arctic glaciers, particularly in Greenland adds to the destabilisation of land-fast Arctic sea ice.

8. The opening of the North East Passage and in particular open water from the North Sea to the Bering Strait (separating Alaska and Russia) means that for some of the year actual ocean currents can flow all the way across the Arctic. This, again, increases transport.

9. The increased rate of arctic temperature rises compared with more southerly latitudes means that the northern Jetstream is breaking down (this is different to the Gulf stream of course). The effect is to make  the Jetstream more wavy which allows warmer air to be transported to the Arctic (often raising temperatures by >20ºC) as well as transporting cooler air further south causing major climatic problems in Canada and North America (the Polar Vortex).

So, in short - there's whole set of depressing indicators and feedbacks as the Arctic Sea Ice melts, which is why as a whole it's accelerating.

Thursday, 30 October 2014

Climate Faith For Beginners

There's a recent Guardian article about combating apathy about climate change.

Reports show the biggest threat to progress on climate change is cynicism. That’s why 10:10’s #itshappening project showcases positive action happening around the world now

I get this a lot on facebook - I have a high number of friends there, but it's rare that I see any of them post anything about raising awareness about climate change, and just as rare for them to like, share or comment on my frequent climate change posts. If cute kittens were the face of global warming activism we'd be in renewable utopia right now.

One of my biggest concerns about climate change is the serious possibility that in practice or in theory it's already too late. We know we're pretty close to exceeding the maximum amount of CO2 we can actually emit, but we also know that thanks to political efforts by the fossil fuel industry, we're still on track for the worst-case scenario for emissions.

The question is, assume that's the case, what happens then? I think, if I was an atheist (or possibly if I was pagan), then I'd either give up and just try to have as much fun as I could, while I could; or I might end up thinking that resolving global warming issues by violence would become my raging response to this slow inexorable crisis.

But I'm not, I'm a Christian who believes that we have a responsibility to take care of the planet. There's a school of theology that argues that Jesus won't return until the world is wrecked (and God plans to complete the destruction). In my post God Loves Green, you can read why I think that theology is misplaced so I won't cover it further here.

I think that a Christian perspective offers hope in a changing climate that I wouldn't have if I had other beliefs. And it centres on the message about Jesus. The message is this: everything we've fouled up, and everything people have damaged in us, was personally dumped on Jesus on the cross. The whole lot, as if he was to blame. He died, beyond any hope of coming back to life, and yet that's exactly what happened: Jesus was raised from the dead. It means that he overcame the lot and buying into him means you buy into that life, forever, from this moment.

This informs my perspective on climate change in three major ways.

Firstly: I'm already a winner; if I die tomorrow, I've already won. It means I can afford to lose in this world, I am not number 1. A practical example of this is the question of how I use my earnings. Almost a decade ago I was in a position to be able to buy a house of my own, instead I decided to invest in wind turbines and rent in shared accommodation. It put me at a disadvantage in a number of ways (e.g. my status amongst my peers who were buying houses), but I can afford to lose.

Secondly, because of the relationship between me (or us) and Jesus there really is a responsibility to act faithfully w.r.t God's creation. It does matter whether we de-carbonize or not, we can't just pray it away (though prayer, being the catalyst for God in action, is integral to everything we do and integral to the changes we see in others).

Thirdly, if we act faithfully, God will do the rest - he can do the impossible.

Put together, for me, my faith is the biggest hope I have for combatting climate change: it gives me a basis for being active even if the odds are against me. It means that I have a big, green light from God to act faithfully and it means I have hope even if I lose, because I've already won.

Tuesday, 16 September 2014

TUKES (The United Kingdom Except Scotland) Isn't Good Company.

I'm not very patriotic, to me that means I think the UK and Scotland will be worse off if The UK Excludes Scotland (TUKES). My lack of patriotism means I'm pro-union. Here's two personal reasons why:

  • Thanks to Scotland being in the UK it's easier for me to invest in Scotland. Case in point: I've invested thousands of pounds in the Boyndie Windfarm Cooperative; which means I effectively supply carbon-free energy to a number of houses in Scotland. With TUKES it would have been much harder for me to invest in Scottish wind farms and by that token harder for me to invest in English wind farms either.
  • My largest sales for FIGnition have been thanks to Strathclyde University, a Scottish University; through their investment with me RS Components decided to take the risk and place an order with me too. It would have been much harder for them to do that if Scotland wasn't part of the UK.
So far who's winning? On balance, Scotland. The amount of money I've made out of Scotland is less than the amount Scotland's made out of me in this respect. And what if Scotland leaves the UK? Then I'll make more money from Scotland than it's likely to invest in me simply because trade won't be quite so open and my current investments have a long-term payback.

To my mind, being part of the UK is in one sense an unpatriotic and therefore good thing to do, because it means considering the interests of the community outside the country. To my mind the whole Nationalist cause, whether it's the Front Nationale in France; the UKIP or the Scottish SNP are all expressions of the same trend when faced with the economic challenges post-2008: an inevitable trend to blame the issues on outsiders (the EU, immigrants or London) combined with hubristic jingoism. It doesn't follow. It's far more likely that the loss of Scotland would lead to greater economic hardship for both TUKES and Scotland.

For example, here's one scenario. If Scotland leaves the UK then it is likely that TUKES would shift in a more right-wing: England, Wales and N.I would become more nationalistic, UKIP (or TUKESIP as perhaps it should be called) would gain power, not least because there would be a loss of confidence in David Cameron, but also because the same trends that would have pushed Scotland into independence have been pushing the whole of the UK towards Nationalism.

This would raise the prospect of TUKES leaving the EU sooner, which would mean that Scotland (though newly independent) would also be at least temporarily leaving the EU. So, Scotland's independence will make it more likely the whole of the UK would leave the EU and the loss of the TUKES from the EU would help destabilise the EU itself (which isn't exactly looking solid right now).

The outgoing President of the European Council, Herman Van Rompuy, said a few years ago that "a rising tide of nationalism is the EU's biggest enemy... In every member state there are people who believe their country can survive alone in the globalised world. It's a lie... the time of the homogenous nation state is over."

The mistake is to think that independence means escaping from domination, but in reality the UK is interdependent and so the process is one of de-interdependence. That's what's really being voted on. It's the same issue as independence from the EU - though the ties are less strong and France/Germany have been the dominant partners, it will be bad for all concerned if we leave.

The mistake with Nationalism is to undervalue the level of interdependence. That's the problem with London, because it has an implicitly built-in Regionalism which under-values the interdependence of the rest of the UK. So, a vote for Nationalism validates London's attitude because it says "Hey, you got it right, we'll take it a step further." The rest of the UK feels the Regionalism and doesn't like it, but the solution isn't to go it alone and to form a break-away Northumbria (though with 15 million people* they'd have nearly 3 times the clobber of Scotland).

The solution is to make London more accountable, to redistribute power across the Kingdom rather than validate the Regionalism. It means bringing in laws that cause concentrations of power within the UK to look further afield and that can only be done by increasing the level of interdependence.

And another reason why I don't want to lose Scotland? Because I really like Scottish people, and so in my mind, The United Kingdom Except Scotland just Isn't Good Company.

(This is the first blog of two on why I think Scottish Independence isn't a good thing, the next blog is coming soon!).

*Comprising of the North West, the North East and Yorkshire & Humber = 14.9million.

Saturday, 5 July 2014

BootJacker: The Amazing AVR Bootloader Hack!

There's an old adage that says if you don't know it's impossible you could end up achieving it. BootJacker is that kind of hack: a way for ordinary firmware on an AVR to reprogram its bootloader. It's something Atmel's manual for AVR microcontrollers with Bootloaders says is impossible (Note the italics):

27.3.1 Application Section.
The Application section is the section of the Flash that is used for storing the application code. The protection level for the Application section can be selected by the application Boot Lock bits (Boot Lock bits 0), see Table 27-2 on page 284. The Application section can never store any Boot Loader code since the SPM instruction is disabled when executed from the Application section.

Here's the background: I'm the designer of FIGnition, the definitive DIY 8-bit computer. It's not cobbled together from hackware from around the web, instead three years of sweat and bare-metal development has gone into this tiny 8-bitter. I've been working on firmware version 1.0.0 for a few months; the culmination of claiming that I'll put audio data transfer on the machine (along with a fast, tiny Floating point library about 60% of the size of the AVR libc one).

Firmware 1.0.0 uses the space previously occupied by its 2Kb USB bootloader and so, needs its own migration firmware image to copy the V1.0.0 firmware to external flash. The last stage is to reprogram the bootloader with a tiny 128b bootloader which reads the new image from external flash. Just as I got to the last stage I came across section 27.3.1, which let me know in no uncertain terms that I was wasting my time.

I sat around dumbstruck for a while ("How could I have not read that?") before wondering whether[1], crazies of crazy, imagining that a solution to the impossible might actually lead me there. And it turns out it does.

The solution is actually conceptually fairly simple. A bootloader, by its very nature is designed to download new firmware to the device. Therefore it will contain at least one spm instruction. Because the spm configuration register must be written no more than 4 cycles before the spm instruction it means there are very few sequences that practically occur: just sts, spm or out, spm sequences. So, all you need to is find the sequence in the bootloader section; set up the right registers and call it.

However, it turned out there was a major problem with that too. The V-USB self-programming bootloader's spm instructions aren't a neat little routine, but are inlined into the main code; so calling it would just cause the AVR to crash as it tried to execute the rest of the V-USB bootloader.

Nasty, but again there's a solution. By using a timer clocked at the CPU frequency (which is easy on an AVR), you can create a routine in assembler which sets up the registers for the Bootloader's out, spm sequence; calls it and just at the moment when it's executed the first cycle of the spm itself, the timer interrupt goes off and the AVR should jump to your interrupt routine (in Application space). The interrupt routine pops the bootloader address and then returns to the previous code - which is the routine that sets up the outspm sequence. This should work, because when you apply spm instructions to the bootloader section the CPU is halted until it's complete.

Here's the key part of BootJacker:

The code uses the Bootloader's spm to first write a page of flash which also contains a usable outspm sequence and then uses that routine to write the rest (because of course you might end up overwriting the bootloader with your own new bootloader!)

BootJacker involves cycle counting, I used a test routine to figure out the actual number of instructions executed after you set the timer for x cycles in the future (it's x-2). In addition I found there was one other oddity: erase and writes always have a 1 cycle latency after the SPM in a bootloader. I fixed this with a nop instruction in my mini bootloader.

This algorithm, I think is pretty amazing. It means that most bootloaders can in fact be overwritten using application firmware containing a version of BootJacker!

[1] As a Christian, I also have to fess' up that I prayed about it too. Not some kind of desperation thing, but some pretty calm prayer, trusting it'll get sorted out :-) 

Saturday, 31 May 2014

Gini Sim

The Gini Index is a measure of wealth distribution.

GiniSim is a simple Javascript program which demonstrates, in simple terms, flaws in free market economics, by showing that trading freely will lead to gross inequality. Copy the program into a .html file; save it and then open it in a browser: you can stop it by pressing the Stop button. Alternatively, you can download and run a simple Java version, GiniSim.jar from here.

Each bar is the wealth of a person, and the simulation starts with everyone having $10 (or £10, or 10€).

Each step simulates a free trade transaction, two monetary notes are picked at random and the person the first one belongs to pays the person the second one belongs to. Intuitively, you’d think this would average out: sometimes some people win and sometimes others would.

In reality what happens is that whenever a person accumulates wealth, it makes it more likely that someone poorer will give money to them. This is due to the fact that the chances of being paid in a transaction is proportional to their wealth - so if someone loses money from a transaction, they become less likely to gain in a future transaction.

How does this correspond to an idealism of the free market? It corresponds, because exchanges take place on the basis of being indifferent towards cash. Therefore when people gain wealth, their wealth acts as a bigger wealth footprint and people (who want to buy things) notice the cash more. If you’re poorer, that doesn’t happen, you’re not noticed, because your visible presence is the cash you hold - you literally disappear.

The important thing to note is that GiniSim demonstrates inequality without the agents involved behaving maliciously. All it does is play fairly towards cash (rather than people). It's a demonstration of a power law.

How does GiniSim1 not correspond to classical economics? GiniSim1 correspond to free trade under mercantilism, which is a zero-sum economic theory.

Here’s GiniSim, copy everything in yellow:

<!DOCTYPE html>
<button onclick="clearInterval(timer)">Stop</button>
<canvas id="myCanvas" width="800" height="600" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.

  var c=document.getElementById("myCanvas");
  var ctx=c.getContext("2d");
  var timer;
  var rects=0;
  var cash=[0],people=[0];
  var kStartCash=10;
  var kNumPeople=100;
  function initGini() {
    var ix,iy;
    for(ix=0;ix<kNumPeople;ix++) {
      people[ix]=kStartCash; // everyone starts with $10.
      for(iy=0;iy<kStartCash;iy++) {
        cash[ix*kStartCash+iy]=ix; // each $1 is owned by a person.
  function incomeSwap(from,too) {
    var ix;
    for(ix=0;ix<kNumPeople*kStartCash;ix++) {
      else if(cash[ix]==too)
  function exchange() {
    var aNote=Math.floor(Math.random()*kStartCash*kNumPeople);
    var aOwner=cash[aNote];
    var aNewNote=Math.floor(Math.random()*kStartCash*kNumPeople);
    var aNewOwner=cash[aNewNote];
    if(people[aOwner]>0 ) {
      // can't take cash from people who have nothing.
      while(aOwner>0 && people[aOwner]<people[aOwner-1]) {
      while(aNewOwner<kNumPeople-1 && people[aNewOwner]>people[aNewOwner+1]) {
  function drawImage() {
    var ix;
    for(ix=0;ix<kNumPeople;ix++) {

[Edit: Added link to GiniSim.jar on 20150321. Edit: I knew from the simulations that wealth always gravitates to the rich, but my reasoning for the mechanism was incorrect, because I was trying to derive it from the probabilities of a single transaction. In reality, the mechanism is due to how the probabilities change between one transaction and the next. 20150626.]