Introduction

The observation of approximate power law distributions of type frequencies is very common in complex systems1,2,3,4,5. The emergence of such distributions is known to be intimately connected to multiplicative growth processes mediated by the structure of complex networks of interaction6,7. Many different effective models have been proposed to derive particular forms of these distributions. They share common characteristics, such as invoking proportional growth (also known as Gibrat’s Law) or preferential attachment and starting out at some mesoscopic scale, typically not derived from the fundamental population dynamics of the system7,8,9,10,11,12,13,14,15,16,17,18.

Among the many statistical patterns that characterize size distributions, none has received more attention than Zipf’s law17,18,19,20,21. Specifically, Zipf’s law applied to an urban system states that the expected population size of a city N is a function of its size rank, r,

$$N(r)=\frac{{N}_{0}}{{r}^{z}},$$
(1)

with an exponent z = 1, where N0 is the size of the largest city (r = 1). In other words, the largest city is predicted to be twice the size of the second largest city (r = 2), three times larger than the third largest (r = 3), and so on. This is equivalent to a Pareto probability density for city sizes, Pz(N) = c/N1+z, with c a normalization constant. First observed by Auerbach for city sizes in 191322, Zipf’s law gained widespread attention through the work of the linguist George Kingsley Zipf, who established the rank-size rule first in the context of word frequencies in the 1930s23 and then cities24. Zipf’s law quantifies the concept of urban hierarchy, which, together with ideas of central place, location theory and other “laws” characterizing statistical regularities in urban systems, became the basis for the quantitative revolution in geography in the decades after World War II. Systematic analyses of urban systems from that time already suggested that the city size distribution is not universal, acquiring different forms as a result of distinct historical patterns of growth that do not have a relation to levels of economic performance or human development25.

Like other power laws in complex systems, Zipf’s law has also attracted much scrutiny and criticism over time6,17. It is hardly ever observed empirically in an unambiguous way, with data often showing systematic deviations at the two extremes of very large and especially of very small cities26,27,28,29,30,31,32,33,34. Besides such systematic variations, estimates of the exponent z take substantial ranges across time and for different urban systems, for example in China27,35,36, the United States20,21,37, and European countries9,38.

In our view, the empirical controversies about the form of the city size distribution and the interpretation of associated deviations can only be resolved through more fundamental approaches that start out with a system’s basic population dynamics. It is also in the context of population dynamics that we can make sense of processes of selection and randomization that order and disorder complex systems. In this paper, we adopt the lens of evolutionary population dynamics to show the emergence and meaning of Zipf’s distribution as a neutral law, signaling the absence of selection. It follows that associated deviations acquire the meaning of information, specifying people’s preferences about where to live, constitute a family, and die. These results allow us to discuss and resolve a number of puzzles surrounding the interpretation of Zipf’s law as a signal for urban system integration and associated implications for the coherence and symmetry of population states.

Results

Demographic dynamics of urban systems

We now derive the population size distribution of cities in the most general way, set by their demographic dynamics. The change of the population Ni in city i during unit time Δt necessarily results from the balance of births, deaths, and migration as

$${N}_{i}(t+\Delta t)={N}_{i}(t)+\Delta t\left[{\upsilon }_{i}{N}_{i}(t)+\sum_{j = 1,j\ne i}^{{N}_{{\rm{c}}}}({J}_{ji}-{J}_{ij})\right],$$
(2)

where Nc is the total number of cities, υi = bi − di is the city’s vital rate, the difference between its per capita average birth rate, bi, and the death rate, di. The current Jij is the number of people moving from city i to city j over the time interval Δt, and vice-versa for Jji. For simplicity of notation we will work in units where Δt = 1. Eq. (2) only accounts explicitly for migration between different specific cities, which can cross political borders. Migration to city i from non-specific places outside the system, for example from non-urban regions or other nations, can be incorporated into the vital rates υi. Note that this model is very general, and naturally accommodates the inclusion of new cities over time when their sizes become non-zero, and indeed the disappearance of others, if their size vanishes.

To proceed we need to explore the dependence of the currents Jij on population size. We start by writing these currents as population rates, Jij = mijNi(t), where mij is the probability that someone in city i moves to city j over the time period. This allows us to write Eq. (2) in matrix form

$${\bf{N}}(t)={\bf{A}}(t){\bf{N}}(t-1),$$
(3)

where \({\bf{N}}(t)={[{N}_{1}(t),\ldots ,{N}_{i}(t),\ldots ,{N}_{{N}_{{\rm{c}}}}(t)]}^{T}\) is the vector of populations in each city at time t and the matrix A projects the population at time t − 1 to time t. This matrix is known in population dynamics as the environment39, with elements

$${A}_{ij}=\left\{\begin{array}{ll}1+{\upsilon }_{i}-{m}_{i}^{{\rm{out}}},&{\rm{if}}\,i=j\\ {m}_{ji},&{\rm{if}}\,i\ne j\end{array}\right.,$$
(4)

where \({m}_{i}^{{\rm{out}}}=\mathop{\sum }\nolimits_{k = 1,k\ne i}^{{N}_{{\rm{c}}}}{m}_{ik}\) is the total probability that a person migrates out of city i per unit time. We also define the population structure vector x = [xi], with xi = Ni/NT, which is the probability of finding a person in city i out of the total population NT. Note that \(\mathop{\sum }\nolimits_{i = 1}^{{N}_{{\rm{c}}}}{x}_{i}=1\), so that the structure vector has Nc − 1 degrees of freedom (the magnitude of x is fixed).

Equation (3) can now be solved by repeated iteration

$${\bf{N}}(t)={\bf{A}}(t){\bf{A}}(t-1)\ldots {\bf{A}}(1){\bf{N}}(0).$$
(5)

City size distributions in different environments

A number of important ergodic theorems40 in population dynamics tell us about the properties of the solutions under different conditions on the environments A(t). These results rely on some constraints on the properties of A; specifically, that the product of matrices in Eq. (5) is positive for sufficiently long times39,41.

First, the weak ergodic theorem guarantees that for a dynamical sequence of environments, the difference between two different initial population structure vectors decays to zero over time. This means that there is typically an asymptotic city size “distribution”, which is a function of environmental dynamics only, independent of initial conditions. When the environment is stochastic but otherwise time independent, the strong stochastic ergodic theorem states that the structure vector becomes a random variable whose probability distribution converges to a fixed stationary distribution, regardless of initial conditions. This is the sense in which most derivations of Zipf’s law apply17,33. For stochastic environments, only probability distributions of structure vectors, not vectors themselves, can be predicted. Finally, in situations where the environment is time dependent and stochastic, the weak stochastic ergodic theorem states that the difference between the probability distributions for the structure vector resulting from any two initial populations, exposed to independent sample paths, decays to zero. Again, in cases where the environment is explicitly dynamic, besides being stochastic in a stationary sense, we cannot say much about the actual probability distribution of city sizes, only that the importance of initial conditions vanishes for sufficiently long times.

To get more intuition on these results we will now show some explicit solutions. The city size distribution can be calculated exactly when the environments A are arbitrarily complicated, but static. This is the result of the strong ergodic theorem, which says that in a constant environment A, any initial population vector converges to a fixed stable structure given by the leading eigenvector of the environment39. This is guaranteed to exist if A is a strongly connected aperiodic graph, meaning that any city can be reached from any other city in a finite and diverse number of intermediate steps along the non-zero migration flows between them. This is a reasonable assumption to make about an urban system, which may even serve as a definition. The leading eigenvector of A is the eigenvector centrality of the urban system. It describes the probabilistic location of a random walker over the graph of migration flows42. This is equal to the stationary solution of numerically integrating a network described by environment A. Figure 1 shows two numerical solutions with different initial conditions, but the same environment A. The cities in the two runs converge to similar sizes, as they experience a common environmental matrix with all entries set to be the same plus a little noise. The insets show how the population structure converges from both initial conditions to the one defined by the leading eigenvector e0. Because the structure vector is the probability of finding a person out of the total population in the urban system in a specific city, we use the Kullback-Leibler (KL) divergence43 \({D}_{{\rm{KL}}}(P| {P}_{{{\bf{e}}}_{0}})={\sum }_{x}P[x]{\mathrm{log}}\,P[x]/{P}_{{{\bf{e}}}_{0}}[x]\) as a measure of the ‘distance’ between the initial distribution, P, and the final, \({P}_{{{\bf{e}}}_{0}}\). The KL divergence is a foundational quantity in information theory. It measures the information gain in describing a probabilistic state using one distribution, \({P}_{{{\bf{e}}}_{0}}\), versus another, P, in units of information (bits). Note that \(P\to {P}_{{{\bf{e}}}_{0}}\) and thus \({D}_{{\rm{KL}}}(P| {P}_{{{\bf{e}}}_{0}})\to 0\) over time, see insets in Fig. 1.

Fig. 1: Temporal evolution of the relative population structure of cities in the same environment for different initial conditions.
figure 1

Lines shows the trajectory of each city in terms of the fraction its population, Ni to the total NT. a shows an initial situation where all cities start out with similar sizes, whereas in b they are initiated following Zipf's law (shown in log-scale). In both cases, the relative city size distribution eventually becomes stationary at long times (vertical red line) with the same population structure. This is given by the eigenvector e0, corresponding to the leading eigenvalue of the environment. The insets show how the system converges in both cases to this common structure set by the environment, because the Kullback–Leibler divergence \({D}_{{\rm{KL}}}(P| {P}_{{{\bf{e}}}_{0}})\) approaches zero at late times.

The convergence rate of the city size distribution to the leading eigenvector is given by the ratio of secondary eigenvalues to the dominant one. Explicitly, we can now write this solution as

$${\bf{N}}(t)={{\bf{A}}}^{t}{\bf{N}}(0)\to {\bf{N}}(t)=\sum_{i = 1}^{{N}_{{\rm{c}}}}{({\lambda }_{i})}^{t}{c}_{i}{{\bf{e}}}_{i}.$$
(6)

where Aei = λiei, so that ei are the eigenvectors of the matrix A and λi the corresponding eigenvalues, so that λ0 > Re(λ1) > Re(λ2) > . . . , where Re(λi) is the real part of the eigenvalue. The projection coefficients ci are such that \({\bf{N}}(0)=\mathop{\sum }\nolimits_{i = 1}^{{N}_{{\rm{c}}}}{c}_{i}{{\bf{e}}}_{i}\), which can be written as c = E−1N(0), where E is a matrix whose jth column vector is ej. The strong ergodic theorem states that the largest eigenvalue λ0 is positive and real and that the associated eigenvector e0 is also positive in terms of all its entries. This means that, over time, the dynamics of the urban system approaches that of the growth of its dominant eigenvector, because the projections on all other eigenvectors decay exponentially in relative terms, as

$${\left(\frac{{\lambda }_{i}}{{\lambda }_{0}}\right)}^{t}={e}^{-\mathrm{ln}\,\frac{{\lambda }_{0}}{{\lambda }_{i}}t}\,{\mathop{-\hskip -4.3pt-\hskip -4.3pt\longrightarrow}\limits_{t\to \infty}}\,0$$
(7)

and exemplified in the two insets in Fig. 1. The longest characteristic time is associated with the difference in magnitude between the two largest eigenvalues \({t}_{*}=1/{\mathrm{ln}}\,\frac{{\lambda }_{0}}{| {\lambda }_{1}| }\). Consequently, for t\({t}_{*}\) we observe an extreme dimensional reduction from an initial condition characterized in general by Nc degrees of freedom to a final one with just one, set by the environment’s leading eigenvector. Using the values of migration flows in the US urban system over the last decade, we can compute the value of \({t}_{*}\). It is rather long—of the order of several centuries—when measured using census data44 and a little shorter using data on tax returns45.

These results allow us to consider very general classes of dynamics and initial conditions. We therefore conclude that in general, given a specific set of demographic conditions, the total population can grow exponentially with a common growth rate across cities. In addition, the relative population distribution at late times does not resemble anything like Zipf’s law. As expected from the statements of the ergodic theorems, the population structure is set by the nature of the intercity flows (and vital rates), or equivalently by the environment A.

Stochastic demographic dynamics and symmetry breaking

The step towards a statistical solution for the city size distribution—and obtaining Zipf’s law in particular—requires the additional consideration of statistical fluctuations, which must arise in the vital and migration rates. Just as in models of statistical physics, the introduction of stochasticity implies not just fluctuating quantities but potentially also the restoration of broken symmetries46,47. In the context of urban systems, restoring broken symmetries means removing preferences for population growth in specific cities over others, associated with imbalances in vital rates and migration flows. To make these expectations explicit we write the migration rates mij as

$${J}_{ij}={m}_{ij}{N}_{i}(t)=\left(\frac{{s}_{ij}+{\delta }_{ij}}{2}\right)\frac{{N}_{j}(t)}{{N}_{{\rm{T}}}(t)}{N}_{i}(t).$$
(8)

Eq. (8) splits the migration flows into two parts: sij describes the symmetric flow between two cities (sij = sji), and δij the anti-symmetric part (δij = −δji). Note that any correlations between Ni and Nj are preserved in these two quantities. Making the population size of the destination city explicit will allow to diagonalize Eq. (2) and therefore to find self-consistent solutions for the structure vector. This form of the migration currents also makes contact with the gravity law of geography, which is typically written as

$${J}_{ij}={G}_{g}\frac{{N}_{i}{N}_{j}}{{d}_{ij}^{\gamma }}={J}_{ji}.$$
(9)

In this form, the gravity law is symmetric, corresponding to Eq. (8) when δij = 0 and sij = GgNT(t)f(dij), where Gg is the ‘gravitational’ constant, \(f({d}_{ij})=1/{d}_{ij}^{\gamma }\) is a decaying function of distance dij and γ is the distance exponent. Only the anti-symmetric part contributes to the dynamics of population size change, since we can write Eq. (2) as

$${N}_{i}(t+1)=\left[1+{\upsilon }_{i}-{\overline{\delta }}_{i}\right]{N}_{i}(t).$$
(10)

with \({\overline{\delta }}_{i}=\mathop{\sum }\nolimits_{j = 1}^{{N}_{{\rm{c}}}}{\delta }_{ij}{x}_{j}\). We can now appreciate the importance of the bi-linearity of the migration flows on both the origin and destination population as a means to diagonalize the demographic dynamics. We have achieved this however at the cost of introducing a slow non-linearity in each city’s growth rate, via their dependence on the population structure vector x. We can establish the existence of a self-consistent solution x* such that for long times

$${\upsilon }_{i}-{\overline{\upsilon }}^{* }=\sum_{j = 1}^{{N}_{{\rm{c}}}}{\delta }_{ij}{x}_{j}^{* },$$
(11)

where \({\overline{\upsilon }}^{* }=\mathop{\sum }\nolimits_{i}^{{N}_{{\rm{c}}}}{\upsilon }_{i}{x}_{i}^{* }\), since \(\mathop{\sum }\nolimits_{i,j = 1}^{{N}_{{\rm{c}}}}{\delta }_{ij}{x}_{i}{x}_{j}=0\), by the conservation of the migration currents. Note that we did not assume any explicit form for the migration flows as a function of distance between places, so that our discussion includes many specific models, including different version of the gravity law.

This equation has a clear geometric meaning: The matrix δ = [δij] is anti-symmetric and real, so that it behaves as an infinitesimal generator of rotations: R(x) = x + δx. We can write the self-consistent solution in terms of these rotation as

$$R({{\bf{x}}}^{* })={{\bf{x}}}^{* }+({\boldsymbol{\upsilon }}-\overline{\upsilon }),$$
(12)

where \(\overline{\upsilon }\) is still a function of x and υ = [υi]. Note that these rotations are associated with very small angles, and that the structure vector is subject to constraints, such as staying positive. The first two terms of Eq. (12) ask for a general solution for x that is invariant under rotations. However, the last term, which introduces differences in relative growth rates for different cities, breaks this symmetry explicitly. This specificity of the relative growth rates leads to particular solutions that do not coincide with Zipf’s law. Fig. 2a shows the example of a numerical solution in a non-linear, non-stochastic environment, defined by Eq. (8). The final population structure in this environment is still well defined, as it reaches a steady state. However, compared to the time independent case (see Fig. 1), the final structure takes much longer to unfold and has a stronger urban hierarchy.

Fig. 2: City size distribution emerging from stochastic demographic dynamics differ significantly from those in time independent environments.
figure 2

a depicts the temporal trajectory for a set of 100 cities in a non-stochastic, non-linear environment, described by Eq. (8). Despite generalizing the demographic dynamics in Fig. 1, this results in a fixed urban hierarchy at late times (vertical red line), regardless of initial conditions. However, when migration and vital rates become stochastic, the demographic dynamics no longer has a static solution at long times, b. Instead, cities constantly change their relative sizes (rank) over time. After an initial transient, the population structure fluctuates close to Zipf's law. The insets show the population structure (red) at the point in time when the non-stochastic evolution (a) becomes approximately stationary, with Zipf's law (dashed blue line) shown for reference.

Symmetry restoration and the emergence of Zipf’s law

The stage is now set to consider what it takes to counter the symmetry breaking resulting from the selective structure of the environment. To do that, we must consider the statistics of the demographic rates. We start by rewriting Eq. (10) in terms of the dynamical equations for the structure vectors x as

$${x}_{i}(t+1)=\left[1+{\upsilon }_{i}-\overline{\upsilon }-{\overline{\delta }}_{i}\right]{x}_{i}(t)=(1+{\epsilon }_{i}){x}_{i}(t).$$
(13)

We now specify the relative growth rate \({\epsilon }_{i}={\upsilon }_{i}-\overline{\upsilon }-{\overline{\delta }}_{i}\) for each xi as a statistical quantity. It is clear by construction that its average over cities vanishes, \({\overline{\epsilon }}_{i}=0\). The only remaining question is how ϵi varies over time. There is strong empirical evidence that on the time scale of years to decades some cities can maintain larger growth rates than others. For example, presently in the US, most cities of the Southwest and South are growing fast, while other cities show slower growth or relative decay, such as many urban areas in the Midwest and Appalachia48. Moreover, it has been true in recent decades that mid-sized cities in the US have been growing faster than either the largest cities or small micropolitan areas, so that even population aggregated growth rates over certain size ranges differ. Going further back in time one could argue that the same cities of the Midwest were once booming as they became the manufacturing centers of the US, especially between the Civil War and the decades post WWII49. Similar arguments may be made for cities in other urban systems, such as in Europe50,51. Thus, it is possible that on very long time scales, T—on the order of a century or longer—the growth rates of cities equalize to very similar numbers and therefore the temporal average \(\langle {\epsilon }_{i}\rangle =\frac{1}{T}\mathop{\sum }\nolimits_{t}^{T}{\epsilon }_{i}(t)\to 0\). This requires that the temporal average of Eq. (11) remains zero, which means that the structure vector is both rotated and dilated ’randomly’ in ways that over sufficiently long times lead to 〈ϵi〉 = 0, for each city. Numerical solutions of the demographic equations under these conditions show a population structure that closely resembles Zipf’s law for long times, see Fig. 2b.

In the following, we show that Zipf’s law is a probability density for this derived dynamics in the long run. To do this, let us characterize the variance in the temporal growth rate fluctuations as \({\sigma }_{i}^{2}=\langle {\epsilon }_{i}^{2}\rangle ={\sigma }_{{\upsilon }_{i}-\upsilon }^{2}+{\sigma }_{{\overline{\delta }}_{i}}^{2}+2{\rm{COV}}({\upsilon }_{i}-\upsilon ,{\overline{\delta }}_{i}) \, > \, 0\). Over the same long time scales, statistical fluctuations in the growth rate may obey a limit theorem, so that they become approximately Gaussian, with variance, \({\sigma }_{i}^{2}\). Then, Eq. (13) becomes simpler, and acquires a direct correspondence to familiar stochastic growth processes. It can be written in analogy to geometric Brownian motion without drift as

$$d{x}_{i}={\epsilon }_{i}{x}_{i}={x}_{i}{\sigma }_{i}dW$$
(14)

where W is a standard Brownian motion. We now see how demographic dynamics can be simplified through a chain of assumptions into a form consistent with typical stochastic processes leading to Zipf’s law as proposed by Gabaix20,52.

Equation (14) can be expressed as an equation for the probability density P ≡ P[xitxi(0), 0] of observing xi at time t, having started with an initial condition where xi(0) was observed at time zero,

$$\frac{d}{dt}P=\frac{{d}^{2}}{d{x}_{i}^{2}}{\sigma }_{i}^{2}{x}_{i}^{2}P=\frac{d{J}_{{x}_{i}}}{d{x}_{i}}.$$
(15)

The last term describes a probability current, \({J}_{{x}_{i}}=\frac{d}{d{x}_{i}}{\sigma }_{i}^{2}{x}_{i}^{2}P({x}_{i})\). This equation is exactly solvable, see Methods for technical details. To find the stationary solutions, we ask that the right hand side of Eq. (15) vanishes. The first of the two solutions corresponds to a vanishing current, \({J}_{{x}_{i}}=\frac{d}{d{x}_{i}}{\sigma }_{i}^{2}{x}_{i}^{2}P({x}_{i})=0\) and is \(P=\frac{c^{\prime} }{{\sigma }_{i}^{2}{x}_{i}^{2}}\), where \(c^{\prime} \) is a normalization constant. If \({\sigma }_{i}^{2}={\sigma }^{2}\) independent of x, as proposed by Gibrat’s law, we can drop the index so this becomes Zipf’s law, \(P(N)={P}_{{\rm{z}}}({N}_{i}) \sim \frac{c}{{N}^{2}}\). Note for example that if \({\sigma }_{i}^{2} \sim {N}^{-\alpha }\) (α may be negative), which violates Gibrat’s law in terms of fluctuations of the growth rate, then P ~ 1/N2−α. Thus, the city size dependence of growth rate fluctuations will change the exponent in Zipf’s law and may destroy scale-invariance altogether if it is not a power law. The second solution applies for constant current, i. e. Jx = J, which leads to \(P=\frac{c^{\prime\prime} }{{\sigma }^{2}x}\), where c″ is a normalization constant. This represents a flow of probability across the urban hierarchy. Both solutions are attractors of the stochastic dynamics that emerge for long times, t 1/σ2.

We find that in the limit where the relative difference in vital rates vanishes due to fluctuations, the structure vector becomes rotationally invariant on average and the angular symmetry of x is effectively restored. This leads to an effective symmetry of the relative city size distribution on the time scale tr = 1/2σ2, when growth rate fluctuations vanish. The time tr can be estimated using US data to be typically very long, on the range of many centuries or even millennia. Under these conditions all cities share statistically identical dynamics and can be interchanged, resulting in Zipf’s law as the time average of population size distributions, see Fig. 3. In the same limit, the anti-symmetric components of intercity flows will average out and the gravity law will emerge in its conventional form. However, the observations of city sizes at each time are samples of this distribution and may reflect decade-long observable positive and negative preferences for certain cities. Figure 4 shows this effect for the US urban system using decennial census data from 1790 to 1990. For time periods of a few decades, the temporal average does not visibly converge to Zipf’s law: The blue line in the inset of Fig. 4 depicts this effect. However, the cumulative temporal average of the size distributions starts to approximate Zipf’s law after about five decades. The red line (inset) shows the KL divergence between the cumulative temporal average and Zipf’s law, starting from 1790 to subsequent census.

Fig. 3: Stochastic migration rates restore the symmetry of city growth rates over time, leading to Zipf’s law.
figure 3

The figures show the temporal solution of the demographic dynamics (Eq. (13)) when rotational symmetry is restored through stochasticity averaged over long times. a Shows the population structure at different times (dashed lines) and the distribution with smallest divergence from Zipf’s law over a long run (red), measured by the smallest observed DKL(PPz). b shows the trajectory of the Kullback-Leibler divergence away from Zipf’s law over time. After a long time period, the population structure approximates Zipf’s law and fluctuates around it. In this regime, at any single time only samples showing some deviations from Zipf’s distribution are observable: it is only on the average over many structure vectors at long times that Zipf’s law emerges as a good characterization of the city size distribution. Fig. 4 shows that this was indeed the case for the US urban system until recently.

Fig. 4: The dynamics of the rank-size distribution for cities in the US between 1790 and 1990.
figure 4

Population structure distributions for the largest 100 cities in the US53 are shown as dashed lines, while the average over all years is shown in red. The inset depicts the DKL(PPz) to Zipf’s law of the population structure for each available year (blue) and of the cumulative average over all structure vectors up the specific year (red). We see that the temporal average steadily approaches Zipf’s law as more years are added. After an initial phase, the average is always closer to Zipf’s law than the distribution in any single year. Note that in recent decades, the population structure vector began consistently deviating from Zipf’s law, leading also to a small divergence of the cumulative temporal averages. This effect is to a large extent the consequence of mid-sized and large metropolitan areas growing faster over this period than the largest cities in the US urban system.

Discussion

We have shown that the demographic dynamics of urban systems can result in different city size distribution and how Zipf’s law, the gravity law and other coarse-grained statistical regularities in geography emerge approximately from these dynamics as averages when certain symmetries are restored over sufficiently long times.

Several of the properties of Zipf’s law that have been controversial in the literature can be clarified from this perspective. First, Zipf’s law is not a “unique signal for the integration of cities in an urban system”54; it is merely one distribution of city sizes among many less symmetric ones that result from such integration. We have shown in this respect that integration of an urban system depends on strong intercity migration flows—but not necessarily the symmetric ones that might lead to Zipf’s law. Intuitively, such flows mix people up between places creating a single common dynamics across all cities that is not associated with any particular kind of economic or political organization beyond enabling free intercity migration. However, asymmetries in the migration flows (and, thus, deviations from Zipf’s law) might originate in systemic properties, but can have a manifold of other reasons—such as socio-economic opportunities, natural disasters, or demographic change—or originate from combinations of them.

Second, in a recent article Cristelli et al.54 make the important point that the properties of Zipf’s law are systemic and cannot be understood simply on the basis of its mathematical form as a power law. They show that Zipf’s distribution is coherent in that subsamples of a population distributed according to Zipf’s law do not reflect the same statistics. They also emphasize that because the largest city in the system sets the overall properties of rank, the distribution makes no sense without it, something they call screening. These properties can be understood through the conservation of the current Jx and its dynamical consequences. If we replace any other probability distribution, including a normalized subsample of Zipf’s law, into the current we will obtain a non-zero drive to the entire system dynamics because P[x] is a field in x. This systemic response signals a lack of coherence and eventually restores P[x] back to Zipf’s distribution. Similarly, a set of cities organized such that their relative populations has Jx = 0 ensures that other cities cannot easily take their sizes and ranks, leading to screening as a result of the global conservation law of the probability current. Under these conditions there can only be churn in the relative positions of cities in the rank hierarchy. The characteristic extinction time for a city with initial rank r to fall below the lower boundary x < xm can be read from the solutions in Methods to be \(\langle \Delta t(r)\rangle \sim \frac{1}{2{\sigma }^{2}}{\mathrm{ln}}\,\frac{{r}_{\max }}{r}={t}_{r}{\mathrm{ln}}\,\frac{{r}_{\max }}{r}\). The longest time, for the largest city to fall off the system, is \(\langle \Delta t(r=1)\rangle {t}_{r}{\mathrm{ln}}\,{N}_{{\rm{c}}}\), which is the product of the characteristic time for the reversal of city growth rates, tr, multiplied by \({\mathrm{ln}}\,{N}_{{\rm{c}}}={\mathrm{ln}}\,{r}_{\max }\), which is a measure of the depth of the urban hierarchy.

To better appreciate the commonly observed deviations of the largest and smallest cities in the distribution, consider that the current can be integrated over any finite range of x [xlxu] to give

$$\int_{{x}_{{\rm{l}}}}^{{x}_{{\rm{u}}}}dx{J}_{x}={x}_{{\rm{u}}}^{2}P[{x}_{{\rm{u}}}]-{x}_{{\rm{l}}}^{2}P[{x}_{{\rm{l}}}]=0\to P[{x}_{{\rm{u}}}]=\frac{{x}_{l}^{2}}{{x}_{{\rm{u}}}^{2}}P[{x}_{{\rm{l}}}],$$
(16)

which is clearly satisfied by Zipf’s distribution with z = 1. This shows how the statistical dynamics of population sizes depends on values at the extremes of x, the maximum, xM and minimum xm. While it may be natural to set xM = 1 with a small probability, it is more problematic to choose xm’s value, thereby defining the population of the smallest possible city in the sample. In particular, because xm = Nm/NT > 0, we must specify how places with population N < Nm relate to our distribution at the lower boundary. The vanishing current condition tells us that there should be a Zipfian “ghost” distribution of cities, such that \(P[x \, < \, {x}_{{\rm{m}}}]=\frac{{x}_{{\rm{m}}}}{x}P[{x}_{{\rm{m}}}]\), with lots of small cities.

Expanding on a point stressed by Saichev et al.5, this means that the boundary conditions, especially for small cities, are critical in shaping the resulting distribution. This issue betrays a failure of true scale-invariance hidden in Zipf’s law. The solution of Eq. (14) in the absence of the vanishing current is a lognormal distribution5 with average given by \({\mathrm{ln}}\,x(t)={\mathrm{ln}}\,x(0)-({\sigma }^{2}/2)t\) (see Methods). This means that, in the absence of boundary conditions at xm, the distribution will become more and more peaked at smaller and smaller values of x over time. The conservation of the current stops this decay from happening, because it effectively injects some compensatory probability for small cities getting smaller, from other even smaller cities (not in the sample) getting larger. This logic requires an immense number of smaller and smaller cities. For example, if like in the US or China the largest city in the system has ~20 million people, one needs 20 million cities with one person, 2 million with 10, 200,000 with 100 and so on, which is not observed. This inevitable deficit of small towns relative to Zipf’s law will always lead to a loss of scale invariance for high ranks and the need to understand the nature of demographic processes at play in this regime on the basis of more fundamental processes, returning us back to the demographic dynamics of Eq. (2).

Zipf’s law acquires a special status among other possible distributions in light of the property of neutrality, which emerges as the rotational symmetry of the dynamics is restored over long times. The term refers to the absence of selection in population dynamics, see Methods. As such, resulting distributions are maximally disordered given additional constraints (maximum entropy). This means that deviations from Zipf’s law express selection of people towards certain places (resulting from temporary ϵi ≠ 0) and should be measured in terms of information. In this respect, we can measure the surprise of an observed state of the system relative to the Zipfian expectation as \(S(x)={\mathrm{log}}\,\frac{P[x]}{{P}_{{\rm{z}}}[x]}\), and the total information (total surprise) in the choices underlying the actual observed distribution relative to the neutral situation (Zipf’s law) in terms of the Kullback-Leibler divergence \({D}_{{\rm{KL}}}(P| {P}_{{\rm{z}}})=\bar{S}\), as we have done in Figs. 1, 3, and 4. Those measures additionally provide a way to compare structures of systems at different times and can reveal temporal trends, signaling basic structural changes in the underlying demographic processes. Fig. 4, for example, depicts a strong and long lasting increasing deviation from Zipf’s law for the US. It might be a signal that the US is in a transitory state with strong preferences for certain regions since the 1940s, such as mid-sized cities in Texas and the Southwest. However, such statements for specific urban systems need further context-specific investigation, which is beyond the scope of this article.

In summary, starting with the most general demographic equations, we can derive many instances of integrated urban systems with city size distributions that differ substantially from Zipf’s law. We can understand the process by which universal patterns in geography emerge as a sequence of situations that restore the symmetry of the demographic dynamics and ultimately rely on averaging stochastic behavior of vital and migration rates over sufficiently long times. Seeing Zipf’s law and other laws of geography in this light helps us appreciate the information content of associated deviations in real urban systems, and trace them back to specific choices and preferences associated with people’s agency in terms of births, deaths, and migration. Formally, the approach developed here for urban systems relies only on the analysis of the transition probability between types against a general background of multiplicative growth dynamics. As such, it is very general and readily applies to other situations in complex systems where rank-size rules are also observed approximately.

Methods

Probability solution for geometric random growth with boundary conditions

The Fokker-Planck equation for random geometric growth without drift is

$$\frac{dP}{dt}=\frac{{d}^{2}}{d{x}^{2}}\frac{{\sigma }^{2}}{2}{x}^{2}P,$$
(17)

where P = P[x(t), tx(0), t0] is the conditional probability of observing state x of the random variable at time t, given the initial state x(t0) at time t0. For simplicity of notation, we have dropped the i indices in x and σ and write x(t0) as x0.

Equation (17) has some similarities with the diffusion equation in physics and can analogously be solved exactly. First, it is useful to change variables so as to eliminate the non-linear term x2. We set \(y={\mathrm{ln}}\,\frac{x}{{x}_{0}}\) and \(\tau =\frac{{\sigma }^{2}}{2}(t-{t}_{0})\). By changing the variables in Eq. (17) we find

$$\frac{dP}{d\tau }=\frac{{d}^{2}P}{d{y}^{2}}+3\frac{dP}{dy}+P\equiv P^{\prime\prime} +3P^{\prime} +P.$$
(18)

This equation is now linear and can be solved in two ways. The first way is using factorization and solve it as a heat equation

$$P={e}^{-\frac{3}{2}y-\frac{1}{4}\tau }g(y,\tau )$$
(19)

and

$$\frac{dg}{d\tau }=g^{\prime\prime} .$$
(20)

The second way is to solve it directly via a Fourier transform, so that

$$P[y,\tau ]=\int\,dk{e}^{iky}P[k,\tau ],$$
(21)

which leads to

$$\frac{dP[k,\tau ]}{d\tau }=(-{k}^{2}+3ik+2)P[k,\tau ].$$
(22)

This equation can be solved via a separation of variables, P[kτ] = f(k)T(τ), which leads to an eigenvalue problem:

$$\frac{dT}{d\tau }=-wT,\qquad (-{k}^{2}+3ik+2)f(k)=-wf(k).$$
(23)

Solving for k we obtain:

$$k=\frac{3}{2}i\,\pm \frac{1}{2}i\sqrt{1+4w},$$
(24)

with

$$P[y,\tau ]=\int\,dkP[k,0]{e}^{iky-({k}^{2}-3ik-2)\tau },$$
(25)

where P[y, 0] = f(k)T(0). In particular, there are two stationary solutions, for w = 0, with k = k0 = 2i and k = k1 = i. Substituting k0, we see that the solution corresponds to \(P \sim {e}^{-2y}=\frac{1}{{x}^{2}}\), which is Zipf’s distribution. The other solution corresponds to the existence of a constant probability current up or down the urban hierarchy associated with different boundary conditions, see main text.

In order to obtain Zipf’s law as the stationary distribution for long times, we must add constraints to the geometric random growth dynamics. To see this more explicitly, we consider the full dynamical solution, which can be written in terms of y as,

$$P[y,\tau ]={\alpha }_{1}{e}^{-2y}+{\alpha }_{2}{e}^{-y}+\int\,dk{a}_{k}{e}^{iky-({k}^{2}-3ik-2)\tau }$$
(26)

To obtain Zipf over the long run, three conditions are needed: First, the integration constant α2 has to be zero when the probability current is set to zero. In terms of y, this reads as

$$J(y)={e}^{-2y}\frac{d}{dy}{\sigma }^{2}{e}^{2y}P[y,\tau ]=0.$$
(27)

Second, the constant α1 can now be fixed by normalization of Zipf’s distribution as a probability:

$${\alpha }_{1}\int_{{x}_{{\rm{m}}}}^{{x}_{{\rm{M}}}}dx\frac{1}{{x}^{2}}=1,$$
(28)

thus \({\alpha }_{1}=\frac{{x}_{{\rm{M}}}{x}_{{\rm{m}}}}{{x}_{{\rm{M}}}-{x}_{{\rm{m}}}}\), where xM and xm are the upper and lower boundaries of city sizes, respectively. A natural choice for the upper boundary is xM = 1, whereas the choice for the lower boundary is not obvious, see main text. Third, we can now set the boundary condition on the time varying solutions, which are now

$$g(y,\tau )=P[y,\tau ]-{\alpha }_{1}{e}^{-2y}$$
(29)

and must be taken to vanish at the boundaries in y. The integral over the range of city sizes needs to be zero to preserve the probability normalization. For example, by asking that these solutions are real and vanish at the boundaries, meaning g(y = ymτ) = g(y = yM) = 0, we get

$$g[y,\tau ]=\sum_{n}{a}_{n}\sqrt{\frac{2}{{y}_{M}-{y}_{m}}}\sin {k}_{n}[(y-{y}_{m})-3\tau ]{e}^{-({k}_{n}^{2}-2)\tau },$$
(30)

with \({k}_{n}=\frac{2\pi }{{y}_{M}-{y}_{m}}n\) and n = 1, 2, 3, …. The coefficients an are determined via the initial condition g[y, 0] in the usual way. The sine functions are an orthonormal basis under integration over the domain of y, thus

$${a}_{n}=\sqrt{\frac{2}{{y}_{M}-{y}_{m}}}\int_{{y}_{m}}^{{y}_{M}}dyg[y,0]\sin {k}_{n}(y-{y}_{m}).$$
(31)

Even though these functions now obey the boundary conditions, the temporal structure is similar to the case with no boundary conditions and the decay of the initial amplitudes occurs on a time scale set by τ, which is \(t-{t}_{0}=\frac{1}{2{\sigma }^{2}}\) and can be very long for small volatilities, σ.

Lognormal solution in the absence of conserved current

We can find the general solution in Eq. (25) with the initial condition P[y, 0] = δ(y), which corresponds to the case N(t = 0) = NT. Then P[k, 0] = 1 and the solution for all times is

$$P[y,\tau ]=\int\,dk{e}^{iky-({k}^{2}-3ik-2)\tau }=\frac{{e}^{-y}}{\sqrt{2\pi \tau }}{e}^{-\frac{{\left(y+\tau \right)}^{2}}{4\tau }}.$$
(32)

Returning to our original variables this becomes

$$P[x,t| {x}_{0},{t}_{0}]=\frac{{x}_{0}}{x}\frac{1}{\sqrt{\pi {\sigma }^{2}(t-{t}_{0})}}{e}^{-\frac{{\left({\mathrm{ln}}\,\frac{x}{{x}_{0}}+\frac{{\sigma }^{2}}{2}(t-{t}_{0})\right)}^{2}}{2{\sigma }^{2}(t-{t}_{0})}},$$
(33)

which is a lognormal with log-mean \(\langle {\mathrm{ln}}\,x\rangle ={\mathrm{ln}}\,{x}_{0}-\frac{{\sigma }^{2}}{2}(t-{t}_{0})\), and log-variance \(\langle {({\mathrm{ln}}\,x-\langle {\mathrm{ln}}\,x\rangle )}^{2}\rangle ={\sigma }^{2}(t-{t}_{0})\). As a result for late times, in the absence of a boundary condition that sets the current Jx, the city size distribution becomes peaked around smaller and smaller sizes, and become broader and broader.

We can define an “extinction time” 〈Δt(r)〉 as the expected time interval for a city of initial rank k to fall through the lower boundary condition, at x = xm. This is defined implicitly through the conditional probability P[xmtx0t0] = p ~ 1, where xm is the minimum size, which close to Zipf corresponds to maximal rank \({r}_{\max } \sim 1/{x}_{{\rm{m}}}\). Observation of the exact solutions above tells us that the leading time is \(\langle \Delta t(r)\rangle \sim \frac{1}{2{\sigma }^{2}}{\mathrm{ln}}\,\frac{x}{{x}_{{\rm{m}}}}=\frac{1}{2{\sigma }^{2}}{\mathrm{ln}}\,\frac{{r}_{\max }}{r}\). There are subleading terms that depend on the exact initial condition. The longest extinction time belongs naturally to the largest city (with initial r = 1): it is \(\langle \Delta t(r=1)\rangle \sim \frac{1}{2{\sigma }^{2}}{\mathrm{ln}}\,{r}_{\max }\), which depends on how many cities there are in the urban system because rmax = Nc.

Neutrality of population dynamics and Zipf’s law

In evolutionary population dynamics, a change in the relative probability of types (in the absence of errors) is attributed to selection. The situation when selection is absent and only statistical fluctuations drive the dynamics is known as neutral dynamics.

We noted in the main text that the structure vector \({x}_{i}(t)=\frac{{N}_{i}(t)}{{N}_{{\rm{T}}}(t)}\), i = 1, . . . , Nc is the probability of finding a person in city i at time t out of a total population NT(t), across all cities. In evolutionary population dynamics we write the evolution of this probability as

$${x}_{i}(t+1)={w}_{i}(t){x}_{i}(t)$$
(34)

The quantity wi(t) is the fitness of state xi, because if wi(t) > 1 this state becomes more common in the updated population and vice versa when wi(t) < 1. Note that by normalization of the updated frequency the population average \({\sum }_{i}{x}_{i}(t+1)=1={\sum }_{i}{w}_{i}(t){x}_{i}(t)=\bar{w}(t)\). Comparing to Eq. (13), this establishes that wi = 1 + ϵi. Positive (negative) selection correspond to the situation when wi > 1 (wi < 1). Neutrality corresponds to wi = 1 → ϵi = 0, which we showed to be necessary to obtain Zipf’s distribution. Consequently, Zipf’s law is a neutral distribution.

Note that Zipf’s law is not the only neutral distribution for multiplicative dynamics, but becomes unique when we impose the additional condition, Jx = 0.

Additionally \(\mathrm{ln}\,{w}_{i}\) has a meaning as information. To see this write,

$${\mathrm{log}}\,{w}_{i}\simeq {\epsilon }_{i}={\mathrm{log}}\,\frac{{x}_{i}(t+1)}{{x}_{i}(t)}={\mathrm{log}}\,\frac{{x}_{i}(t+1)P({\bf{A}})}{{x}_{i}(t)P({\bf{A}})}={\mathrm{log}}\,\frac{P({x}_{i},{\bf{A}})}{{x}_{i}P({\bf{A}})},$$
(35)

where P(A) is the probability of a particular environment and p(xiA) is the joint probability of the population structure and of states of the environment. The idea is that the updated probability is the structure vector given (conditional on) the influence of the environment, as we wrote in Eq. (13), so that xi(t + 1) = P(xiA(t)). Thus, \(\mathrm{log}\,{w}_{i}\) once averaged over x and A is the mutual information between the population structure and the environment. When the evolution is neutral P(xiA) = xiP(A), the two variables are statistically independent and there is no information from the environment being encoded in the population structure. Since the environment, in our case, is the space of preferences in vital and migration rates, there is no structure of these preferences encoded in the population structure when we observe Zipf’s law. Only the deviations from it, when ϵi ≠ 0, can in this sense give us information.

Time integration

Numerical solutions shown in Figs. 13 where obtained by iterating the respective environments, A, starting with several different initial population states, N(0), as expressed by Eqs. (3) and (5). We assumed that all environments are strongly connected graphs; the migration probability from city i to city j is non-zero, or Aij > 0. These parameterizations reflect features of real world urban systems such as the average annual fraction of population that moves between metropolitan areas in the US in the last few decades, which is about 1.8%, according to US Census Bureau44 and tax returns reported by the Internal Revenue Service45. The data from both sources shows that the migration rates δij follow a lognormal distribution. We implemented the stochastic environments to reflect this statistical distribution.

The introduction of stochasticity in Figs. 2 and 3 requires that we set boundary conditions at large and small x as discussed in the main text. The upper bound is less critical and a natural choice is to allow the whole population to concentrate in one city, or xM = 1. This state has very low entropy, so that it is extremely rare for it to occur by chance. In practice, it is never observed in numerical solutions even when stochastic fluctuations are strong. On the other hand, the boundary condition for small cities is violated all the time, as shown in Fig. 2. Varying the value of xm shows that the best value for the lower bound is of the order of the size of the smallest city according to Zipf’s law (N(r = Nc) = N0/Nc), resulting in:

$${x}_{{\rm{m}}}=\frac{{N}_{0}}{{N}_{{\rm{c}}}{N}_{{\rm{T}}}}.$$
(36)

When a city’s time evolution violates this lower constraint, our implementation resets the population size of the city back to its former size, typically just above xm, and adapts the other cities so that

$$\sum_{i = 1}^{{N}_{{\rm{c}}}}{x}_{i}=1$$
(37)

This is achieved by reducing the xi uniformly among all other cities without violating the lower bound during this process. This implementation of the boundary condition for small cities is necessary to obtain Zipf’s law. It mimics the probabilistic effects of a ghost population of very small cities, as described in the main text.

Data

Data was obtained from two main sources, the US Census Bureau (USCB) and the US Internal Revenue Service (IRS). USCB provides a data set for the complete population in the US on a decennial basis. We use CPS Historical Migration/Geographic Mobility Tables44 as the main empirical basis in this paper. IRS data is released annually45. Migration rates are only implicitly given in this dataset. It provides locations of tax filings every year and corresponding (different) locations the year before. IRS data does not capture the whole population, since only the portion files tax returns (perhaps 85%). It nevertheless provides valuable insights into the migration patterns within the US.

In both cases data are provided at the county level. We aggregate the data to the level of Metropolitan Areas (MSA). MSAs are functional cities, defined as clusters of contiguous counties that have strong socio-economic ties to an urban core, measured via commuting fluxes. For this reason, MSAs are definition of urban areas as integrated labor markets. A crosswalk from counties to MSAs is provided by the National Bureau of Economic Research (NBER)55.

This data allows us to build all entries of the environmental matrices A and their migration flows. The net vital rates are given implicitly in both data sets via the total population change for each county in every year. We assume that the parts of the growth rates that can not be explained by national migration, stem from the balance of births, deaths, and international migration. All references to data are based on the matrices constructed this way on the basis of USCB and IRS data, except for Fig. 4, which is based on another data set from USCB53.