GiniSim is a simple Javascript program which demonstrates, in simple terms, flaws in free market economics, by showing that trading freely will lead to gross inequality. Copy the program into a .html file; save it and then open it in a browser: you can stop it by pressing the Stop button. Alternatively, you can download and run a simple Java version, GiniSim.jar from here.
Each bar is the wealth of a person, and the simulation starts with everyone having $10 (or £10, or 10€).
<!DOCTYPE html>
<html>
<body>
<button onclick="clearInterval(timer)">Stop</button>
<canvas id="myCanvas" width="800" height="600" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var timer;
var rects=0;
var cash=[0],people=[0];
var kStartCash=10;
var kNumPeople=100;
function initGini() {
var ix,iy;
for(ix=0;ix<kNumPeople;ix++) {
people[ix]=kStartCash; // everyone starts with $10.
for(iy=0;iy<kStartCash;iy++) {
cash[ix*kStartCash+iy]=ix; // each $1 is owned by a person.
}
}
}
function incomeSwap(from,too) {
var ix;
for(ix=0;ix<kNumPeople*kStartCash;ix++) {
if(cash[ix]==from)
cash[ix]=too;
else if(cash[ix]==too)
cash[ix]=from;
}
ix=people[from];
people[from]=people[too];
people[too]=ix;
}
function exchange() {
var aNote=Math.floor(Math.random()*kStartCash*kNumPeople);
var aOwner=cash[aNote];
var aNewNote=Math.floor(Math.random()*kStartCash*kNumPeople);
var aNewOwner=cash[aNewNote];
if(people[aOwner]>0 ) {
// can't take cash from people who have nothing.
//}while(aNewOwner==aOwner);
people[aOwner]-=1;
people[aNewOwner]+=1;
cash[aNote]=aNewOwner;
while(aOwner>0 && people[aOwner]<people[aOwner-1]) {
incomeSwap(aOwner,aOwner-1);
aOwner--;
if(aOwner==aNewOwner)
aNewOwner++;
}
while(aNewOwner<kNumPeople-1 && people[aNewOwner]>people[aNewOwner+1]) {
incomeSwap(aNewOwner,aNewOwner+1);
aNewOwner++;
}
}
}
function drawImage() {
var ix;
for(ix=0;ix<kNumPeople;ix++) {
ctx.fillStyle="#c0c0c0";
ctx.fillRect(ix*8,0,8,600-people[ix]);
ctx.fillStyle="#000000";
ctx.fillRect(ix*8,600-people[ix],8,600);
}
exchange();
}
initGini();
timer=setInterval(drawImage,1);
</script>
</body>
</html>
[Edit: Added link to GiniSim.jar on 20150321. Edit: I knew from the simulations that wealth always gravitates to the rich, but my reasoning for the mechanism was incorrect, because I was trying to derive it from the probabilities of a single transaction. In reality, the mechanism is due to how the probabilities change between one transaction and the next. 20150626.]
2 comments:
Very pretty program, but it's possible to make a redistribution such as said Levitico 25, each 49 years, in 50 year all properties come to original proprietors. Also the 1% are depending on government to make their business and to accelerate accumulation. Accumulation is realized more on countries in peripheral and by direct action political or indirect action by speculators. And other peripheral countries live in misery yet they work hard, but technology is voided for them.
I think that you must to include tendencies to diminish inequality in your model to make it more as reality, and to put the international actions that suck money in peripheral countries.
Excuse me for the critics.
regards
Hi Sobrevive,
Thanks for the comment. I understand what you mean by Levitico 25; in an English Bible it's Leviticus 25, which talks about the concept of "Jubilee", that debts are canceled every 50 years.
However, the purpose of GiniSim isn't to simulate a means of compensating for free market trends but to demonstrate what happens if you don't compensate for them, i.e. GiniSim is a refutation of "Trickle-down economics". GiniSim is a good demonstration in that sense, because it doesn't simulate greed (the players are not greedy), nor does it explicitly simulate a number of other classical economic ideas such as "price signals", or "market forces", or "marginal utility". By demonstrating that random trade leads to massive wealth inequality, GiniSim also demonstrates that the principle of "pricing signals" is no different to "random trade"; which is to argue that pricing signals do not exist.
Post a Comment