I had to present on path dependence recently. Paul David’s famous QWERTY paper (American Economic Review P&P, 1985) was covered, as was Paul Pierson’s Increasing Returns, Path Dependence, and the Study of Politics (American Political Science Review, 2000).

Both of these papers reference theĀ Polya urn model. This is a ball-and-urn process where, instead of simple replacement, there is replacement with addition of a ball of the same colour. This gives one colour a dominant position in the long run.

I coded a script to run Polya urn simulations. It’s in JavaScript, and easily adaptable. I tested it in Chrome.

[sourcecode language=”javascript”]
<html><body><script language="JavaScript">
///////////////////////////////////////////////////////////////////////////////////////////////

// Number of iterations
var runs = 400;

// Number of blue balls initially in urn
var num_blue = 1;

// Number of red balls initially in urn
var num_red = 1;

// Number of additional red/blue balls added after red/blue "wins"
var extra_extra = 1;

// Show which colour was picked etc
var details = true;

// Summarize the mean at the end
var mean_details = true;

///////////////////////////////////////////////////////////////////////////////////////////////

var initial_dist = num_red / (num_red + num_blue);
red_width = initial_dist*400;

// Graph initial distribution
document.write("Initial Distribution<br /><div style=’background-color:blue;height:10;width:400;’>");
document.write("<div style=’background-color:red;height:10;width:" + red_width +";’></div></div>");

// Random number
var r_n = 0;

var red_share = new Array();
red_share[0] = num_red / (num_red + num_blue);

for(i=1;i<runs;i++)
{

// Random number on unit interval
r_n = Math.random();

if (r_n > red_share[i-1])
{
num_blue = num_blue + extra_extra;
if(details){document.write("Blue.");}
}

if (r_n <= red_share[i-1])
{
num_red = num_red + 1;
if(details){document.write("Red.");}
}

red_share[i] = num_red / (num_red + num_blue);
if(details){document.write(" Red Share = " + num_red + "/(" + num_red + " + " + num_blue + ") = " +

red_share[i]);}

document.write("<div style=’background-color:blue;height:10;width:400;’>");
document.write("<div style=’background-color:red;height:10;width:" + red_share[i]*400 + ";></div>");
document.write("</div><div style=’background-color:white;height:5;width:400;’></div>");
}

var total = 0;
var mean = 0;
for(j=0;j<runs;j++)
{total = total+red_share[j]}
mean = total/runs;
if(mean_details){document.write("Mean of red share: " + mean);}
</script></body></html>
[/sourcecode]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top