Lessons taught; Lessons learnt

Maths, teaching and beyond.

Clumping and clustering

without comments

I've had a fun weekend playing with Processing and improving the clumping visualisation I posted earlier this week. The new version has been uploaded to OpenProcessing.org, a site which contains over 1000 visualisations, many of them containing beautiful and interesting mathematics:

A brief reminder of the situation: We have a grid of squares, of several different types. These squares are happy when they are surrounded by enough squares of the same type as them, and unhappy otherwise. We take two unhappy squares, swap them over, and repeat until bored!

There are two key parameters here: the number of different types of cell/person/house/whatever these squares are representing, and the happiness threshold: how many neighbours need to be the same as a cell for it to be happy.

Let's look at the types of behaviour that emerge for different values of the parameters:

A behaviour catalogue

Neighbours needed for happiness
2 3 4 5 6
Types 2
3
4
5
6

You find that it takes longer and longer for the state to settle down as you increase the number of types of cell. With 6 cells, and a happiness threshold of 4, for example, you can see from the table that it does eventually settle into a fairly stable clustered pattern, but it takes a very long time. After 50,000 swaps the grid looked like this:

clump-6-4-50k

Apart from the special case of two types, with happiness threshold five or six, the cells always seem to settle into a relatively small small clustered pattern (with small threshold), or to not stabilise at all (large threshold).

2 types; threshold 5: this is the case explored in the earlier post on this clustering behaviour. The cells cluster together fairly quickly, and then over the next 20,000 swaps or so the clusters join together into larger features, with the borders being long stretches of horizontal/vertical/diagonal lines.

2 types; threshold 6: this is perhaps even more interesting then the previous case. We do get some clustering, but the clusters don't hold together, but fray, and move around.

As with the previous post on this topic, I have wrapped left-right and top-bottom. This doesn't change the behaviour significantly. If you'd like to explore what happens without this wrapping, then go get the source code and dive in!

Emergent Behaviour.

This 'clumping' behaviour is just one of many examples of emergent behaviour, where small-scale local actions add up to a sometimes surprising global behaviour. Sometimes, as the old aphorism says, the whole is more than the sum of its parts.

One of the best known examples of this emergent behaviour is flocking, where groups of birds fly together in flocks that seem to require some collective intelligence, but are actually generated from purely local actions. This behaviour was modelled in Boids, a classic Artificial Life simulation from 1986. Here's an excellent 3D Boids simulation.

Related Posts (automatically generated)

  1. Clustering and seating plans
  2. Geogebra 3.2 beta: Now with animation

Written by Jon Ingram

April 12th, 2009 at 9:15 pm

Posted in Computing

Tagged with , ,

Leave a Reply