1Commit to a prediction
Imagine a village where every trader makes one good and wants one different good. There are 20 kinds of goods, and nobody uses money. Two traders who meet can trade only if each one has exactly what the other wants, a condition economists call a double coincidence of wants.
Out of 1,000 chance meetings between traders, how many do you expect to end in a successful trade? Record your estimate before running the model.
2Simulate barter and money
The model creates a large number of random meetings. In each meeting, both traders are assigned a good they make and a different good they want. Under barter, a trade succeeds only when each trader wants what the other makes. Under money, a trade succeeds whenever the second trader makes what the first trader wants, because the first trader can pay with money instead of goods.
Change the number of goods to see how the gap between the two systems grows as an economy becomes more specialized.
Loading the Python engine. This takes several seconds on the first visit.
Lines show the exact probabilities for every village size. The points show your simulation. The vertical axis uses a logarithmic scale, so each gridline is ten times the one below it.
3Reconcile the model with your prediction
Lock in a prediction in Step 1, then run the simulation with 20 goods to compare.
Why is barter so much harder than it seems?
A barter trade requires two separate matches at once. The other trader must make what you want, and must also want what you make. With 20 goods, the first match happens in about 1 meeting out of 20, and the second happens in only about 1 out of 19 of those. Multiplying the two gives roughly 1 successful meeting in 380. Money removes the second requirement, so only the first match matters.
What does the prices figure measure?
Without money, every pair of goods needs its own exchange rate, such as eggs per sack of grain or eggs per pair of shoes. With 20 goods there are 190 such pairs. When one good serves as a common measure, each good needs only one price stated in that measure, which is 19 prices. This role is called the unit of account, and it is one of the three classic functions of money, alongside the medium of exchange and the store of value.
Did barter economies actually exist?
Anthropologists have found little evidence of whole societies organized around face-to-face barter. Many communities relied instead on credit, gift obligations, and shared records of who owed what to whom. The simulation should therefore be read as a thought experiment that isolates one problem money solves. It is not a historical account of how money began, and the origin of money remains a subject of genuine scholarly debate.
4Judge what makes good money
If money solves the problem you just measured, then whatever serves as money must perform well at several tasks at once. Economists commonly describe six properties. Select a candidate, score it from 1 (poor) to 5 (excellent) on each property, and save your scores. Save at least two candidates to compare them on the chart.
5Inspect the code
Nothing on this page is hidden. The Python below is the exact code that produced your simulation results, running in your browser through Pyodide.