Fun with (Schelling) Segregation – with source!

[UPDATE May 2013] Welcome, readers from! It has been very interesting reading your discussion (admittedly, through Google translate) on the potential applications of the Schelling model. I was also interested in what you had to say about a combination of Schelling segregation and Conway’s Game of Life – I have an expanded version of that  that may be of interest to you as well. I made these simulations because of a free online course called ‘model thinking’, which is available at Thanks for the interest!]

This is a Schelling sim. hit ‘run’ to start it, play with the sliders to get interesting stuff coming out. Read on for an explanation of what’s happening.

[kml_flashembed publishmethod=”static” fversion=”11.0.0″ movie=”” width=”800″ height=”600″ targetclass=”flashmovie”]

Get Adobe Flash player


I’m still having a lot of fun taking online courses at Coursera. I’m taking ‘Networked life’, which goes over the general ideas of networks in various forms. One of the ideas they mention, and something that was also in “Model Thinking”, is “Schelling segregation.”

I can’t find a simple text explanation of it online, so here goes: imagine a world divided into a grid. Each grid cell can have either a red person, a yellow person or be empty.

A person could have  up to eight neighbours, and  each neighbour can be the same colour, or a different one:

If we say that people want to have more than 35% of their neighbours the same, then this would only affect the bottom-left yellow one. They’d pick a new space at random in the next round until everyone has found a spot where they’re happy.

The interesting thing that you see in this system is that the level of segregation that you get is always much higher than how picky the individual people are. If you have a system with people wanting 20% of their neighbours to be like them, the average person ends up with 40% like them, 40% gives you 80% segregation and upward until nobody ever ends up happy.

It’s an interesting way of looking at a pretty touchy issue, so when I heard about it I decided to code it up to see what it does. You can play with the result above. I’ve added some extra controls to it on top of how picky the people are: How dense the grid is, how many types of people there are, as well as the the number of neighbours a cell has. The standard model says that each person is connected to the eight people around them:

You could imagine expanding it so that a person checks neighbours two squares away:

That would make the check for happiness a lot more complicated – but I have expanded it so that a person might also be connected to people up to five squares away – so each person would be looking at over fifty others. There are some really interesting results when you do that.

First, people have to be more picky to make anything happen. It makes sense – the more neighbours, the more usual your neighbours will be. It’s interesting because this creates a kind of two-layered effect when the world evens out into more segregated areas – there are red-and-yellow, red-and-empty, and yellow-and-empty mixtures.

Another thing is that if everyone starts off too picky, nobody ends up happy and the world just kind of churns. What is interesting, though, is that if the population starts out as not picky, but gets pickier over time, then it can settle into a stable state. It seems like the shape of that stable state has something to do with the speed that the pickiness changes around.

The time it takes to stabilize has a lot to do with the population density. The fewer empty cells available, the harder it is for anything to settle down.

More different colours means more boundaries, and therefore more difficulty settling into a stable state.

These are awesome things to be able to observe, but I’d like to look into it more. At the moment everyone is the same level of picky. First, it would be interesting to see what happens when you either get a pickiness ‘map’, make the pickiness a result of the level of segregation in the last round. Second, it’s unrealistic to think of everyone as having the same level of choice in where they live. Altering the population over time would be cool too – either by adding people at random, or having very happy people ‘reproduce’. A degree of churn could be interesting to observe the effects of too.  If you decide to take this and run with it, let me know how it goes, it’s a fascinating model that has a lot of room for exploration!  Get the source for the Schelling segregation model here.