Shame about the title though. I think the words “Yes we can” should probably be banned. Anyway, here’s Robin Hahnel on “Change how the world works? Yes we can“:
Until capitalism is replaced, we want the tail to stop wagging the dog. Finance should serve the real economy instead of the other way around. If the financial sector improves the efficiency of the real economy, it is helpful. But if it misdirects investment resources to where they are less productive, it reduces production in the real economy by obstructing the flow of credit altogether. Then it is failing to accomplish its only social purpose. Jobs producing useful goods and services, and investments which help us to produce what we need with less human toil and less strain on the environment, are what count. Increases in the profit rates and stock prices of financial corporations count for nothing when they fail to correspond to real increases in productivity, as has too often been the case.
We have offered several positive alternatives to capital liberalization and to the governing structures and policies of the International Monetary Fund (IMF) and the World Bank, such as capital controls and a Tobin tax to protect smaller economies from volatile speculative flows. We have made suggestions on how national governments can restore competent regulation of their traditional financial sectors, and stressed the urgency of extending regulation to cover new financial institutions which were allowed to grow outside existing regulatory structures.
Filed under: Mathematics, Programming, python | Tags: fast mandelbrot, mandelbrot, mandelbrot set, numpy, vectorisation, vectorization
This will be of little interest to people who regularly read my blog, but might be of some interest to people who find their way here by the power of Google.
The standard way to compute fractals like the Mandelbrot set using Python and numpy is to use vectorisation and do the operations on a whole set of points. The problem is that this is slower than it needs to be because you keep doing computations on points that have already escaped. This can be avoided though, and the version below is about 3x faster than the standard way of doing it with numpy.
The trick is to create a new array at each iteration that stores only the points which haven’t yet escaped. The slight complication is that if you do this you need to keep track of the x, y coordinates of each of the points as well as the values of the iterate z. The same trick can be applied to many types of fractals and makes Python and numpy almost as good as C++ for mathematical exploration of fractals.
I’ve included the code below, both with and without explanatory comments. This 400×400 image below using 100 iterations took 1.1s to compute on my 1.8GHz laptop:

Uncommented version:
def mandel(n, m, itermax, xmin, xmax, ymin, ymax):
ix, iy = mgrid[0:n, 0:m]
x = linspace(xmin, xmax, n)[ix]
y = linspace(ymin, ymax, m)[iy]
c = x+complex(0,1)*y
del x, y
img = zeros(c.shape, dtype=int)
ix.shape = n*m
iy.shape = n*m
c.shape = n*m
z = copy(c)
for i in xrange(itermax):
if not len(z): break
multiply(z, z, z)
add(z, c, z)
rem = abs(z)>2.0
img[ix[rem], iy[rem]] = i+1
rem = -rem
z = z[rem]
ix, iy = ix[rem], iy[rem]
c = c[rem]
return img
Commented version:
from numpy import *
def mandel(n, m, itermax, xmin, xmax, ymin, ymax):
'''
Fast mandelbrot computation using numpy.
(n, m) are the output image dimensions
itermax is the maximum number of iterations to do
xmin, xmax, ymin, ymax specify the region of the
set to compute.
'''
# The point of ix and iy is that they are 2D arrays
# giving the x-coord and y-coord at each point in
# the array. The reason for doing this will become
# clear below...
ix, iy = mgrid[0:n, 0:m]
# Now x and y are the x-values and y-values at each
# point in the array, linspace(start, end, n)
# is an array of n linearly spaced points between
# start and end, and we then index this array using
# numpy fancy indexing. If A is an array and I is
# an array of indices, then A[I] has the same shape
# as I and at each place i in I has the value A[i].
x = linspace(xmin, xmax, n)[ix]
y = linspace(ymin, ymax, m)[iy]
# c is the complex number with the given x, y coords
c = x+complex(0,1)*y
del x, y # save a bit of memory, we only need z
# the output image coloured according to the number
# of iterations it takes to get to the boundary
# abs(z)>2
img = zeros(c.shape, dtype=int)
# Here is where the improvement over the standard
# algorithm for drawing fractals in numpy comes in.
# We flatten all the arrays ix, iy and c. This
# flattening doesn't use any more memory because
# we are just changing the shape of the array, the
# data in memory stays the same. It also affects
# each array in the same way, so that index i in
# array c has x, y coords ix[i], iy[i]. The way the
# algorithm works is that whenever abs(z)>2 we
# remove the corresponding index from each of the
# arrays ix, iy and c. Since we do the same thing
# to each array, the correspondence between c and
# the x, y coords stored in ix and iy is kept.
ix.shape = n*m
iy.shape = n*m
c.shape = n*m
# we iterate z->z^2+c with z starting at 0, but the
# first iteration makes z=c so we just start there.
# We need to copy c because otherwise the operation
# z->z^2 will send c->c^2.
z = copy(c)
for i in xrange(itermax):
if not len(z): break # all points have escaped
# equivalent to z = z*z+c but quicker and uses
# less memory
multiply(z, z, z)
add(z, c, z)
# these are the points that have escaped
rem = abs(z)>2.0
# colour them with the iteration number, we
# add one so that points which haven't
# escaped have 0 as their iteration number,
# this is why we keep the arrays ix and iy
# because we need to know which point in img
# to colour
img[ix[rem], iy[rem]] = i+1
# -rem is the array of points which haven't
# escaped, in numpy -A for a boolean array A
# is the NOT operation.
rem = -rem
# So we select out the points in
# z, ix, iy and c which are still to be
# iterated on in the next step
z = z[rem]
ix, iy = ix[rem], iy[rem]
c = c[rem]
return img
if __name__=='__main__':
from pylab import *
import time
start = time.time()
I = mandel(400, 400, 100, -2, .5, -1.25, 1.25)
print 'Time taken:', time.time()-start
I[I==0] = 101
img = imshow(I.T, origin='lower left')
img.write_png('mandel.png', noscale=True)
show()
George Monbiot has an interesting article linking capitalism and privatisation with growing prison populations:
This revolting trade in human lives creates a permanent incentive to lock people up; not because prison works; not because it makes us safer, but because it makes money. Privatisation appears to have locked this country into mass imprisonment.
It’s not clear to me that this is enough to explain the whole problem, but it’s worth considering.
Alderson has an interesting piece on religion over at Directionless Bones:
[Alderson's view] also implies a certain set of priorities, that changing people’s lives is more important than changing their minds (though obviously not unrelated), and that often religion will persist regardless of rational arguments if the conditions that produce it persist.
The Mathematics Genealogy Project has a huge database of mathematicians, showing who was supervised by whom, and what students everyone had. If you’re a mathematician, you can use this to trace back who your mathematical ancestors were and it can be quite fun. Below is a chart I made of my own mathematical genealogy. It’s nice to see exciting names from the history of mathematics and science there, such as Poisson, Laplace, Lagrange, d’Alembert, Euler, the Bernoullis, Leibniz, and Huygens (I stopped at that point). The dates are when they finished their doctorate, or if they didn’t do one, when they lived.

Reg article reporting on Nigel Inkster, former Assistant Chief of MI6:
There are limits to what we can sensibly aspire to…
Efforts to establish a global repository of counterterrorist information are unlikely ever to succeed. We need to be wary of rebuilding our world to deal with just one problem, one which might not be by any means the most serious we face.
…
We need to keep terrorism in some kind of context, for example, every year in the UK, more people die in road accidents than have been killed by terrorists in all of recorded history.
…
We should keep our nerve and our faith in our own values. Our own behaviour – especially with respect to the rule of law – is very important.
Filed under: Ethics, Morality, Philosophy, Politics | Tags: arationality, fascism, feelings, guilt, integration propaganda, psychology
I got the following criticism of my previous entry on arationality and honesty. Consider the case of car drivers. On any individual drive, there is a very small chance of causing a death that is not their fault (there’s also a much larger chance of causing a death that is their fault, but let’s leave that aside). Now, according to my theory, how is a car driver supposed to behave? In the two cases where (a) their drive doesn’t end up killing anyone, and (b) it does end up killing someone. The criticism is that the theory appears to say that in case (b) the person should feel bad and personally responsible, even though it was only random that it happened to them rather than someone else.
I have various responses to this. The first thing is to point out that the theory doesn’t tell people how they should feel, it speaks more to how they should act and more importantly how they should integrate actions and their consequences into their ongoing thinking. You can’t exert the same sort of conscious control over how you feel about something as you can over how you act and think about something. (That said, you can exert a less direct form of control over feelings and I’ll get back to that at the end of this entry.)
With that in mind, let’s first consider the decision before the drive: whether or not to take the drive knowing that there is a small chance of killing someone. It seems that the decision here is a straight up cost benefit analysis of whether the importance of making this journey by car rather than another form of transport outweighs the cost of killing someone multiplied by the probability of it happening. It’s already unlikely that most people think about it as clearly as this. More likely, they just think “it’s very unlikely” and drive whenever they want to. But even this level of analysis misses the full picture. As well as the external consequences of the action, you also have to bear in mind the internal consequences. You know that if you kill someone with your car you will feel guilty about it, even if it is not your fault. Most likely, that guilt will live with you the rest of your life. So there is a selfish component to the cost benefit analysis as well, which is to take account of how it will make you feel in both cases. Alright so where does this get us? Well, it is a demonstration of the method of not modelling ourselves as rational agents. Our own emotional reactions are a particular case (and not one I wanted to focus on in the previous entry) of our arational cores. We can understand these, and take them into account in our actions. Incidentally, doing so doesn’t make us any less human; we would still feel those emotions we would just better take account of them in our planning.
The next decision to analyse is the decision about what to do in the case that you have just accidentally killed someone with your car. Your feelings about it are a given (although see the last bit of this entry): guilt. The question is: what should your actions be and how do you integrate this into your ongoing thinking about the world? One reaction would be to reorganise your way of thinking so that the unavoidable feelings of guilt you would have would be suppressed or at least not contribute to your ongoing thinking. Another reaction would be to become permanently depressed about it. The former makes it possible to go on living your life relatively normally, at least outwardly, but would most likely completely change the nature of the way you relate to the world. For example, you might reorganise your thinking so that guilt feelings generally were suppressed. But what would the consequences of that be? The latter reaction, on the other hand, makes it difficult to go on living which doesn’t appear to be a valuable thing to do for anyone. A better option would perhaps be to accept the feelings you have but channel them into a positive activity (like becoming a road safety campaigner, or public transport proponent). This option can potentially be one that doesn’t involve becoming self-delusional, but does allow you to continue living your life. It’s not delusional because you accept responsibility for the consequences and you know that you are doing the campaigning work as a way to assuage your guilt, but it still helps you to go on living and has positive social effects.
The example of the car driver came up in a conversation about fascism and integration propaganda. I was arguing that if people take responsibility for their actions more, fascism couldn’t have happened. In other words, if people didn’t allow themselves to excuse themselves from fighting fascism for various reasons, and accepted responsibility for the consequences of it, it wouldn’t have happened because dictatorships require passive consent to continue functioning. Like the case of the car driver, there are three options when a fascist or dictatorial state is taking power: go along with it and rationalise it as the right thing to do; become depressed and inactive (which is essentially going along with it too); fight it, at possibly great cost to yourself. These are somewhat analogous to the three options the car driver above who has accidentally killed someone faces, and like in that case, the third option is the best.
So that about sums up my response to this criticism. I want to finish by saying a few words about psychology. I’ve made some pretty strong assumptions in this entry about the ways in which we can or can’t exert control over ourselves. I’ve assumed that we can exert control over the way we act, the way we think, and the way we integrate knowledge and events into our ongoing thinking, but that we can’t exert control over the way we feel. None of these assumptions are likely to be completely correct. For example, an addict cannot control their actions (or at least, that is one way of looking at it). And we know that we can affect the way we feel about things (although this process can take many years). Worse, in my previous entry I was advocating a theory that said we can’t make use of this sort of grammatical construct – “we can control the way we think” – because the “we” is the same object and so the verb “control” doesn’t have the usual semantics here. Indeed so, but despite that it feels as though by reading about and trying to understand the world, our modes of thought can be affected by ideas, and these ideas have greater or lesser effect when directed at certain parts of our thinking rather than others. An idea that tries to change the way we feel about things, it seems, is less likely to be effective than an idea that tries to change the way we reason about things at a more conscious level. This consideration may provide a way out of that difficulty.
Despite it being based on assumptions which are likely false, it still seems as though they might be true enough that the conclusions derived from them might be useful. Whether or not that is so is an empirical question, but at least to me it feels like there is something there worth considering.
Now I’ll end on a question.
If there were a pill you could take that would mean you would never again do a bad thing, would you take it?
In case anyone is interested, this year the most popular entries were:
- Make Google search in English
- Aubergine pasta sauce
- 28 points (about scrabble)
- Terrorism: Hysteria, Profit, Control
- Keeping your knife sharp
Top search terms that led people to my blog:
- cooking
- scrabble
- lol
- slave
- google search in english
So there you have it.