{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Economics Simulation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is a simulation of an economic marketplace in which there is a *population* of actors, each of which has a level of wealth. On each time step two actors (chosen by an *interaction function*) engage in a transaction that exchanges wealth between them (according to a *transaction function*). The idea is to understand the evolution of the population's wealth over time. I heard about the problem when I visited the Bard College Computer Science Department in 2008. *Update:* In 2017, a version posed by Uri Wilensky [became popular](http://www.decisionsciencenews.com/2017/06/19/counterintuitive-problem-everyone-room-keeps-giving-dollars-random-others-youll-never-guess-happens-next/). We cover his version [below](#Uri-Wilensky-Version).\n", "\n", "\n", "\n", "Why is this interesting? \n", "- It is an example of using simulation to model the world. The model is simple but captures some aspects of a complex world.\n", "- Many students will have preconceptions about how economies work that will be challenged by the results shown here.\n", "- It reveals subtle differences between computational thinking, mathematical thinking, and statistical thinking." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Population Distributions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will model a population as a list of `N` numbers, each number being one actor's wealth. We'll start with a Gaussian distribution (also known as a *normal* distribution or *bell-shaped curve*), with a mean wealth of 100 [simoleons](http://en.wiktionary.org/wiki/simoleon) and a standard deviation of 1/5 the mean:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import random\n", "\n", "N = 5000 # Default size of the population\n", "MU = 100. # Default mean of the population\n", "\n", "population = [random.gauss(mu=MU, sigma=MU/5) for _ in range(N)]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Population Statistics and Visualization\n", "\n", "How evenly is the wealth in a population distributed? The traditional measure is the [Gini coefficient](http://en.wikipedia.org/wiki/Gini_coefficient), which Wikipedia says is computed by this formula (which assumes the *y* values are sorted):\n", "\n", "\n", "\n", "A Gini index of 0 means total equality (everyone has the same amount), and values closer to 1 mean more inequality (most of the money in the hands of a few individuals). Here's a table of Gini coefficients for several countries:\n", "\n", "
Sweden | 0.250\n", " |
Canada | 0.326\n", " |
Switzerland | 0.337\n", " |
United States | 0.408\n", " |
Chile | 0.521\n", " |
South Africa | 0.631\n", " |