---
title: Models of self-organizing inequality
author: 36-313, Fall 2022
date: 29 November 2021 (Lecture 23)
output:
  pdf_document:
    toc: true
    toc_depth: 4
    number_sections: true
bibliography: locusts.bib
---

```{r, include=FALSE}
library(knitr)
opts_chunk$set(size="small",background="white", highlight=FALSE,
               cache=TRUE, autodep=TRUE, cache.comments=FALSE,
               tidy=TRUE, warning=FALSE, message=FALSE,
               echo=FALSE)
```


\newcommand{\Expect}[1]{\mathbb{E}\left[ #1 \right]}
\newcommand{\Var}[1]{\mathrm{Var}\left[ #1 \right]}

\clearpage

- Some things we've seen over and over:
    + There is a lot of inequality!  Income, wealth, health, lifespan, exposure to crime...
    + There are big differences in all these variables across major social categories
    + There are also big inequalities _within_ major social categories
    + The size of between-group and within-group inequalities change over time, but their directions are more stable, and the fact of large inequalities is more stable yet
- What might help explain these larger patterns?
    + Very basic probability models of income and wealth inequality predict a lot of patterns we see
    + Making those models a little more complex has big implications for the persistence of both between- and within- group inequality
    + Other models, based on social learning, show how between-group inequalities can be perpetuated without prejudice or bias, and even how they can arise without prejudice or bias
	
\clearpage
	
# Multiplicative Growth and Its Implications

## Multiplicative Growth Implies Heavy Tails

- Suppose person $i$ in year $t$ earns income $Y_i(t)$.
  + The same ideas will work for wealth
- We can express the change over time as $Y_i(t) = G_i(t) Y_i(t-1)$ where $G_i(t)$ is the factor by which income grew, or shrank, over the year
- So $Y_i(t) = Y_i(0) \prod_{s=1}^{t}{G_i(s)}$
- It makes sense to treat the $G$s as random variables, so we can ask what
  distribution this leads to
- Distributions of products are ugly, so let's see if taking a log doesn't help:
\[
\log{Y_i(t)} = \log{Y_i(0)} + \sum_{s=1}^{t}{\log{G_i(s)}}
\]
- Now _assume_ that the $G$s are statistically independent over time, so the $\log{G}$s are too, and that $\Expect{\log{G}} = \mu$, $\Var{\log{G}} = \sigma^2$
- Remember the central limit theorem: if $X_i$ are IID with common mean $\mu$ and variance $\sigma^2$, then
\[
\frac{1}{n} \sum_{i=1}^{n}{X_i} \rightsquigarrow \mathcal{N}(\mu, \sigma^2/n)
\]
    + If you are the kind of purist who wants to make the denominator on the left $\sqrt{n}$ so the right-hand side is $\mathcal{N}(\mu, \sigma^2)$, you can make the correction on your own
    + Multiplying both sides by $n$, and remembering what doing so does to the mean and variance, we can say that, for large $n$,
\[
\sum_{i=1}^{n}{X_i} \approx \mathcal{N}(n\mu, n\sigma^2)
\]
     + So, applied here,
 \[
 \log{Y_i(t)} \approx \log{Y_i(0)} + \mathcal{N}(t\mu, t\sigma^2)
 \]
- This means that $Y_i(t)$ should have an approximately log-normal distribution!
- Illustration: Suppose $G_i(t)$ is independent across $i$ and $t$, and uniformly distributed on the interval $[0.9, 1.15]$ (to give a slight positive bias).  Say $Y_i(0) = 4\times{10}^4$ with probability 1, just to keep things simple.  See Figure 1.
    + The black lines show the (approximate) densities when I simulate a population
of 1000 individuals whose incomes evolve on this process.  The
blue lines show the closest-fitting log-normals.  You can see that initially
the match is very bad, because a uniform distribution and a log-normal are very different, but after 10 steps the match is excellent.

```{r, echo=FALSE}
yi0 <- rep(4e4, times=1000)
yi1 <- yi0 * runif(n=length(yi0), min=0.9, max=1.15)
yi2 <- yi1 * runif(n=length(yi0), min=0.9, max=1.15)
yi10 <- yi2
for (t in 3:10) {
    yi10 <- yi10 * runif(n=length(yi0), min=0.9, max=1.15)
}    
```

```{r, echo=FALSE}
plot(density(yi1), lty=3, xlim=c(0, max(yi10)), ylim=c(0,1.3e-4),
     main="Figure 1", xlab="Income", sub="")
curve(dlnorm(x, meanlog=mean(log(yi1)), sdlog=sd(log(yi1))),
      add=TRUE, col="blue", lty=3)
lines(density(yi2), lty=2)
curve(dlnorm(x, meanlog=mean(log(yi2)), sdlog=sd(log(yi2))),
      add=TRUE, col="blue", lty=2)
lines(density(yi10), lty=1)
curve(dlnorm(x, meanlog=mean(log(yi10)), sdlog=sd(log(yi10))),
      add=TRUE, col="blue", lty=1)
legend("topleft", legend=c(expression(t==1),
                           expression(t==2),
                           expression(t==10)),
       lty=c(3,2,1))
```


- We saw that the bulk of the distribution of income and wealth is log-normal,
  across many countries and many decades.  This basic argument suggests that
  this is what we'd expect out of multiplicative growth.  But _that_ means that
  right-skewed and heavy-tailed distributions are going to be hard to avoid,
  _unless_ we can somehow make sure income and wealth do not grow
  multiplicatively[^taxes].
- We also saw that income and wealth distributions have right tails which are
  too heavy for log-normals; they are, at least very roughly, more like power
  law or Pareto distributions.  How could we explain that?
- One possibility: income growth is _faster_ for higher incomes, at least some
  of the time [@Montroll-Shlesinger-on-1-over-f-noise]

[^taxes]: Taxation is, in principle, one way to do this, though the tax rates would have to increase very rapidly with income levels.

## Refinements

- Seemingly-small differences in average growth rates quickly accumulate into
  big differences in outcomes
     + This is the power-of-compound-interest lesson again
	 + Illustrative example: if $Y(0) = 4\times {10}^4$ and $G(t)$ averages $1.03$ for 20 years, $Y(20) = `r signif(4e4*(1.03)^20, 3)`$, but if $G(t)$ averages $1.06$, $Y(20) = `r signif(4e4*(1.06)^20,3)`$
	 + Of course it helps to start out well: if $G(t)$ averages $1.03$ but $Y(0)=5\times{10}^4$ instead of $4\times{10}^4$, we're looking at $Y(20) = `r signif(5e4*(1.03)^20, 3)`$.
- Some of the transmission of inequality across generations is families trying to equip their children with high $Y(0)$, and some of it is trying to increase the expected value of $G(t)$.
- If belonging to group A rather than group B raises average growth rates, even a modest number of steps can see a big difference in typical outcomes, and _especially_ in which group is represented at the top of the income distribution
    + More subtly, if group A and group B have the same average growth rates _and_ the same starting values, but group A has higher variance of growth, we'll see more of it in the highest percentiles of the income distribution
      * We'd also see more of group A in the lowest percentiles, but the simple multiplicative growth model will break down there (at least for income)

\clearpage

# Mobility and Transmission of Inequality

- We've seen that rates of economic mobility are not very high
    + E.g., probability that a child born in the bottom 20% of the income distribution around 1980 will be in the top 20% as an adult is about 8% in the US (see homework 7)
	
## Multiplicative Growth and Social Mobility

Let's consider the relative income (or wealth, etc.) of two individuals:

\begin{eqnarray}
Y_i(t) & = & Y_i(0) \prod_{s=1}^{t}{G_i(s)}\\
Y_j(t) & = & Y_j(0) \prod_{s=1}^{t}{G_j(s)}\\
\frac{Y_i(t)}{Y_j(t)} & = & \frac{Y_i(0)}{Y_j(0)}\prod_{s=1}^{t}{\frac{G_i(s)}{G_j(s)}}
\end{eqnarray}

Suppose $Y_i(0) < Y_j(0)$, so that $i$ starts out worse-off than $j$.  For
their relative standings to be reversed at some later time, $Y_i(t) > Y_j(t)$,
we need $\prod_{s=1}^{t}{\frac{G_i(s)}{G_j(s)}} > 1$.  In words, this means
that the initially-poorer individual needs to grow _faster_ than the
initially-richer one.  (How much faster depends on the ratio of initial
incomes.)  If everyone grows at exactly the same rate, $G_i(t)=G_j(t)$ for all
$t$, then this can't happen and the ratio of incomes is static.  For their to
be relative mobility, then we need either a _negative_ correlation between current income $Y_i(t)$ and growth factors $G_i(t+1)$, _or_ we need $G_i(t)$ to
vary randomly _across individuals_ $i$, and not just randomly over times
$t$.

To get a concrete sense of this, we'll consider a situation where $Y_i(0) = 2\times {10}^4$ and $Y_j(0) = 6 \times {10}^4$.  As in the earlier demo,
$G$ will be uniform on $[0.9, 1.15]$, independently across people and across
time.  I'll show _one_ trajectory for $Y_j$, but a whole bunch of trajectories
for $Y_i$.

```{r, fig.cap=paste("Relative economic mobillity under multiplicative growth.  Incomes grow at an average rate of ", signif(100*(mean(c(0.9, 1.15))-1),2), "% per time period, but with a standard deviation of ", signif(100*sqrt((1.15-0.9)^2/12), 2), "% per time period.  The figure shows one trajectory starting from a high income, and a large number of trajectories starting from a lower income.  _Some_ of the latter are able to catch up with the former, but it's not what usually happens.", sep="")}
t <- 20
g.min <- 0.9
g.max <- 1.15
g.joey <- runif(n=t, min=g.min, max=g.max)
y.joey <- cumprod(c(6e4, g.joey))
y.irenes <- replicate(1000, cumprod(c(2e4, runif(n=t, min=g.min, max=g.max))))
plot(x=0:t, y=y.joey, ylim=c(0, max(cbind(y.irenes, y.joey))),
     xlab="t", ylab="Y", type="l")
for (sim.run in 1:ncol(y.irenes)) {
    lines(x=0:t, y=y.irenes[,sim.run], col="lightblue", lwd=0.1)
}    
```

Here you can see that _some_ of the $Y_i$ trajectories overtake the $Y_j$
trajectory, but not many (here, just `r 100*mean(y.irenes[t,] > y.joey[t])`% of
them do so).  If you play with the parameters of the simulation, you can see
what happens to this probability; in particular, you can convince yourself that
it goes up if you increase $\Var{\log{G}}$ while leaving $\Expect{\log{G}}$
alone.

\clearpage

## Transmission of Individual Inequality Implies Persistent Inter-group Inequalities

Suppose (i) in one generation, members of group A tend to be higher in the income distribution than members of group B, (ii) relative inter-generational economic mobility is low, and (iii) (most) children belong to the same group as their parents.  Then _even if_ inter-generational economic mobility is the _same_ for both groups, in the next generation group A will still be better off than group B

- A simple calculation: suppose there are just two economic levels, and the probability of being in the same level as your parents is 80%.  Group A starts off as 2/3 better-off, 1/3 worse-off and group B starts off as 1/3 better-off, 2/3 worse-off.  Figure 2 shows what happens in this case.  You can see that _eventually_ the two groups will equalize their economic distributions, but that this takes many generations.  Even after 4 generations the disparity between the groups is considerable.
    + You can play around with the precise numbers in the code to convince yourself that the general phenomenon is pretty robust.
    + In more technical terms (take 36-410 or 36-467), the assumption of equal economic mobility in both groups means that economic status follows a Markov chain, and a general theorem about Markov chains with a finite number of states is that they converge to a unique[^markovquibble] distribution which is "invariant", i.e., doesn't change over time.  So under this assumption, the economic distributions of groups A and B will converge to the same limit, and so converge on each other.  But the time needed for this depends on how rapidly "mixing" the Markov chain is, and the assumption of low economic mobility implies slow mixing.

```{r}
sim.binary.mobility <- function(n, T, p0, stay=0.8) {
    history <- vector(length=T)
    population <- rbinom(n=n, size=1, prob=p0)
    history[1] <- mean(population)
    for (t in 2:T) {
        population <- ifelse(rbinom(n=n, size=1, prob=stay),
                             population,
                             1-population)
        history[t] <- mean(population)
    }        
    return(history)
}    
```

```{r}
A.history <- sim.binary.mobility(n=1000, T=10, p0=2/3, stay=0.8)
B.history <- sim.binary.mobility(n=1000, T=10, p0=1/3, stay=0.8)
```

```{r, fig.cap="If two sub-populations start with different distributions over economic positions, but thereafter have the same rates of relative economic mobility, they will eventually converge on the same distribution, but large disparities can persist for generations."}
plot(A.history, xlab="Generations", ylab="Fraction in upper economic bracket",
     ylim=c(0,1), col="blue", type="l", main="")
lines(B.history, col="red")
legend("topright", legend=c("A", "B"), lty="solid",
       col=c("blue", "red"))
```


[^markovquibble]: If you know enough to quibble here about different ergodic components, you also know enough to see that the state space for this kind of model is necessarily a single irreducible set and that the transition matrix is aperiodic.


Here is the moral of this calculation:

> Once a categorical inequality forms, if individuals' relative mobility is low, and membership in the categories is inherited, then the inequality can persist for a long time, _even if_ there is no discrimination or prejudice


If poverty has other bad consequences (ill health, exposure to crime, being treated badly by the police, etc.), the distribution of those consequences would also be different between groups as well, again, even without discrimination and prejudice.

It's important to the argument that group membership is inherited.  So this
works better for categories like race, ethnicity or religion than it does for
sex.

A not-at-all-random application: the US civil rights acts were passed in the 1960s, i.e., two generations ago.  Even if those laws had completely eliminated all forms of racial discrimination, we would still expect to see very large economic disparities between races in the 2020s.  Of course, the civil rights acts did not eliminate all forms of racial discrimination and prejudice.  Also of course: whether it's acceptable to just (!) eliminate discrimination and let social mobility work to slowly reduce inequalities is an ethical and political value-judgment, not a scientific proposition.  But it in making that judgment, it can be _helpful_ to know what we'd see in a non-discrimintion-but-nothing-else world, and how close (or far) the actual world is to that baseline.


Remember this is about _relative_ mobility, rank in the distribution, not absolute mobility --- both groups could be better off in absolute terms over time (or worse off...)  If the worse-off group, B, is to catch up to the better-off group, A, in _absolute_ terms, it needs _higher_ rates of income growth than group A.



I _think_ a lot of what our friends in the humanities and some of the social
sciences call "systemic" or "structural" inequality is a way of talking about
this mechanism, of persistent, inter-generational inequality, or ones very like
it.  (But I have to admit I am often not sure what exactly, some of them are
trying to get at.)


\clearpage


# Schelling, and the unraveling of integration

- @Schelling-introduces-segregation-model introduced a now-classic model which he intended to illustrate a point about how difficult it can be to _maintain_ equality, and how the outcomes people produce may be very different from the outcomes they _want_.
    + Two types of people, say A and B
	+ Everyone lives on a square lattice (large checker-board or chess-board)
	+ Everyone is perfectly happy with neighbors of the opposite type...
	+ ... but not comfortable being in a small minority
	+ Specifically, if the fraction of your neighbors who are of the same type as you is $< p$, move to a random un-occupied square, otherwise stay put
        * The classic version defines "neighbors" has the 8 squares on the cardinal directions and diagonals
	+ If you start with a random scatter of As and Bs, most people are initially fine with the neighborhood...
	+ ... but some people are uncomfortable because they're the only B in a block of As (or vice versa)
	+ Key point: every time a B moves because there were too many As around, their old neighborhood is now _even more_ A-predominant...
	     * And their new neighborhood has even more Bs...
	+ ... which can induce _others_ to move
        * more Bs will leave the first B's old neighborhood, As will leave from the new neighborhood
	+ Result: integrated patterns unravel, and we get big homogeneous blobs where almost everyone is of the same type
	    * The fraction of neighbors of the same type isn't $\approx p$ but much larger than $p$
- Schelling's point is that it's hard to maintain integration, unless (i) the initial configuration is _very_ carefully engineered, or (ii) you can persuade everyone to be OK with being in a small minority (very low $p$), or (iii) people are not free to move as they like
    + The government of Singapore has pursued option (iii)
	+ It's very hard, legally, to pursue option (iii) in the US; see the discussion of the Starrett City development in New York, which tried, in @RTFord-race-card, ch. 4, pp. 285--294.
- Schelling, not being an idiot or an apologist, was quite clear that the two main reasons why the US was racially segregated in 1971 were a long history of active efforts to _make_ it segregated, and the economic inequality which priced blacks out of good neighborhoods.  He described his model as one of a "third order" effect, behind these.  But the model _does_ show that just eliminating active segregationist efforts, and even eliminating racial economic inequality, would not necessarily lead to integration.  It also illustrates how the collective outcome of individuals' choices can be very different from what any of the individuals want!

	

\clearpage

# Unequal institutions

There are many situations involving the division of labor, gains from
cooperation, etc., where everyone benefits if there is _some_ recognized rule
or convention, rather than having to re-negotiate everything from scratch every
time.  (Imagine something as simple as roommates dividing up the work of
cleaning their apartment.)  These conventions or rules are examples of what are
called **social institutions**, or just **institutions**.
Here are some examples of institutions (in this sense):

- Everyone drives on the right
- The "Pittsburgh left": when a traffic light turns green, cars turning left have right-of-way over those going straight.  This is 100% illegal (according to Pennsylvania's traffic code), but it is, or was, a commonly-recognized rule around here
- Greeting acquaintances with hand-shakes, or bows, or kisses on the cheek.
- The grammar and vocabulary of a language.

An institution can often be thought of as a solution to a social problem ("how
can we drive multi-ton machines at high speed through cities without killing
ourselves or each other?").  That being said, there are usually _many_ possible
institutions for any particular situation, many solutions to the same problem,
which would all be better than sheer disorder.  Often, some of these possible
institutions are much better for one party than others.  (Imagine that one
roommate has to take out the trash once a week, but the other roommate has to
cook, clean the kitchen, and scrub the bathroom.)

- We could equally well all drive on the left, and many countries do.  (This doesn't seem to advantage or disadvantage anyone particularly.)
- _Do_ you greet an acquaintance with a hand-shake, or by bowing, or by kissing them on the cheek?
    + Even if you don't care _which_ of these, you do want to do the same thing as those around you, to avoid awkwardness and/or looking like a barbarian and/or embarrassing misunderstandings.
- _Which_ language are you using?  There are very real and obvious advantages
  to _sharing_ a language with those around you.  There are also very real and
  obvious advantages to a firm, school or government office picking _a_
  language to do business in, which gives an advantage to those who are already
  good with that language.
    + This is why disagreements about language are often at the core of nationalist disputes, why nationalist movements often begin by creating a standardized literary language that can be used in in education, government and business, etc. [@Gellner-nations].
- If you accept a job with a one-year contract, are you free to quit before the
  year is out?  Can your boss fire you before the end of the year?  It might
  seem obvious, to modern Americans, that the answer to both questions is
  "yes", but this is one of our taken-for-granted institutions.  Historically,
  even in England as late as 1875, workers who quit could be sued or even prosecuted as criminals [@Naidu-Yuchtman-coercive-labor].  While there might be outlandish scenarios where this constraint somehow helped
  workers, historically they thought it was very much against their interests
  and struggled, successfully, to get rid of it (and employers, for their part,
  agreed that benefited them at workers' expense).  At the other extreme one
  can imagine institutions under which an employer who agrees to hire you for a
  year has committed to paying you for the full year no matter what.
  
All of this raises three puzzles:

1. How do institutions form?
2. When there are multiple possible institutions, _which_ institutions form?
3. When some possible institutions benefit some groups rather than others, who wins?

It turns out that institutions can self-organize even when individual agents
follow very simple learning rules.  In particular, rules that amount to
versions of "do more of what worked for you and less of what didn't"
(individual learning), or "copy those who did better than average" (social
learning) can do the job, and the precise details often don't matter much.

Simple learning rules like this often lead to situations where (almost)
everyone acts the same way, or everyone in the same group acts similarly and
this meshes with the actions of other groups.  Optimistically, this offers some
hope that society will self-organize _some_ kind of solution to coordination
problems.  Pessimistically, it will not necessarily self-organize to a very
_equal_ solution.  In particular, plausible models of social learning are
typically ones where already-advantaged groups have an edge in struggling over
which institution to use, further entrenching their advantages.

Once an institutional convention forms, it tends to be very persistent and
"sticky", because nobody benefits from being the _only_ one pushing against the
institution.  Institutions _can_ change when objective conditions change.
Institutions can also change if enough people are stubborn and/or don't care
about the (short-term) consequences (collective action), or through random
drift.  But institutions once formed can be powerfully self-sustaining, even if
_everyone_ would be better off switching to an alternative.

The last few paragraphs have made a lot of assertions without backing them up;
the rest of this section will try to provide some substantiation.

## Game theory: a crash course

Decision theory is about evaluating strategies for taking action in the face of
_random_ uncertainty.  It's an important part of statistics (some argue _the_
core idea of statistics).  It has an extension to dealing with situations where
the decision-maker isn't just facing some unknown, more-or-less random
situation, but rather _another_ decision-maker.  That extension is known as
"game theory".

- Two (or more) players or **agents**
- Each agent picks an action (or "move"), and gets a payoff that depends on their action and those of all other players
  + Simple cases: all agents have the same discrete set of actions available
     * Square payoff matrices showing the payoff that each agent gets
  + Continuous actions, distinct action sets for different agents, etc., all possible
  + You can imagine multiple rounds of games where agents respond to each others' previous moves, etc.
      * Reduces to the "one-shot" case by considering _strategies_ rather than _moves_
- "Payoff" can be monetary, utility, number of offspring (in evolutionary applications, etc.)
- An **equilibrium**[^equilibrium] is a situation where no agent benefits from being the _only one_ to change their action[^nash].

[^equilibrium]: The word "equilibrium" is used in a number of distinct-but-related ways in economics.  I am about to define a **pure-strategy Nash equilibrium**.  "Equilibrium" has even more distinct meanings in other fields, such as physics.  @Economy-as-evolving-complex-1 offers some classic accounts of social and natural scientists misunderstanding each other because (in part) of the slipperiness of this word.

[^nash]: In symbols, an assignment of actions to agents, $a=(a_1, a_2, \ldots a_n)$, is a (pure-strategy Nash) equilibrium when no agent can increase their payoff by changing _only_ their action.  Writing $r_i(b_1, b_2, \ldots b_{i-1}, b_i, b_{i+1}, \ldots b_n)$ for the payoff to agent $i$ when agents take actions $b_1, \ldots b_n$, $a$ is a Nash equilibrium when $r_i(a) \geq r_i(a_1, \ldots a_{i-1}, b, a_{i+1}, \ldots a_n)$, for all agents $i$ and for all alternative actions $b$.  (Some people strength this to $>$ rather than $\geq$, others distinguish ordinary from "strict" equilibria.)  --- A **mixed-strategy** Nash equilibrium, incidentally, is an assignment of _probabilities_ of actions to agents where no one can increase their _expected_ payoff unilaterally.

### The Prisonners' Dilemma

As a classic example, here's the prisoners' dilemma[^pdparable]:

|    | C     | D     |
|----|-------|-------|
| C  | (2,2) | (0, 3)|
| D  | (3,0) | (1,1) |

If both the row and the column player make the move "C", they both get 2.  If
the row player makes the move C but the column player makes the move D, the row
player gets 0 and the column player get 3, and vice versa.  If the both play D,
they each get 1.  Clearly, both players are better off if they can somehow
cooperate to both play C, rather than to both play D.  But if you know that the
other player will play C, you can improve your own pay-off by switching to D.
If on the other hand you know the other player will play D, then to protect
yourself you must play D as well.  The two letters C and D stand for
"cooperate" and "defect", and we have just reasoned ourselves into concluding
that defection is the equilibrium, and in fact the _only_ equilibrium.

[^pdparable]: The standard parable, which goes back to the 1950s and is the origin of the name, runs as follows.  Alice and Bob are political dissidents who have both been brought in by the police for questioning.  If both of them keep their mouths shut (C,C), the police have no other evidence against them and have to let them go.  (This parable was invented by Americans with very little experience of secret police.)  If one of them informs on the other (D,C), the informer (D) gets a reward while the one informed against (C) receives an especially harsh punishment as an example.  Finally, if they both turn informer (D,D), they both receive merely ordinary punishment.  Here is an alternative parable: Ashoka and Babur are two bandits.  If they team up, they can combine their forces to attack caravans and steal valuable loot, which they could split equally (C,C).  Or one of them (D) could turn on the other (C) _after_ the attack, taking all the loot for himself.  Or they could both refuse to cooperate (D,D), and have to content themselves with small-scale mugging in back alleys.

The prisoners' dilemma is a very simple game, but it encodes a _lot_ of what
makes social cooperation difficult to create and sustain.  A great deal of
ingenuity has gone into trying to figure out how, despite the all-defect
equilibrium, cooperation can evolve and persist in the prisoners' dilemma, an
effort which has yield a lot of insight into important parts of biology,
economics and philosophy.  (See further reading.) If this was a different kind
of course we could devote months to it.  Instead, we're going to focus on a
different kind of game.


  

### A coordination game

The prisoners' dilemma has _one_ type of agent.  We'll now start to worry about
situations where we divide up the whole collection of agents into discrete,
distinct social groups; I will call these by colors, such as blue, red, etc.
But we also have a distribution of types of agents within each group.  This
makes "the population" ambiguous.  To avoid ambiguity, each group will be a
"population" of agents, and the complete collection of all agents of all groups
will be an "assemblage"[^delanda].

[^delanda]: I am borrowing "assemblage" from @DeLanda-on-society, but I am not altogether sure I'm use the term in quite the way he would.

Here's an example pay-off matrix for a game with two types of players,
red and blue, and two actions.

|                   | Red makes move A | B     |
|-------------------|------------------|-------|
| Blue makes move A | (4,1)            | (0,0) |
| B                 | (0,0)            | (2,2) |

The first number in each cell shows the pay-off to the row player (blue), the
second the pay-off to the column player (red).

This is a **coordination game** --- the two players benefit by doing the same
thing; the (A,A) and (B,B) outcomes are better for everyone than the (A,B) or
(B,A) outcomes.  (This is unlike the prisoners' dilemma.)  It's also a game
with multiple equilibria: both (A,A) and (B,B) are equilibria.  (Check this!)
But the two types of agents don't benefit equally from the two equilibria.
Clearly, the (A,A) equilibrium is much better for blue agents than the (B,B)
equilibrium, while the red agents have the opposite preferences[^rescaling].

[^rescaling]: I have made the payoffs for red and blue agents equal at the (B,B) equilibrium, but that's a bit artificial.  If I divided all the blue payoffs, but not the red, by a factor of 4, then (A,A) would look egalitarian, with payoffs (1,1), and (B,B) would look biased in favor of reds, (0.5, 2).  But you should ask yourself, as we go along, whether there's any way you could _detect_ this, without directly observing the payoffs themselves.

We'll analyze this little coordination game pretty thoroughly, because these
features --- a shared interest in reaching agreement, multiple equilibria with
different agreements, and conflicting preferences over equilibria --- make it a
clarifying model for struggles over institutions.

## Classical game theory

Classical game theory analyzes the interaction of **strategies**, which are
rules saying which move to make as a function of the other players' previous
moves, your previous moves, and perhaps some external signals.  The usual
approach is very "forward looking", where agents are supposed to try to
maximize their future payoffs given presently available information, taking
into account that the other agents are doing likewise.

This is a mathematically intricate and often beautiful body of theory.  I will
give just one example of the kind of reasoning it employs, namely "backward
induction" in the multi-stage prisoners' dilemma.  So suppose the two agents
are playing the prisoners' dilemma, with the payoff matrix above, for $T$
rounds; each agent wants to maximize the sum of all the payoffs.  If they
cooperate each round, each agent will collect $2T$, but let's see if that's
really feasible.  Start at the end and work backwards: what should the agent do
to maximize its payoff on the _last_ round, $T$?  Well, that looks just like a
one-shot prisoners' dilemma, so it should defect.  By symmetry, then, on the
last round _both_ agents will defect.  What about on round $T-1$?  You might
hope that the agents could sustain cooperation up to that point somehow, but
notice that if _one_ of them decides to defect at time $T-1$, there's nothing
the other agent can do to induce it to change its mind, since they both know
they will both be defecting at time $T$.  So both agents will defect at time
$T-1$ as well at time $T$.  By mathematical induction, they defect all the way
back time 1, and so they only collect a payoff of $T$ each, instead of the $2T$
that could have been theirs if they'd cooperated all the time[^shadowofthefuture].

[^shadowofthefuture]: Of course, for this sort of backward induction to work, the agents have to _know_ that round $T$ is the last one.  If the game might continue forever, cooperation _can_ be sustained even in classical game theory.  It's enough in fact to always have a large-enough probability $\delta$ of continuing the game for another round.  (If you know that the other player follows a "grim trigger" strategy of cooperating until you defect, and thereafter defecting on you forever, what's the minimum $\delta$ which makes it worth your while to always cooperate?)  Game theorists call this the "shadow of the future".

Classical game theory is, as I said, a beautiful subject, but it involves a
_lot_ of this sort of I-know-that-you-know-that-I-know, which becomes very
implausible very quickly, at least as an explanation of social phenomena
involving lots of ordinary people who are not good at logic puzzles.

## Evolutionary game theory

An alternative way of thinking about games is what's called "evolutionary" game
theory[^evolutionary].  The basic ideas here are that people usually follow
habits rather than engaging in complicated forward-looking reasoning, but
they're not stupid, they can learn from their own experience about what works
and what doesn't, they're willing to try new things at least occasionally, and
they can learn from others' experiences, too.

[^evolutionary]: The theory actually comes from evolutionary biology [@Maynard-Smith-games], but using doesn't commit us to thinking that social change is a process of _genetic_ evolution.

From this point of view, what we really care about is the distribution of
strategies within each population, what distribution of payoffs that leads to,
and how those distributions change as a result of individual and social
learning.  I say "strategies", but remember that we're now assuming the agents
are mostly just acting by habit, so the strategies will be very simple; in fact
let's just reduce them to individual _moves_ in the game.

To see why the distributions matter, let's think about the coordination
game.  Let's write $p_A$ and $p_B$ for the probability that a blue agent
plays A or B, and likewise $q_A$ and $q_B$ for the probabilities for red
agents.  (This really only gives us two variables, because $p_A+p_B=q_A+q_B=1$,
which is convenient for making plots.)  The expected payoff to a blue agent
from playing A is $4 q_A$.  The expected payoff to a blue agent playing B
is $2q_B=2(1-q_A)$.  So A has a higher expected payoff than B, for blue, when
\[
4 q_A > 2(1-q_A) \Rightarrow q_A > 1/3
\]
Similarly, the expected payoff of A to a red agent however is just $p_A$, while red's expected payoff from B is $2p_B = 2(1-p_A)$.  Thus, red does better, in
expected, from playing A when
\[
p_A > 2(1-p_A) \Rightarrow p_A > 2/3
\]
Blue agents _really_ benefit if everyone plays A rather than B, so much so that
they prefer to play A when only a minority (1/3) of reds will go along.  But
reds have the opposite interests, and so they only prefer to play A when a
substantial majority (2/3) of blues are forcing their hand (so to speak).


These calculations matter because we said that agents learn from experience,
and prefer actions which work well (i.e., have high payoffs) to those which
work poorly (i.e., have low payoffs).  Expected values aren't everything, but
we should still anticipate that when A is usually better than B for blues, any
blues who are playing B are going to tend to switch to A, while those already
playing A will tend to stick with what is working for them.  (See also
the complementary exercises.)


## Replicator dynamics and social learning

This leads us to the important topic of the **replicator dynamic**.  Here's how
it works with one population, and available strategies $i$.  At time $t$, a
fraction $p_i(t)$ follows that strategy.  The expected payoff to that strategy,
_given the probabilities of all the other strategies_, is $m_i(t)$, often called the **fitness** of the strategy.  The "dynamic" then is to update the
population shares according to what's called the "replicator equation",
\[
p_i(t+1) = p_i(t) \frac{m_i(t)}{\sum_{k}{p_k(t) m_k(t)}}
\]
Notice that the denominator on the right-hand side is the average fitness,
i.e., the expected payoff to a
randomly-selected member of the population.  So what this says is that
strategies which do better than average will become more common, while
strategies which do worse than average will become less common.  It's a version
of "do more of what worked and less of what didn't".

Now, as for where $m_i(t)$ comes from, it is, implicitly, a function of the distribution of strategies in the population.  The payoff matrix is, let us say, $\mathbf{r}$, where $\mathbf{r}_{ij}$ tells us our payoff to playing $i$ when the other agent plays $j$.  Then
\[
m_i(t) = \sum_{j}{r_{ij} p_j(t)} = (\mathbf{r} p(t))_i
\]
abbreviating the vector of all the $p_i(t)$ as $p(t)$.

There are a couple of things to notice about the replicator dynamics (exercises):

- If the $p_i(t)$ are valid probabilities, so $0 \leq p_i(t) \leq 1$, $\sum_{i}{p_i(t)} = 1$, and all the $m_i(t) \geq 0$, then the $p_i(t+1)$ are valid probabilities, too.
- If $p_i(t)=0$ then $p_i(t+h) = 0$ for all $h>0$; "extinction is forever".
- If one strategy $i$ has a _higher_ fitness than all the others, $m_i(t) > m_j(t)$, then that strategy will increase its share of the population, $p_i(t+1) \geq p_i(t)$.
- A **fixed point** of a dynamical system is a state which doesn't change under the dynamics.  A fixed point of the replicator dynamic would be a vector of probabilities $p$ where plugging the  $p_i$s into the replicator equation on the right-hand side gives us back $p_i$ again on the left.  This requires every strategy $i$ where $p_i > 0$ to have the _same_ fitness.
- Changing all the payoffs, and so all the fitnesses, by the same factor would leave the replicator dynamic unchanged.

Now, all of this is for one type or population of agents, playing against others
from the same population.  If we've got an assemblage of multiple types,
the changes are pretty straightforward and almost just notational.  Let's
write $p_i(t)$ for the probability that a member of the "blue" group
plays $i$ at time $t$, and likewise $q_i(t)$ for the probabilities in
the red group.  The fitnesses will be $m_i(t)$ for the blues and $\ell_i(t)$ for
the reds.
The relevant equations become
\begin{eqnarray}
m_i(t) & = & \sum_{j}{r^{(blue)}_{ij} q_j(t)}\\
\ell_i(t) & = & \sum_{j}{r^{(red)}_{ij} p_j(t)}\\
p_i(t+1) & = & p_i(t) \frac{m_i(t)}{\sum_{k}{p_k(t) m_k(t)}}\\
q_i(t+1) & = & q_i(t) \frac{\ell_i(t)}{\sum_{k}{q_k(t) \ell_k(t)}}
\end{eqnarray}
The important points are that the fitness of members of one population depends
on the distribution of strategies in the _other_ population, but strategies
grow or shrink within a population as they do better or worse than the average
for that population.


**Why the replicator dynamic?** There are several reasons.

- Some evolutionary processes really do consist of copying or "replication".
  If there are $np_i$ members of the population of type $i$, and on average
  each of them creates $m_i$ copies, then there will be $np_i m_i$ new members
  of type $i$, and a total population size of $n \sum_{k}{p_k m_k}$.  The
  replicator equation then describes the new distribution of types.
- Many processes of individual and social learning which may seem more
  complicated than simple copying have been shown mathematically to reduce to
  the replicator dynamic, either exactly or approximately in certain limits
  (like large population sizes, or gradual learning, etc.).  This includes
  reinforcement learning [@Borgers-Sarin-reinforcement-and-replicator],
  learning by Bayesian updating [@CRS-dynamics-of-bayes], and many others.  So
  studying the replicator dynamic gives us at least an approximate handle on
  what other sorts of learning will do.

### Replicator dynamics in the coordination game

To make this all less abstract, and to return to institutions, let's
go back to our coordination game.  Under the replicator
dynamic, the equations of motion are
\begin{eqnarray}
p_A(t+1) & = & p_A(t) \frac{4 q_A(t)}{4p_A(t) q_A(t) + 2 (1-p_A(t))(1-q_A(t))}\\
q_A(t+1) & = & q_A(t) \frac{p_A(t)}{q_A(t) p_A(t) + 2 (1-q_A(t)) (1-p_A(t))}
\end{eqnarray}
(The denominators here are the expected payoff to a random blue or random red
agent, respectively.)  The ratios on the right hand sides will be $>1$ when A is the preferred action, because that's exactly the time when A has better-than-average payoffs.  On the other hand the ratios will be $<1$ when A is the dis-favored action.  So:

- If at least 1/3 of the reds are playing A, the share of blues playing A will increase
- If less than 1/3 of the reds play A, the share of blues playing A will decrease
- If at least 2/3 of the blues play A, the share of reds playing A will increase
- If less than 2/3 of the blues play A, the share of reds playing A will decrease

What are the fixed points of this, the situations where $p_A(t+1) = p_A(t) = p^*$ and $q_A(t+1)=q_A(t) = q^*$?  It would be nice if the equilibria were
fixed points, so let's try that.  Plugging $p_A(t)=1$, $q_A(t)=1$ into the equations gives us back out $p_A(t+1)=1$, $q_A(t+1)=1$, so that's one fixed point.
Similarly, $q^*=0, p^*=0$ is another fixed point.  So the two equilibria
are indeed fixed points.  (See also the complementary exercise.)


Here are some representative trajectories of this system.

```{r}
coordination.game.replicator.dynamic <- function(hi=4,lo=1,balanced=2,disagree.blue=0,disagree.red=disagree.blue, p=runif(1), q=runif(1), T=30) {
    pq.trajectory <- matrix(0, nrow=(T+1), ncol=2)
    pq.trajectory[1,] <- c(p,q)
    for (t in 1:T) {
        p.new <- (p*q*hi + p*(1-q)*disagree.blue)/(p*q*hi + p*(1-q)*disagree.blue + (1-p)*(1-q)*balanced + (1-p)*q*disagree.blue)
        q.new <- (q*p*lo + q*(1-p)*disagree.red)/(q*p*lo + q*(1-p)*disagree.red + (1-q)*(1-p)*balanced + (1-q)*p*disagree.red)
        p <- p.new
        q <- q.new
        pq.trajectory[t+1,] <- c(p,q)
    }
    return(pq.trajectory)
}    
```

```{r, fig.cap="\\label{fig:coordinate.game.replicator.dynamic} Trajectories for the coordination game, from evenly-spaced initial condtions.  (Colored lines connect points on the same trajectory, with arrows showing the direction of motion.)  Only the probabilities of each side playing A action are shown.  Notice how trajectories move towards the equilibria of the game, which here are $p_A=1=q_A=1$ (referred by the blue agents) and $p_A=0, q_A=0$ (preferred by the red agents).  Trajectories which start out below the anti-diagonal line will tend to one equilibrium, those above the line to the other."}
# Make a grid of evenly-spaced initial conditions
ic.grid <- expand.grid(p=(1:10)/11, q=(1:10)/11)
# Make an empty plot
par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- coordination.game.replicator.dynamic(p=ic.grid$p[i],
                                               q=ic.grid$q[i])
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}
```

\clearpage

### Some lessons from the example

- Depending on the initial values of $p_A$ and $q_A$, the assemblage (almost always) ends up at one equilibrium or the other[^domainorbasin].  In social terms, _some_ institution forms spontaneously, or **self-organizes**.
    + This is true even though none of the agents has any representation of the institutions or equilibrium, or of the distribution within their population or the other population, or engages in any sort of complicated reasoning.  They just do more of what works well right now for other agents like them, and less of what's working poorly.
     + In particular, none of the agents has anything like an _intention_ or _plan_ to make the population coordinate on their favored equilibrium (i.e., to create institutions that serve their interests).
- If the assemblage starts very near an equilibrium, it approaches that equilibrium (rather than the other one, or doing something weirder).
- Therefore, if the assemblage is at, or close to, an equilibrium, and something perturbs the assemblage, it will tend to return to the old equilibrium.  That is, once an institution has been reached, it tends to be _stable_[^stability].
    + Another way to say this is that the assemblage displays **negative feedback** around each equilibrium: if it's disturbed away from the equilibrium, that sets forces in motion which tend to restore the equilibrium[^feedback].  Negative feedback _looks_ an awful lot like purposeful behavior, and a good case can be made that purposeful behavior requires negative feedback [@Behavior-purpose-teleology].  But in this case no agent _wants_ to maintain the equilibrium, even though some of them benefit from it (and benefit more than others).
    + It's reasonable (but not iron-clad) that the assemblage will spend most of its time close to an equilibrium.  ("Stable things persist".)
- A sufficiently large perturbation _could_ change the state of the system so much that it would then, if left to its own devices, head to the other equilibrium.  It might not be necessary to go all the way to the neighborhood of the other equilibrium[^domaincrossing].

[^domainorbasin]: The set of all states of the assemblage which will tend towards a particular fixed point consistutes that point's **basin of attraction** or **domain of attraction**.  Here the two domains of attraction of the equilibria are the two triangles, above and below the anti-diagonal line from $(0,1)$ to $(1,0)$.  In general the domains do not have to be so nicely-shaped and symmetric.

[^stability]: In dynamical systems theory, we think about dynamical rules like $x_{t+1}=f(x_t)$.  We say that $u$ is a **fixed point** of $f$ when $f(u)=u$, so that if the dynamics starts at that state it stays there.  A fixed point $u$ is **locally stable** if all trajectories which start sufficiently close to $u$ tend to $u$.  One way to formalize this is to say that there exists a distance $\delta>0$ such that $0<\|v-u\|\leq \delta$ implies $\|f(v)-u\| < \|v-u\|$.  This would mean that the system showed _negative_ feedback, at least locally, because the consequence of moving away from the fixed point would be to head back towards it.

[^domaincrossing]: In terms of an earlier footnote, the perturbation just has to move the assemblage into the domain of attraction of the target equilibrium; then the dynamics will do the rest (presuming there are no further perturbations).

## Perturbations

What would constitute a "perturbation", in this sense, to the replicator
dynamic?  There are three leading possibilities: shocks, noise, and collective
action.

- _Shocks_ are some external event or force which (temporarily) compels,
persuades or induces a bunch of agents to do something differently for a while.
- _Noise_ is any sort of probabilistic or stochastic component in the dynamics.  The replicator dynamic can be understood as describing the expected behavior
of very large populations, where the law of large numbers makes randomness average itself away, leaving a deterministic limit.  But limited populations open the way for randomness to matter, particularly near boundaries between domains of attraction.
- _Collective action_ is a group of agents deliberately coordinating their behavior to change the dynamics, or at least the outcome of the dynamics.

I won't say anything more about shocks, but noise and collective action
deserve some elaboration.

### Noise

What I've shown above is the pure replicator dynamic.  This is a dynamical
system for the _distribution_ in each population, but the dynamics are
_deterministic_: once we say what the initial distributions are, the
distributions at all later times are fixed.  It is a little unclear, though,
how this is supposed to matter to the individuals comprising the members of the
population.  I waved my hands about how each individual looks at their
population and copies the successful, but that was just hand-waving.

Let me now suggest a partially random (or "stochastic") set of rules which
will have the replicator dynamic as their _expected_ behavior, so what we'll
actually see is the replicator dynamic plus noise:
- There are $n_{blue}$ blue agents and $n_{red}$ red agents.  At every point in time, each agent is either a habitual  A player or a habitual B player.
- At time $t$, we randomly pair red and blue agents.  (If $n_{blue} \neq n_{red}$ someone has to play more than once.)  The paired off agents play their habitual moves and collect their payoffs according to the payoff matrix.
- Each red agent selects another red agent with a probability proportional to the latter's payoff.  The first one then adopts the habitual action of the selected agent.[^meaningofpayoff]  The blues do likewise.
- Repeat.

[^meaningofpayoff]: At this point we could even _define_ the payoff function this way, through the probability of being an object of emulation.


Under this set-up, the probability that a blue A-player is paired with a red A-player is $q_A$, in which case that blue agent gets a payoff of 4.  The expected
total payoff of all the blue agents will be $4 n_{blue} p_A q_A + 2 n_{blue}
p_B q_B$.  The expected probability that a blue agent will copy _one_ of the $n_{blue} p_A$ players is then
\[
\frac{4 {n_{blue} p_A} q_A}{n_{blue} (4p_A q_A + 2 p_B q_B)} = p_A \frac{4 q_A}{4 p_A q_A + 2 p_B q_B}
\]
just as it should be for the replicator dynamic.  (I will let you verify that
this holds for all the other combinations of color and move.)  So the
on-average behavior of this random process will track the replicator
dynamics.  Moreover, it should be intuitive that increasing the population
sizes, the $n_{blue}$ and $n_{red}$, will bring the actual random averages increasingly close to the expected values (by the law of large numbers).  So very
large populations should move especially close to the limiting
deterministic behavior.

```{r}
demo.n.blue <- 50
```

Here is a demonstration of the trajectories we _can_ get from this stochastic
replicator dynamic, starting from the same initial conditions for the assemblage
as in the previous figure, but with $n_{blue}=n_{red}=`r demo.n.blue`$.


```{r}
# Play our coordination game, where each player in each population is
# randomly matched with a player from the other team.
randomized.coordination.game <- function(n.blue, n.red=n.blue, p, q, hi=4, lo=1, balanced=2, disagree.blue=0, disagree.red=disagree.blue, T=30) {
    blue.payoff.matrix <- matrix(c(hi, disagree.blue, disagree.blue, balanced),
                                 byrow=TRUE, ncol=2)
    action.names <- c("A", "B")
    colnames(blue.payoff.matrix) <- c(action.names)
    rownames(blue.payoff.matrix) <- c(action.names)
    red.payoff.matrix <- matrix(c(lo, disagree.red, disagree.red, balanced),
                                byrow=TRUE, ncol=2)
    colnames(red.payoff.matrix) <- action.names
    rownames(red.payoff.matrix) <- action.names
    blue.state <- sample(action.names, size=n.blue, replace=TRUE, prob=c(p, 1-p))
    red.state <- sample(action.names, size=n.red, replace=TRUE, prob=c(q, 1-q))
    pq.trajectory <- matrix(0, nrow=T+1, ncol=2)
    pq.trajectory[1,] <- c(p,q)
    for (t in 1:T) {
        # Match up randomly by sampling
        reds.for.blues <- sample(red.state, size=n.blue, replace=TRUE)
        blues.for.reds <- sample(blue.state, size=n.red, replace=TRUE)
        # Calculate everyone's fitness by going through matrices
        blue.fitness <- blue.payoff.matrix[cbind(blue.state, reds.for.blues)]
        red.fitness <- red.payoff.matrix[cbind(blues.for.reds, red.state)]
        # Sample new states appropriately
        blue.state <- sample(blue.state, prob=blue.fitness, replace=TRUE,
                                 size=n.blue)
        red.state <- sample(red.state, prob=red.fitness, replace=TRUE,
                                size=n.red)
        new.blue.As <- sum(blue.state=="A")
        new.red.As <- sum(red.state=="A")
        pq.trajectory[t+1,] <- c(mean(blue.state=="A"),
                               mean(red.state=="A"))
    }
    return(pq.trajectory)
}    
```

```{r, fig.cap=paste("As in the previous figure, but now using finite populations (", demo.n.blue, " players of each color), randomly paired up in each round of the game.  The two panels show two different runs of the stochastic process, from the same initial conditions.", sep="")}
par(mfrow=c(1,2))

par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- randomized.coordination.game(n.blue=demo.n.blue, p=ic.grid$p[i],
                                       q=ic.grid$q[i])
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}

par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- randomized.coordination.game(n.blue=demo.n.blue, p=ic.grid$p[i],
                                       q=ic.grid$q[i])
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}
```

The over-all tendency is clearly still similar to that of the
infinite-population deterministic model, but equally clearly things are much
more erratic.  Of course, if I re-run the code, I get a somewhat
different set of trajectories (compare the two panels of the figure).

In particular, while the assemblage will still (probably) tend to an
equilibrium, _which_ equilibrium it reaches depends on where it starts _and_ on
chance fluctuations along the way.  Fluctuations are particularly important
near the boundary between two domains of attraction; chance can carry an
assemblage which "should" end up at one equilibrium over into the domain of the
other.  Proverbially: "For want of a nail, a horse was lost", and so on.




```{r}
pop.amp.factor <- 10
```

If I increase the population size by (say) a factor of `r pop.amp.factor`, the
behavior is closer to the deterministic version of the model, because more of
the randomness averages away.  The long-run outcome is _less_ influenced
by noise, but not _un_-influenced by noise.

```{r, fig.cap=paste("As in the previous figure, but increasing the population size by a factor of ", pop.amp.factor, ".  Again, the two panels show two independent sets of realizations of the stochastic process, starting from the same initial conditions.", sep="")}
par(mfrow=c(1,2))

par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- randomized.coordination.game(n.blue=pop.amp.factor*demo.n.blue,
                                       p=ic.grid$p[i],
                                       q=ic.grid$q[i])
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}

par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- randomized.coordination.game(n.blue=pop.amp.factor*demo.n.blue,
                                       p=ic.grid$p[i],
                                       q=ic.grid$q[i])
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}
```




The next figure shows the _distribution_ of outcomes that can happen when we
start the stochastic replicator dynamic near a boundary between two domains of
attraction.  You can see behavior that comes out of the deterministic
replicator dynamic, which in this case eventually converges to the $p_A=q_A=0$
equilibrium.  That's what we'd anticipate seeing in infinitely large
populations.  You can also see that with $n_{blue}=n_{red}=`r demo.n.blue`$, a
lot of the stochastic trajectories kind-of-sort-of follow along, but some of
them are definitely converging to the other equilibrium.

Deep in a domain of attraction, in particular very close to an equilibrium,
we'd need to see very large fluctuations to change the
outcome[^bigorprolonged].  This is, almost by definition, very
unlikely[^sizeoffluctuation], but "very unlikely" is not "impossible".  In
particular, if we wait long enough, anything which is _merely_ very unlikely,
but not impossible, _will_ happen eventually.  There are even techniques for
calculating how long it will take for fluctuations to spontaneously move us
from the vicinity of one stable fixed point to another, finding the most likely
path of this admittedly-unlikely trajectory, and so on.


[^bigorprolonged]: This could be either a lot of unlikely events at once (e.g, red A players have higher payoffs at time $t$ than red B players, but nonetheless all red agents randomly copy B players), or less individually less unlikely ones that are sustained over time in the same direction (e.g., a slight random excess of copying B's every time step for many time steps).
	
[^sizeoffluctuation]: Basically, we say that a fluctuation away from the expected behavior is "large" if it becomes exponentially unlikely as $n$ grows.  We then measure the size of large fluctuations by the exponential rate at which they become improbable.  The all-red-agents-copy-B-players-at-once event from the previous footnote is going to be exponentially improbable because each red agent has some probability of doing that,  say $s$, but they do so independently so the probability of them _all_ doing it will be $s^n = e^{-n\log{s}}$.  Having a slight excess of copying Bs at one time will likewise be exponentially unlikely at any one time, and having that sustained over time will require multiplying together probabilities.



```{r, fig.cap="Comparison of the deterministic and stochastic (50 agents per color) dynamics, starting from the same initial conditions.  The stochastic trajectories are shown in paler colors, the deterministic one by more saturated colors in thicker lines.  While most of the stochastic trajectories sooner or later reach the same equilibrium as the deterministic model, at this small population size we can see that an appreciable number do not."}
p.initial <- 0.49
q.initial <- 0.48
pq.det <- coordination.game.replicator.dynamic(p=p.initial, q=q.initial)
plot(0, type="n", xlim=c(0, 10), ylim=c(0,1), xlab="t",
     ylab="pA or qA")
for (i in 1:30) {
    pq.rand <- randomized.coordination.game(n.blue=demo.n.blue, p=p.initial, q=q.initial)
    lines(x=(1:nrow(pq.rand))-1, y=pq.rand[,1], col="lightblue")
    lines(x=(1:nrow(pq.rand))-1, y=pq.rand[,2], col="lightsalmon")
}    
lines(x=(1:nrow(pq.det))-1, y=pq.det[,1], ylim=c(0,1), col="blue", lwd=2)
lines(x=(1:nrow(pq.det))-1, y=pq.det[,2], col="red", lwd=2)
```

Now, as I've written out the model above, if the assemblage has _completely_
converged on one equilibrium or the other, so $p_A=q_A=0$ or $p_A=q_A=1$, it's
stuck there, because the _only_ way agents change their habits is by copying,
so once everyone is doing exactly the same thing they'll keep doing it.  An
easy fix is to allow everyone _some_ (small) probability of spontaneously
switching from being an A player to a B player and vice versa.  If we think in
more human terms about the agents, this switching probability could represent
sheer mistakes or mis-understandings, occasional stubbornness, or, frankly,
creativity and innovation.  The important thing is that it will keep
the assemblage from getting completely stuck at an equilibrium.

In the rest of these notes, I am going to "turn the noise back off", and just
show the deterministic behavior.  I will, however, make some remarks about the
effects of noise.


\clearpage

### Collective action

As I said, in this sort of model, institutions (tend to) form even though no
one is thinking about that, trying to achieve it, or considering alternatives.
Of course _people_ can think about institutions and alternatives, and in
particular about whether _different_ institutions would be better _for them_.

In the case of this model, the (B,B) equilibrium is better for the reds than
the (A,A) equilibrium is.  If the assemblage has coordinated on the (A,A)
equilibrium, an _individual_ red agent insisting on playing B is not going to
achieve anything except a 0 payoff for themselves.  But _enough_ red agents all
agreeing to play B, and to keep playing B, could tip the
balance[^collectiveactionanddomains].  This would be an example of **collective
action** on the part of the red agents.

Of course, agreeing to and carrying out this collective action raises other
issues.  In the first place, the red agents who insist on playing B when the
assemblage has coordinated on (A,A) are, at initially, going to get a payoff of
$0 < 1$ for reds who keep playing A.  Maybe worse, if the red B-players
succeed, and tip the assemblage over to the (B,B) equilibrium, then _all_ the
red agents will benefit, even those who _didn't_ participate in the collective
action.  This creates an incentive for red agents to "free ride" on the red
B-players, by continuing to play A until the new equilibrium is established.
But then why would _any_ red agent join the collective action?[^socialdilemma]
Now, as a matter of fact, collective action to change institutions happens all
the time, but social scientists have come to see it as a _puzzle_ which
requires explanation, and often requires institutional underpinnings of its
own[^collectiveaction].

[^collectiveactionanddomains]: Specifically, in this model, at least 2/3 of the reds would have to agree to play B, _and stick to it_.  The emphasized phrase is important.  If the assemblage has converged on $p_A=q_A=1$, and then 2/3 of the reds agree to play B _once_, we just move from $(1,1)$ to $(1, 1/3)$, and a glance at the figure shows that this would return to $(1,1)$ if the replicator dynamics were left to their own devices.  If we're considering one-time perturbations, they need to be big enough to move the assemblage into the domain of attraction of another equilibrium to matter.  This will often be easier to achieve if many of the blues can be persuaded to cooperate with the red collective action.  (Of course, blue allies help even if the red collective-actors _can_ make themselves stick to playing B.)

[^socialdilemma]: If this reminds you of the prisoners' dilemma, that's no accident!

[^collectiveaction]: Even the little discussion above suggests some possible ways to get collective action to happen: (a) creating trust among the collective actors; (b) rewarding those who join the collective action; (c) punishing those who don't join, or who defect from it; (d) making agents _not care_ about their immediate payoffs.  Item (d) in turn can take many forms, ranging from material compensation for the lack of payoff (e.g., a fund to support striking workers, car-pooling during a bus boycott, etc.) to instilling the conviction that participating in the action has some invisible or future payoff ("for great is their reward in heaven"), or that participating is is a _duty_ that must be fulfilled regardless of theconsequences.



## Persistence in the face of changing conditions

Suppose the payoff matrix used to be the one I gave above, but that conditions
have gradually (or suddenly) changed, so that the new payoff matrix is now

|                   | Red makes move A | B     |
|-------------------|------------------|-------|
| Blue makes move A | (4,1)            | (0,0) |
| B                 | (0,0)            | (5,5) |


The two equilibria are still (A,A) and (B,B), but now _both_ populations would
prefer the (B,B) equilibrium[^paretoimprovement].  Nonetheless, if enough
members of one populations are playing A, then A is the better action for their
partners in the other population, so the (A,A) equilibrium is still
stable[^criteria]; see the figure.

[^criteria]: What are the critical values of $p_A$ and $q_A$ above which A is the best action for each population?

[^paretoimprovement]:   Moving from the (A,A) equilibrium to the (B,B) equilibrium would in fact be a strict Pareto improvement, making everyone better off.

One consequence of this stability is that if the assemblage coordinated on the
all-A institution in the past, this institution can persist, _even though_ the
original conditions which helped bring it into being have gone away.  It can
even persist despite _everyone_ preferring the alternative all-B institution.
Fundamentally, though, it can persist because inefficient coordination is
better (for everyone) than _no_ coordination.

On the other hand, raising the (B,B) payoff to (5,5) does make the range of
$p_A$ and $q_A$ values which favor the (A,A) equilibrium much smaller than
before.  (Again, see the figure.)  Thus the all-A institution is _less_ stable
than before.  It takes a smaller perturbation --- less noise, or less extensive
collective action --- to move the assemblage to a state where it will converge
on the (B,B) equilibrium.  (Once more, see the figure.)

```{r, fig.cap="Behavior in the coordination game when the payoff from (B,B) is raised to (5,5), everything else being left unchanged.  Notice that there are still trajectories converging to the (A,A) equilbrium where $p_A=q_A=1$ in the upper-right corner."}
par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- coordination.game.replicator.dynamic(p=ic.grid$p[i],
                                               q=ic.grid$q[i],
                                               balanced=5)
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}
```

\clearpage



## Disadvantage payoffs and bargaining power

So far in these examples, we've made it so that the payoff if the two players
fail to coordinate is equal, and is zero for both of them.  What happens if we
increase this "disagreement payoff" for one side but not the other?  Each color
would (selfishly) prefer that the other color agrees to play at its favored
equilibrium.  It can't always get that, because if _enough_ agents of the other
color play _their_ favored move, coordinating with them is better than the
disagreement payoff.  But if we raise the disagreement payoff for blue but not
red agents, we make playing A better for blues, no matter what the reds do.
This will lead to more blues playing A.  This in turn makes it better for reds
to play A, etc.  All of this suggests that increasing the disagreement payoff
for one side but not the other should make it easier to reach an equilibrium
that favors the advantaged side.  This is generally correct.

```{r}
improved.blue.disagreement.payoff <- 1.5
```

For instance, suppose we make the disagreement payoff for blues $h>0$, but
leave everything else unchanged.  A blue agent's expected payoff to playing A
is now $4q_A + h q_B = h + (4-h)q_A$, while their expected payoff from playing
B is $h q_A + 2q_B = 2 + (h-2) q_A$ (since $q_B=1-q_A$).  Thus blues
prefer to play A whenever
\[
h + (4-h)q_A > 2 + (h-2) q_A \Rightarrow q_A > \frac{2-h}{6-2h}
\]
Before, when $h=0$, at least $1/3$ of the red agents had to agree to play A for
blue agents to favor it.  Increasing the blue agents' disagreement payoff
lowers this threshold.  For instance if we set $h=`r improved.blue.disagreement.payoff`$ the threshold value of $q_A$ drops to $1/6$ (see figure).
The larger we make $h$, the less blues will care about
the difference between their disagreement payoff and what they'd get at the
(B,B) equilibrium.  If we raised $h$ all the way to 2, the $q_A$ threshold
would fall to zero --- blues would always be at least as well off playing A as
B.  In _that_ extreme, no matter what the initial values of $q_A$ and $p_A$,
$p_A$ would always increase, heading towards 1, and so $q_A$ would always
eventually increase too[^eventually].

[^eventually]: Specifically, because we haven't change the payoffs for red, $q_A$ would start increasing once $p_A > 2/3$.

So: one-sided improvement to the disagreement payoffs, say favoring the blues,
increases the range of states of the assemblage which will eventually
coordinate on the blues' preferred equilibrium.  If the assemblage hasn't
reached an equilibrium yet, this makes it more likely to reach the blues'
preferred equilibrium.  If the assemblage _has_ reached that equilibrium, the
equilibrium is more stable --- it'd require a larger perturbation to upset it.
If the assemblage has coordinated on some other equilibrium, a _smaller_
perturbation is now needed to upset _that_ equilibrium and tip us over into the
domain of attraction of the blues' preferred equilibrium.  In particular, fewer
blues would need to go against their immediate interest to _force_ a change in
the institutions on the whole assemblage.


```{r, fig.cap="Replicator dynamics for the coordination game, with an improved disagreement payoff for blue agents (and only for blue agents)."}
par(pty="s")
plot(0, type="n", xlab=expression(p[A]), ylab=expression(q[A]),
     xlim=c(0,1), ylim=c(0,1))
for (i in 1:nrow(ic.grid)) {
    pq <- coordination.game.replicator.dynamic(disagree.blue=improved.blue.disagreement.payoff,
                                               disagree.red=0,
                                               p=ic.grid$p[i],
                                               q=ic.grid$q[i])
    arrows(x1=pq[-1,1], x0=pq[-nrow(pq),1],
           y1=pq[-1,2], y0=pq[-nrow(pq),2],
           length=0.10,
           col=i)
}    
```

In this situation, when a blue agent plays A and meets a red playing A, the
blue's payoff, `r improved.blue.disagreement.payoff`, is almost as good as what
it would get if it had played B and accepted an unfavorable agreement.  On the
other hand if the blue played A and met a red that played A, the blue would
get 4.  Because the disagreement payoff is so close to the unfavorable
agreement payoff, and both are so much lower than the favorable agreement
payoff, reds playing A must be rather uncommon to make it worthwhile for a blue
to _not_ also play A.  (Imagine what would happen if blue agents were
indifferent between an unfavorable agreement and disagreement.)


### Disagreement payoffs and social advantage

All of this raises the question of which populations / social positions will
have the more favorable disagreement payoffs.  To _some_ extent, this will vary
depending on the exact situation we're interested in, but we can, nonetheless,
make some generalizations.  Basically: the group which is _already_ better off
will usually need _this_ agreement less, and/or have other resources they can
bring to bear to improve their disagreement payoff.

Thus an employer who has an on-going business and some savings does need to
hire workers, but they don't need any particular worker all _that_ much,
compared to the intensity with which workers need
jobs[^unemploymentinsuranceandunions].  In many times and places, the
negotiations between landlords and tenant farmers have been more than a little
shaped by the fact that the land-_lords_ were highly trained and equipped
professional providers of armed violence, and the tenants very much were not.
Other examples are easy to multiply; see the further reading.

[^unemploymentinsuranceandunions]: Institutions like unemployment insurance can thus be seen as improving the prospective employee's disagreement payoff, improving their bargaining positon.  Similarly, if all the employees are in a union, the employer _and the union_ have much more similar disagreement payoffs than do the employer and an isolated worker.  (Whether these institutions are ethically desirable, or achieve desirable aims at acceptable costs, are separate questions.)

\clearpage


# Some common themes

This lecture has covered a bunch of rather different ideas, but there are some
themes in common across them.

0. **Generative modeling**: All of the large-scale patterns we see in these
models --- whether in terms of income distribution, or residential segregation,
or the formation of institutions --- are logical consequences of the
assumptions of the model.  They may not be _obvious_ consequences, we may need
the computer to simulate many steps of the model, but they do follow from those
assumptions.  (Otherwise, the simulation wouldn't produce them!)  So we know
that the assumptions we put in, about individual agents and their behavior and
their interactions, lead to these conclusions[^inverse].  If we don't want to see those
conclusions come to pass, we need to make sure the world doesn't fit those assumptions.
1. **Self-organization**: If we _start_ these models in random or dis-organized
initial configurations, their dynamics, the "laws of motion" which they follow,
tend to produce organized large-scale patterns, if not necessarily ones we
like.  The Schelling model produces segregated neighborhoods; social learning
in the coordination game converges on an equilibrium institution;
multiplicative growth leads to a heavy-tailed distribution.  Again, these are
_consequences_ of the ways the individuals interact.  They don't require any
sort of hidden organizer, intelligent designer, or diabolical conspiracy.
2. **Randomness and path dependency**: _Which_ institution the assemblage
converges on is at least somewhat random; similarly the ultimate borders
between neighborhoods in the Schelling model are also random.  That there will
be _some_ institution, or some set of neighborhoods, is overwhelmingly probable
and predictable, but exactly how that turns out is much less so.  Random
fluctuations early on can have large consequences, persistent consequences for
shaping the social structure.  This is an example of **path dependence** [@Arthur-increasing; @scotte-on-path-dependence].
3. **Emergence and abstraction**: We can describe the behavior of the models
entirely in terms of the individual agents, their actions, their interactions,
etc.  But it can be at least as illuminating to talk about things like the
distribution of incomes across a population, or the institution the assemblage
has converged on.  This involves aggregating information across lots of agents
--- dealing with abstractions that ignore many details about individuals.  (We
say "95% of red agents play A", not "Alice plays A, Babur plays A, Chandra
plays B, Dieter plays A...".)  These variables aren't _properties_ of any individual agent,
but they are functions of the states of all the agents.  We say that things
like income distributions or institutions **emerge from** the agents' behavior,
that they are **emergent**.  The advantage of such abstraction is that it's a lot
simpler, because it hides lots of messy detail.  Sometimes we can describe the
dynamics in these models entirely in terms of these higher-level, emergent
abstractions, so we can talk about (say) the evolution of institutions, without
ever having to talk about the behavior of individual agents, even though "the
institutions" is nothing but a way of describing the collective behavior of the
agents.  (The disadvantage of abstractions is that sometimes those details turn
out to matter a great deal.)
4. **Objectivity and alienation**: From the viewpoint of any individual agent,
those self-organized patterns and emergent phenomena are just facts about its
world.  "The assemblage has converged on the (A,A) equilibrium" is just as much
an objective fact, from Alice's point of view, as "Babur always plays A", or
"red's payoff from (A,A) is half of red's payoff from (B,B)".  (And similarly
for neighborhoods in the Schelling model, or income distributions, etc.)  It's
true that if everyone acted differently, those facts could change, but they
_are_ objective facts (within the model).  The agents have to deal with the
massed consequences of everyone's behavior as though that was something outside
them, something _other than_ their own choice.  The Latin for "other's"
being _alienus_, some philosophers describe this as the agents being
**alienated** from phenomena they themselves produce, or just
**alienation**.
5. **Feedback and cycles**: We have seen a lot of feedback loops.  Sometimes
these feedbacks stabilize an pattern --- small departures from the pattern
create responses which tend to restore the pattern.  (Think of the stable,
equilibrium institutions in coordination games.)  Other times, feedbacks
_de_-stabilize a pattern, as when an integrated configuration in the Schelling
model unravels.  (Every red that moves out of a mostly-blue neighborhood makes
that neighborhood even more blue, causing more reds to move out.)  These are
often distinguished as "negative" and "positive" feedback, respectively.
Feedback loops _can_ be a bit difficult to reason about, and to model
statistically in the ways we're used to.  For instance, if we look at snapshots
of the distributions of strategies in a lot of assemblages playing the same
coordination game, what we'll see is a bunch of small, random fluctuations
around the equilibria, and no particular pattern to which assemblage is
near which equilibrium.  If we have access to data _over time_, however,
we can "unroll the cycles": $p_A(t)$ and $q_A(t)$ depend on $p_A(t-1)$ and $q_A(t-1)$ and so on back in to the past.


[^inverse]: Of course, other assumptions might _also_ lead to those same large-scale patterns.  (The mathematicians would say that the "inverse problem" here is "ill-posed".)




\clearpage

# Further reading

On models of income and wealth leading to heavy tails, see
@Arnold-on-Pareto-distributions-2nd for an exposition of many of the classic
models (with common notation!), comparisons, references to the original and
subsequent papers, etc.

That the outcome of individuals' social interactions is often very different
from what any of them sought to achieve is the theme of Schelling's great book
@Schelling-micro-macro.  That book includes an extensive discussion of his
segregation model, among many other fascinating topics.  Of course the idea
of unintended consequences is much older than Schelling [@Boudon-unintended],
but he did bring unusual rigor to showing _how_ it can happen.

The literature on institutions is immense, and literally centuries
old[^classics].  Modern studies of institutions in economics and political
science (and to a lesser extent, sociology) owes a lot to the works of Douglass
North (e.g., @North-institutions);
@Eggertsson-economic-behavior-and-institutions is a good introduction to this
literature if you are already familiar with microeconomics.

Game theory originates with @von-Neumann-Morgenstern; @Poundstone-prisoners is
at once a biography of von Neumann, a conceptual introduction to game theory,
and a horror story about the Cold War.  Evolutionary game theory starts with
the work of Maynard Smith and colleagues around the 1970s, with the
deservedly-classic reference being @Maynard-Smith-games.
@Sigmund-games-of-life is a very readable, but intellectually serious, popular
account of evolutionary game theory.  Much of evolutionary game theory has
focused on the problem of the evolution of cooperation, using the prisoners'
dilemma as a test-bed or prototype [@Axelrod-evol-of-coop;
@Sigmund-calculus-of-selfishness; ].  @Gintis-game-theory-evolving-2nd is a
good introduction to both classical and evolutionary game theory.
@Hofbauer-Sigmund;@Hofbauer-Sigmund-evol-games-and-pop-dyn are thorough
treatments of the mathematics of the deterministic replicator dynamics and
related systems.  @Sandholm-population-games is a mathematically advanced
textbook aimed at economists, giving a lot of attention to the effects of noise
on the dynamics, using the tools of "large deviations theory".  This is an
important branch of probability theory which has a lot to say not only about
stochastic dynamics [@Freidlin-Wentzell], specifically how long it takes to
leave the vicinity of a fixed point [@Kautz-thermally-induced-escape-1987;
@Kautz-thermally-induced-escape-1988].  Large deviations theory is also
important for foundational issues in statistical inference
[@Bahadur-limit-theorems].  Unfortunately I don't know of any truly elementary
introduction aimed at statisticians, but see @den-Hollander-large-deviations.

The idea of combining models of learning with game theory to study the
formation and development of institutions goes back to the 1990s;
@Young-strategy-structure was an important milestone.  That book, like
@Foster-Young-hypo-testing, used more elaborate models of individual learning,
and less purely social learning like replicator dynamics, but derives very
similar results to what we've gone over.  @Bowles-micro is a broad-ranging
synthesis of institutional economics and evolutionary game theory.

@Knight-institutions-and-conflict was one of the first works to connect the new
ideas about institutional evolution to social conflict, and specifically to
conflict over _which_ institution should be selected; many later results in the
literature were first announced here, without the benefit (or burden) of
advanced mathematics.  @Axtell-Epstein-Young-emergence-of-classes showed
explicitly how evolutionary games could evolve unequal and inefficient
institutions which could nevertheless persist for very long periods of
time[^tags].  Similar results on the persistence of unequal institutions were
later found by @Bowles-Naidu-persistent, who also studied the connection to the
transmission of inequality.  More recently, @OConnor-unfairness applies similar
ideas to inequality between the sexes and to gendered divisions of labor.  All
of these authors (among others) note how advantaging one group, such as by
increasing its disagreement payoff, makes it easier for the whole assemblage to
converge on an institution which benefits that group.

[^tags]: In the examples above, I _assumed_ that there are red and blue agents, that reds and blues are paired up with each other, and that blue agents only learn from blues and reds only learn from reds.  The more ambitious model of @Axtell-Epstein-Young-emergence-of-classes actually shows how such social divisions (they say "classes") can emerge spontaneously, as agents come to condition their behavior on "tags", arbitrary characteristics assigned to agents which have no intrinsic significance [@Holland-hidden-order;@Epstein-Axtell].

[^classics]: Machiavelli's _Discoures on Livy_, ibn Khaldun's _Muqaddimah_, and Plato's _Republic_ are all precious parts of our common cultural heritage.

@do-institutions-evolve tries to pull together ideas about institutions,
evolutionary game theory, inequality, large deviations and social networks, if
we ever finish writing it.

\clearpage


# Complementary exercises

_Not_ for turning in.

0. Suppose that a population playing prisoners' dilemma consists of a
   proportion $p$ of cooperators and $1-p$ defectors.  Find the expected
   payoffs of playing C and D.  Verify that playing D always has a higher
   expected payoff.  What will happen to $p$ under the replicator dynamic?
1. _Cheerful facts about the replicator dynamic_ Assume we're only dealing with
   one population.
    a. Show that if the $p_i(t)$s are valid probabilities, so $p_i(t) \geq 0$
	   and $\sum_{i}{p_i(t)} = 1$, and if the fitnesses are all non-negative,
       $m_i(t) \geq 0$, then the $p_i(t+1)$s will also be valid probabilities.
    b. Show that if $p_i(t)=0$ then $p_i(t+h)=0$ for all $h > 0$.
    c. Show that if $p_i(t)=1$ then $p_i(t+h)=1$ for all $h > 0$.
    d. Show that if $m_i(t) > m_j(t)$ for all $j \neq i$, then
	   $p_i(t+1) \geq p_i(t)$.  If we also assume that $0 < p_i(t) < 1$, can we
	   conclude that $p_i(t+1) > p_i(t)$?
   e. Show that if $m_i(t)=m_j(t)$ and $p_j(t)\neq 0$, then
      $\frac{p_i(t+1)}{p_j(t+1)} = \frac{p_i(t)}{p_j(t)}$.
   f. Explain why, at a fixed point, all the strategies with positive
      probability have equal fitness, i.e., either $p_i=0$ or $m_i=m>0$ for
	  some common $m$.
1. The two-player, two-move coordination game used as a running example has
   _three_ fixed points under the replicator dynamic.  Two are the equilibria
   where $p_A=q_A=0$ and $p_A=q_A=1$, but there is also a third one.  Find it
   and describe it in words.  _Hint 1:_ Figure \ref{fig:coordinate.game.replicator.dynamic}.  _Hint 2:_ At a fixed
   point of the replicator dynamic, every action which has positive probability
   must have the _same_ payoff.  (See previous exercise.)
2. Take the running-example coordination game, and expand it to have _three_
   actions, as in the following pay-off matrix.
     a. Show that (A,A), (B,B) and (C,C) are all equilibria, and all fixed
        points under the replicator dynamics.
     b. Are there any other fixed points?
     c. Are the equilibria stable?


|                   | Red makes move A | B     | C   |
|-------------------|------------------|-------|-----|
| Blue makes move A | (4,1)            | (0,0) |(0,0)|
| B                 | (0,0)            | (2,2) |(0,0)|
| C                 | (0,0)            | (0,0) |(1,4)|




# References

