# Idea
Basic Urn model: An Urn contains balls of different colors. The outcome equals the color of the ball selected.
Simplest model: [[Bernoulli distribution|Bernoulli]] model where outcomes are independent. No path dependence.
Polya process (Phat-dependence, see [[path dependence]]): Select ball and return. Add a new ball that is the same color as the ball selected. Path dependence.
- Any probability of red balls is an equilibrium and equally likely. That is, anything could happen, and they are all equally likely to happen.
- Any history of blue and red balls are equally likely. Knowing the frequency of balls doesn't tell us anything about the sequence.
Like [[Bayes theorem]]^[[[Adam Bear]]], where the initial state of the world is the [[prior]], and data are being added constantly, which updates the state of the world.
```python
def polya(steps=100):
urn = [0, 1] # "prior"
for _ in range(steps):
np.random.shuffle(urn) # "likelihood"
urn.append(urn[0]) # "data"
return urn
x = [np.mean(polya()) for i in range(1000)]
np.mean(x) # close to 50
plt.hist(x)
```
Balancing: Select and return. Add a new ball that is the opposite color of the ball selected.
- This process converges to equal percentages of the two colors of balls.
- Equilibrium is always 50%.
Sway process: Select and return.
![[Pasted image 20210615003046.png|800]]
# Types of [[path dependence]]
Path-dependent **outcomes**: color of ball in a given period depends on the path (Polya, balancing processes).
Path-dependent **equilibrium**: percentage of red balls in long run depends on the path (Polya process).
![[Pasted image 20210615002238.png|800]]
# References
- https://www.coursera.org/learn/model-thinking/lecture/ym0VV/urn-models