Social Mobility as a Markov Chain

A cohort starts in the lowest quintile and moves between generations.

The science

Each person belongs to one of 5 classes (quintiles). Per generation they stay with probability p; otherwise they move one class up with weight 0.5+u or down with weight 0.5-u (at the top or bottom a blocked move means staying). This defines a transition matrix P, and the class distribution evolves as πt+1 = πt P.

Because P is irreducible and aperiodic when p>0, the chain converges to a unique stationary distribution π* = π* P. The speed is set by the second-largest eigenvalue modulus: persistence close to 1 means a family stays in place for many generations ("sticky" mobility), which sociologists summarise with intergenerational elasticity.

Honest simplifications

Real mobility depends on education, geography and networks and is not a nearest-class random walk. The model keeps only two behavioural numbers so that the maths stays exact and checkable.

Numerical check built into this page

The exact Markov-chain distribution after the chosen generations is compared with a Monte Carlo cohort of individual agents (total-variation distance must be below 0.03 for cohorts of 3000 or more), and the stationary vector is verified to satisfy π*P = π* to within 1e-6. The result is shown live under the chart and turns red if the agreement fails.

Reproducibility and method notes

All random draws come from a seeded 32-bit generator (mulberry32) and Gaussian variates from the Box-Muller transform, so a given seed always produces the same sample on every device; Re-run random seed advances the seed deterministically. Deterministic curves are evaluated on a fixed grid and integrated, where needed, with a fixed-step fourth-order Runge-Kutta scheme whose local error scales with the fifth power of the step; the step sizes used here keep the error far below the drawn line width.

How to read the readouts

The tiles under the chart are recomputed on every slider move. Quantities labelled exact or analytic come from a closed-form expression; quantities labelled simulated come from the random sample and fluctuate around the exact value by an amount that shrinks as the sample size grows (roughly as one over the square root of the sample size). The green or red box is the automated agreement test between the two.

Things to try

Educational scope

This page is an educational model, not a decision tool. It is meant to build intuition for how a handful of parameters shape an outcome and how a stated formula can be checked against an independent numerical experiment. Numbers are illustrative unless a unit is given, and results must not be used for real engineering, medical, financial or legal decisions. If you notice a result that contradicts the stated formula, the built-in check is the first place to look: it is designed to fail loudly instead of hiding a disagreement, and a failing check on a sensible parameter set would be a bug worth reporting.

Common questions

Why does the simulated value never match the exact one perfectly? Because a finite random sample has sampling error; the check box tests that the difference is no larger than four standard errors, which a correct model fails only about once in sixteen thousand runs.

Why are some sliders limited to a narrow range? Outside those ranges the formula is still valid mathematically but the plain-language interpretation stops making sense, or the chart would become unreadable.

Can I embed or share a state? The page keeps no hidden state: the sliders, the seed and the formulas fully determine every number you see, so a screenshot of the sliders is enough to reproduce a result.

Does the chart work on a phone? Yes. The canvas resizes with its container, scales to the device pixel ratio (capped at 2 for smooth drawing), and the controls stack above the chart on narrow screens.

How to use