
Peter Norvig's Economic Simulation (2018) - ColinWright
https://github.com/norvig/pytudes/blob/master/ipynb/Economics.ipynb
======
Anderkent
I guess what I always find unconvincing about these kind of arguments is that
they require 0-sum trades, and real world trades are positive sum.

I think this is more of a gambling simulation than an economic one.

However, even with positive-sum games, the nature of the transaction can have
big impact on the wealth inequality. There's a great writeup on that in
[https://jasoncollins.blog/2020/01/22/ergodicity-
economics-a-...](https://jasoncollins.blog/2020/01/22/ergodicity-economics-a-
primer/)

~~~
sjg007
Some trades are zero. You exchange money for some good or consumable. For
example you buy food at a supermarket. If you were to bake a cake with that
food and sell it then it would be non-zero sum but not if you eat it.

~~~
snowwrestler
If there is no difference in value between the money and the food, then why
did you exchange the money for the food? Why not just keep your money and skip
the trip to the store?

Same with the store: why bother selling the food for money? If the value is
the same, why doesn’t the store just keep the food and save themselves the
trouble?

~~~
sjg007
The store buys low and sells high, that’s the value. The end consumer does
not... unless they are baking a cake to sell or something.

~~~
BlueTemplar
From another angle, why would the customer spend their time (which has value
to them) in a transaction where they don't get any?

~~~
vageli
> From another angle, why would the customer spend their time (which has value
> to them) in a transaction where they don't get any?

Well I for one always took issue with the rational consumer model. It is
possible that people trade things they value for things they don't, because
people do not always act rationally.

~~~
BlueTemplar
But we're talking about basic stuff here like buying bread...

~~~
rebuilder
Have you seen the variety of bread available, and the price range thereof? If
all of it is purchased on rational valuation grounds, I think we must end up
with a fairly loose definition of "value"

~~~
BlueTemplar
I'm sorry, but you still seem to be missing the point ? This isn't about bread
varieties either, I would assume that most bread is bought within an order of
magnitude of prices.

------
leto_ii
In case you find this interesting, there's an entire field dedicated to this
kind of models: [https://en.wikipedia.org/wiki/Agent-
based_computational_econ...](https://en.wikipedia.org/wiki/Agent-
based_computational_economics)

------
snowwrestler
An important take-away here is that larger personal economic buffers (the
percentage of their wealth each person does not need to transact regularly)
resulted in a lower final Gini coefficient. This matches our real-world
experience that growing savings is the path to financial stability, and real-
world data that forced saving functions (home ownership, social security)
improve average financial stability.

I would be interested to see death included in the model, as that is an
important and common way that pools of wealth get redistributed over the long
term in an economy.

~~~
maroonblazer
>I would be interested to see death included in the model, as that is an
important and common way that pools of wealth get redistributed over the long
term in an economy.

Only in the narrowest sense of 'redistributed' though, right? I.e. upon death
wealth typically transfers to kin, modulo whatever estate taxes apply for a
given country.

~~~
snowwrestler
Yeah, I mean just the basic inheritance tree—if there are 2 kids then each
gets half, and if each of them has kids then it gets further subdivided, plus
some heirs will spend down or lose money and have less to pass down...

~~~
xyzzyz
Each gets half, but typically their spouse also gets their half from their
parents.

------
zerr
Slightly off-topic: it was mentioned here earlier that the reason Norvig
switched to Python (from Lisp) was because of his job (Google). But in fact he
uses Python for most of his personal stuff as well.

~~~
Scaevolus
It's because Python more closely resembles pseudocode, making the examples in
_AI: A Modern Approach_ more accessible to readers.

[https://news.ycombinator.com/item?id=1803815](https://news.ycombinator.com/item?id=1803815)

~~~
fizixer
As a long time python user who recently got into s-exp languages (scheme to be
specific), I realized the differences between python and scheme are more than
just syntactic, in the following sense:

Programming in scheme forced me to think and code with a functional mindset.
Python never forced me like that, even though you could stick to a functional
subset of python (essentially forcing yourself).

I've also realized that a strictly functional mindset doesn't match well with
CS curriculum. Case in point, there is a textbook called purely functional
data structures, and I'm personally fully convinced that there is a whole
class of functional algorithms that I have not explored, and these look
nothing like the usual algorithms and data structures taught in a standard CS
curriculum.

I also believe that SICP doesn't even scratch the surface of this different
kind of thinking. SICP is small booklet of (dynamically typed) functional
programming 101.

So if your standard CS graduate doesn't have a bleep of an idea about how to
think with a functional mindset, and all of a sudden, has to program in a
language which practically forces you to do so, they're going to have a bad
time.

P.S.: You could develop an imperative framework on top of scheme (or lisp) and
move on with your life, never having to think functionally. But that's a whole
different story.

~~~
dehrmann
> I've also realized that a strictly functional mindset doesn't match well
> with CS curriculum. Case in point, there is a textbook called purely
> functional data structures, and I'm personally fully convinced that there is
> a whole class of functional algorithms that I have not explored, and these
> look nothing like the usual algorithms and data structures taught in a
> standard CS curriculum.

Schools are trying to strike a balance between theory and practice. A strictly
functional mindset is, for one, a pretty limited way of viewing computing, but
also disconnected from how CPUs actually work.

------
epiteton
Quick self-promo, you can run the simulation and play around with it (and the
rest of the repo) in Deepnote:
[https://beta.deepnote.org/launch?template=python_3.6&url=htt...](https://beta.deepnote.org/launch?template=python_3.6&url=https%3A%2F%2Fgithub.com%2Fnorvig%2Fpytudes%2Fblob%2Fmaster%2Fipynb%2FEconomics.ipynb)
(Disclaimer: I work there.)

------
ur-whale
MMmh ... there's no wealth creation function anywhere. Is Peter assuming that
economy is a zero-sum game?

Or is he assuming that the simulation is unaffected by working with normalized
numbers?

My gut says both assumptions need to at least be justified. I'd be happier to
see an actual wealth creation mechanism added.

Also, the final metric (Gini coefficient, aka the jealousy index), how much
does it actually to speak to individual's happiness? A rather controversial
choice: happiness is probably much correlated to absolute rather than relative
wealth, something Gini entirely fails to capture.

~~~
dagw
_happiness is probably much correlated to absolute rather than relative
wealth_

Studies show that it's much more complex than that. Basically both are always
a factor, but if you're below a certain level absolute wealth is the most
important factor, but once a above a certain level relative wealth
dominates[1]. The level where the switch over happens differs quite a bit
between countries and places, although most studies looking at salary seem to
put it in the $75k-$120k/year range for the US. All that being said most
studies also find that income/wealth (both absolute and relative) have
relatively small impact on overall happiness when compared to other factors.

[1]
[https://link.springer.com/article/10.1007/s11205-007-9217-0](https://link.springer.com/article/10.1007/s11205-007-9217-0)

------
NPMaxwell
What makes the increasing-Gini result confusing is ignoring variation. This is
done by thinking of the full distribution as if it were its average. In this
case, the pot is distributed using a pull from a uniform random distribution:
The assets of a pair are combined into a pot, and a number, s, from 0 to 1 is
drawn. One person gets s of the pot. The other gets 1 - s. On average, s = .5.
When s = .5, the Gini coefficient of the pair after the transaction is zero.
Their pair of assets are equal. As ABS(s) approaches 1.0, their inequality
becomes larger. For example, in Russian Roulette, s is either 0 or 1. With p =
the portion of the pot that came from one person, then, when ABS(s - 0.5) >
ABS(p - 0.5), the transaction increases inequality. When s is a constant 0.5,
every transaction will either reduce inequality or maintain the perfect
equality. The system increases inequality in the population until it matches
the inequality in the pool from which s is pulled. There's nothing surprising
there unless you make a simplifying assumption that s = 0.5, the average of
its distribution. Using this simulation to model economic systems comes down
to choosing a distribution for s: whatever you choose, that's what you get.
UNIFORM(0.49,0.51) will result in lots of equality. UNIFORM(-1,2) will produce
some people in debt to others.

------
universa1
The standing ovation problem is another nice and easily understood problem,
that allows a view into dynamics and the impact of structure on the results.
One can easily model that as an agent-based simulation and introduce all kinds
of stuff on top.

[https://www2.econ.iastate.edu/tesfatsi/StandingOvation.Mille...](https://www2.econ.iastate.edu/tesfatsi/StandingOvation.MillerPage.pdf)

------
oli5679
This is just modelling transfers. A lot of economics focusses on gains from
interaction/trade.

------
scottmsul
Real life wealth distributions have a very interesting property not shown
here. The "random give/take" always ends up with an exponential distribution,
which models real life for about the bottom 99% and doesn't have any really
high values or long tails. However the top 1% follows a power law in real
life, which does spread wealth across several orders of magnitude and has long
tails, and the transition is very sharp. Presumably this is because the top 1%
made their wealth in a way that is scalable, such as though starting
businesses, investing, etc. If you search papers in econophysics you can see
this effect.

------
k2enemy
This is interesting and a fun link between statistical mechanics and observed
income and wealth inequality.

But I think the statistics chosen to compare to the real world are a little
cherry picked? The wealth distribution matches, but in the simulation, I think
the identities of the wealthy change over time. The rich get poor, then rich
again, then poor again. Over an infinite time, everyone is in every wealth
percentile.

But an important political economic problem in the real world is that the rich
stay rich and the poor stay poor. So in that regard the simulation does a poor
job of explaining income and wealth inequality.

~~~
SkyMarshal
_> But an important political economic problem in the real world is that the
rich stay rich and the poor stay poor._

I’m not sure if this 100% true. The highly visible super rich like Bezos and
Gates and, say, the top 50 billionaires may stay rich, but the merely rich
like millionaires and low billionaires are more likely to have turnover in
their ranks. I recall seeing some data on this but forgot where. Will post if
I can find it.

~~~
kebman
I might be wrong, but IMHO the amount of billionaires don't really constitute
a big enough population to say something definitive about that claim. Clearly
the list of rich people isn't static. A billionaire might be shoved off the
list of billionaires and further down, for instance. Though certainly, the
chance of a billionaire becomming poor is most likely lower than a millionaire
becomming poor, though I'm sure this can be tested. But without a better
definition of "rich", then it really doesn't say much about social mobility or
economic equality, if that is what you're going after.

If you assume that the claim "the rich becomes richer" is true—which seems to
be the case in this simulation—then the thing to find out is probably, "why?"
and "what can be done to make a more fair distribution?" Given that this
system is even unfair that is. As I see it, this is clearly up for discussion
(i.e. whether what is basically Capitalism is unfair), though the simulation
does not take it up explicitly, and instead merely hinting to that with such a
system, the rich would necessarily become richer, and the poor poorer.

I mean, who said economic equality is even a goal? Do not those who make life
better for others, also deserve a good life themselves? And if you _don 't_
make life better for others, you obviously still deserve to live, but do you
deserve as much comfort and self-determination (in terms of economic wealth)
as those who manage to offer more?

~~~
BlueTemplar
Huge economic inequality breeds resentment and a bad society for everyone to
live in. Not to mention the risk of a bloody revolution if the poorest people
end up with not enough food.

~~~
xyzzyz
Huge inequality of consumption breeds resentment, yes. Fortunately, in the US,
inequality of consumption is much, much, much smaller than inequality of
income or wealth.

~~~
BlueTemplar
I wouldn't say that this is true for such "middle-class" "consumption"
categories like college and healthcare ?

------
tasubotadas
That's amazing. I've always wanted to do something similar but I had a much
more complicated simulation in mind. Apparently, you can get some interesting
insights even with such a rough approximation.

I would be very interested to see, how the "connectivity" and information
would affect transactions. For example, I am more inclined to buy from Apple
because Apple is a well-known company and my friends bought from there. The
more you are known, the more transactions you can expect to make.

~~~
qubex
This doesn’t model B2C-type asymmetrical situations, but pure P2P-type
symmetrical situations.

An easier first step for the interested beginner would be modelling
_visibility_ as a kind of dynamic network. That leads to interesting
considerations about imperfect information and agents’ profit-maximisation
under such conditions.

(Economist here.)

~~~
tasubotadas
What's visibility?

------
rodolphoarruda
> "Many students will have preconceptions about how economies work that will
> be challenged by the results shown here."

I wonder what those preconceptions might be.

------
sudoaza
I doubt wealth is exchanged 1 on 1 so clearly, there is lot of wealth
accumulated in assets that change price for example. Or the commons, a limited
wealth up for grabs at the expense of everyone else.

~~~
nabla9
Hypothesis does not rely on wealth exchanged 1 on 1. The idea of modelling is
to capture essential features.

This model looks at the case where everything is fair and everybody is equal.
In the sense it's the best possible world scenario and it demonstrates that
inequality builds up even if no player is better than other.

------
BlueTemplar
Another fascinating aspect of simulations like these is how the shape of the
final distribution depends on the _number_ of actors - with links to
statistical thermodynamics.

------
G8WyaX
Previous (2016):
[https://news.ycombinator.com/item?id=10962026](https://news.ycombinator.com/item?id=10962026)

------
jpttsn
Smh.

I’ve modelled the economy too. For simplicity, I model every actor as a pool
ball on a pool table. Collisions are transactions.

While simple, my model really challenged some preconceived notions about how
the economy works.

------
jpiabrantes
Captain Obvious: real world transactions don’t look anything like this.

~~~
empiricus
How would you better model real world transaction?

~~~
ploika
To be fair, the answer to that question is probably someone's PhD thesis.

~~~
empiricus
Quite possible, but he started with "Captain Obvious" so I hoped that meant he
knows other models that are obviously better.

~~~
randallsquared
Even if they do know other economic simulations which are better, it isn't a
given that a better tool exists for every tool that doesn't ideally meet a
need. Of course, you did say "hoped" instead of "expected"...

------
dang
Anyone know the original year?

~~~
pvg
Last tweaked in 2018, explicitly talks about being based on a 2017 variant of
the simulation.

~~~
dang
Ok, let's go with 2018 for now. Thanks!

