Skip to main content
Nature Communications logoLink to Nature Communications
. 2018 Aug 30;9:3538. doi: 10.1038/s41467-018-05750-z

Density-functional fluctuation theory of crowds

J Felipe Méndez-Valderrama 1,#, Yunus A Kinkhabwala 2,#, Jeffrey Silver 3, Itai Cohen 4, T A Arias 4,
PMCID: PMC6117271  PMID: 30166535

Abstract

A primary goal of collective population behavior studies is to determine the rules governing crowd distributions in order to predict future behaviors in new environments. Current top-down modeling approaches describe, instead of predict, specific emergent behaviors, whereas bottom-up approaches must postulate, instead of directly determine, rules for individual behaviors. Here, we employ classical density functional theory (DFT) to quantify, directly from observations of local crowd density, the rules that predict mass behaviors under new circumstances. To demonstrate our theory-based, data-driven approach, we use a model crowd consisting of walking fruit flies and extract two functions that separately describe spatial and social preferences. The resulting theory accurately predicts experimental fly distributions in new environments and provides quantification of the crowd “mood”. Should this approach generalize beyond milling crowds, it may find powerful applications in fields ranging from spatial ecology and active matter to demography and economics.


Tools from statistical physics can be used to investigate a large variety of fields ranging from economics to biology. Here the authors first adapt density-functional theory to predict the distributions of crowds in new environments and then validate their approach using groups of fruit flies.

Introduction

Identifying the role of social interactions and environmental influences on living systems has been the goal of many recent studies of collective population behavior115. Current agent-based models of crowds can reproduce many emergent behaviors, ranging from random milling to swarming, but often must postulate preconceived rules for individual agent interactions with each other and their environment110. In contrast to such bottom-up approaches, some studies have inferred interaction rules from observations of individual motions within a crowd for a few species of fish11,12, birds13, and insects14,15, but these studies have largely been limited to specific behaviors and have not been developed for making predictions under new circumstances. To date, a general predictive approach to emergent collective behavior in living systems has been lacking.

Such approaches, however, have been developed successfully for large collections of interacting atoms and molecules in the field of statistical physics. One of the central tenants of statistical physics is that generic thermodynamic behaviors emerge from underlying interaction rules among large numbers of particles16,17. Remarkably, these emergent behaviors are often insensitive to the detailed nature of the underlying interactions. Here, we pursue the hypothesis that a similar scenario emerges in the study of large crowds1822 so that behaviors arising from generic agent-based models can be predicted using a top-down approach. Accordingly, our strategy is to begin with a family of models that roughly capture the “microscopic” behaviors of individuals as they rearrange within a crowd. We do this, not because we are interested directly in individual behaviors, but rather because we are interested in the generic “macroscopic” behaviors that emerge in crowds en masse. This tack is not a priori obvious since active systems do not possess a fixed energy, their temperature is ill-defined, and there are no obvious equilibrium states23. Nonetheless, we show here that mathematical equivalents of free energy, the Hamiltonian, and equilibrium states arise naturally from plausible models of crowd behavior.

In this work, we present the following results. We introduce a general class of plausible agent-based models in which two different functions,“vexation” and “frustration,” quantify location and social preferences, respectively. For this class of models, we develop a coarse-grained approach stemming from classical density-functional theory (DFT) that allows us to determine the general mathematical form of the probability distributions describing a crowd. We then discuss the conditions a system must possess to be describable by our theory and test our approach using a living system consisting of walking fruit flies (Drosophila melanogaster), which we confine to a variety of two-dimensional environments. For this fruit-fly system, we successfully extract the vexation and frustration functions corresponding to a variety of different physical settings. Furthermore, these functions are sufficiently stable that, by mixing and matching functions from different experiments, we accurately predict crowd distributions in new environments. Finally, by exposing the fly system to conditions that elicit distinct social motivations, we are able to identify changes in the overall behavior of the crowd, i.e., its “mood,” by tracking the evolution of the social preference function.

Results

General mathematical form of crowd-density distributions

Consider, as an example, a crowd at a political rally (Fig. 1a). Under such circumstances, individuals will seek the best locations—presumably closest to the stage—while avoiding overcrowded areas where there is insufficient “personal space.” Moreover, individuals will, from time to time, move to new, better locations that become available.

Fig. 1.

Fig. 1

Resulting density-functional approach. a Schematic of crowd in which agents attempt to get as close to the stage as possible while avoiding overcrowding. b In the absence of interactions, the mean of each probability distribution (vertical dashed line) indicates location preference, from which we can extract a bin-dependent vexation functional, vb. c Resulting bin-dependent vexations. df Crowds in environments with uniform vexation but with neutral, repulsive, or attractive interactions. For neutral interactions, we expect complete spatial randomness leading to Poisson distributed counts within each bin. The repulsive and attractive interactions are thus reflected in the deviation of the probability distribution from the Poisson form26. From these deviations we can extract a bin-independent frustration functional, fN, whose curvature indicates the nature and intensity of the interaction

A plausible agent-based model of this behavior would assign an intrinsic desirability of each location x through a “vexation” function V(x) that takes its minimum value at the most ideal location near the stage. In addition, it would account for crowding effects through the local crowd areal density n(x) by introducing a “frustration” function f′(n), so that the relative preferablity of location x is actually the sum of vexation and frustration effects, V(x) + f′(n(x)). Finally, this model would include a behavioral rule to account for the tendency for individuals to seek improved locations. When an agent considers a move from location x to x′, the change in the agent’s dissatisfaction is ΔH ≡ (V(x′) + f′(n(x′)) − (V(x) + f′(n(x)). A rule where each agent executes such moves with probability 1/(eΔH + 1) captures the intuition that moves that increase the dissatisfaction ΔH > 0 are unlikely, and moves that decrease the dissatisfaction ΔH < 0 are likely, while moves where ΔH = 0 occur with 50% probability. The disadvantage of such an agent based modeling approach is that the rules for each agent are postulated and comparison with experiment requires gathering statistics from repeated simulations, each of which scales as the number of agents or worse. Again, our purpose here is not to develop such a model in detail, but rather to explore the top-level, global behaviors that emerge from this class of models, which we conjecture should apply to crowds more generally.

To extract such global behaviors, we develop a top-down approach by considering the system as a whole and summing the changes in the individual agent dissatisfactions ΔH to obtain a net global population dissatisfaction functional H[n(x)] (Methods). Integrating over dn and area element dA yields

H[n(x)]F[n(x)]+V(x)n(x)dA, 1

where the net frustration effect at location x is described by f(n)=f(n)dn, and a local density approximation24,25 F[n(x)]f(n(x))dA is in this case sufficient for capturing the crowd behavior. This global functional H[n(x)] and the model described above then lead mathematically to the prediction (Methods) that the probability for observing a crowd arrangement with density n(x) will be given by the probability density functional

P[n(x)]=Z-1exp(-H[n(x)]), 2

where Z is an overall normalization constant. Since we cannot measure the function n(x) directly in experimental crowds, we instead consider discrete counts of individuals within equal area bins (quadrats)26. Thus, to make contact with experiments we discretize Eq. 1 as H=bfNb+vbNb, where vb is the average value of the vexation V(x) over bin b, and fNbf(NbA)A approximates the total frustration contribution of bin b of area A (Methods). Substituting this discretization into Eq. 2, the overall probability factors into independent distributions for each bin of the form

Pb(N)=zb-11N!e-vbNe-fN, 3

where zb is a bin-dependent normalization constant and N! accounts for equivalent configurations among the bins (Methods). Thus, we predict that the fluctuations of the bin counts will be statistically independent and follow a modified Poisson form for each bin. This formulation dramatically reduces the complexity of the system description from tracking each individual to tracking the local density in each bin. Additionally, instead of rules with potentially complex interactions for each agent, the global system behavior of the density is determined by just two functions, vb and a bin-independent fN. Because this reduction in the number of variables is the result of transitioning to a local-density description as in classical density-functional theory, but now with the modification that interactions are inferred from density fluctuations, we call our approach density-functional fluctuation theory (DFFT).

Remarkably, rather than postulating these functions, they can be extracted directly from measurements of density distributions in each bin. In particular, in the case of neutral interactions (fN = 0), the bin counts will be single-parameter Poisson distributed, as expected for an experiment counting so-called completely spatially random events26. From the mean of these distributions one can extract an effective vb (Fig. 1b, c), or logarithm of the so-called intensity26, that can arise either from actual preferences for particular locations or from other kinetic interactions with the environment, such as slowing down near barriers27. In the case of interactions, such probability distributions can vary substantially from their non-interacting form (Fig. 1d) when the interactions are included (Fig. 1e, f). For example, so-called contagious distributions, which correspond to attractive interactions and show increased variance-to-mean ratios, have been observed26,28,29. If the interaction is strongly attractive, groups will form, resulting in a bimodal bin probability distribution corresponding to low and high density regions (Fig. 1e), with the high density region constrained by the packing limit. In contrast, highly repulsive interactions (Fig. 1f) lead to more uniform distribution of individuals in the crowd26 and will narrow the bin probability distribution. Finally, from distortions off of the Poisson form, we can determine an effective frustration function fN, without assuming any particular functional form, that describes any local interaction, attractive or repulsive. This formulation holds whether the interaction is directly related to density or to more complex factors such as orientation distributions, as well as higher-order many body interactions (Methods). The power of this approach is that, since vb is tied to the interactions with the environment and fN is tied to inter-agent interactions, it may be possible to combine vexations and frustrations from previous measurements to predict future crowd behaviors.

Several conditions must be met when applying this methodology to crowds under realistic circumstances. For example, the system must be sufficiently ergodic. Thus, the time scales for measurements must be longer than the system decorrelation time. In addition, the agent interactions with their environment should be sufficiently independent of the agent density, the agent interactions should be sufficiently independent of location, and both should be stable over the measurement time. Finally, bin sizes must be appropriately chosen. The bins must be large enough to yield reliable estimates of density, as well as to avoid trivial correlations in neighboring bins, yet small enough that the underlying vexation and local density are nearly constant across each bin.

Extraction of functionals for model system of walking flies

To test whether this approach applies to actual populations, we consider a model crowd consisting of wild-type male Drosophila melanogaster from an out-bred laboratory stock. It is well know that flies exhibit complex spatial preferences30,31 and social behaviors32,33. Here we seek to determine whether a large crowd of individuals with such complex behaviors indeed can be described within our vexation and frustration framework. The flies are confined in 1.5 mm tall transparent chambers where they can walk freely but cannot fly or climb on top of each other. We record overhead videos of the flies, bin the arena, and use custom Matlab-based tracking algorithms (Methods) to measure the individual bin counts Nb in each video frame. To explore a variety of behaviors, we use arenas of different shapes30 and apply heat gradients34 across the arenas to generate different spatial preferences. We find that the flies fully adjust to such changes in their environments after 5 min. We also find that the behavior of the flies changes slowly over a time scale of hours (Methods). We thus take care to make our observations over 10 minute windows during time periods where the behavior is stable.

A top down image of 65 flies in a quasi 1D arena that is uncomfortably heated on the right is shown in Fig. 2a. We find that a bin size of 0.15 cm2, corresponding to the area of approximately 7 flies, ensures that the counts are spatially independent (Fig. 2b) and that the density does not vary substantially over each bin. We also find that the decorrelation time for Nb is about 5 s (Fig. 2c) indicating the system is sufficiently ergodic over the time scale of our observation windows. We show representative probability distributions Pb(N) for a high and a low density bin in Fig. 2d, e, respectively. We find that the distribution peaks are centered at higher N near the left side of the chamber suggesting lower vexation there. Additionally, the high density probability distribution is significantly narrower than the fitted Poisson distribution, hinting that there are repulsive interactions among the flies.

Fig. 2.

Fig. 2

Statistical analysis and extraction of functionals for walking fruit fly experiments. a Single frame of 65 flies walking in a quasi 1D chamber of dimensions 10 cm × 0.8 cm divided into 48 bins with approximate area 0.15 cm2. Heat is applied on the right side of the chamber so that the temperature varies from 35 °C on the left to 50 °C on the right. b Averaged spatial correlation function. c Averaged temporal correlation function. de Probability distributions of the number of flies in the two bins outlined in a in red and magenta, respectively. f The “pseudo-free energy,” −ln(N!Pb(N)), for eight representative bins. The observed positive curvature indicates deviations from the Poisson form and repulsive interactions. g Frustration functional, fN, obtained from collapse of the pseudo-free energies for all 48 bins upon removal of the Poisson contributions. h Vexation for each bin as measured from the Poisson contributions to the pseudo-free energies. S.d. error bars in df computed from Bayesian posterior distribution assuming a Dirichlet prior. S.d. errors bars in g computed from linear propagation of errors displayed in f

To validate our description and quantify the vexations and frustrations, we plot what we call as a mnemonic the “pseudo-free energy” −ln(N!Pb(N)) = (vbN +ln zb) + fN versus N in Fig. 2f. To determine whether the frustration fN is indeed universal, we subtract a linear term corresponding to a bin-dependent vexation and normalization constant, vbN +ln zb, from each curve. Remarkably, the resulting curves can be made to collapse, indicating that a single, universal frustration function fN applies equally well to all bins (Fig. 2g). The positive curvature indicates that higher densities are less preferable than expected from non-interacting populations, and thus indicates repulsive interactions. We also show the bin-dependent vexation values vb used to collapse the curves in Fig. 2h. Finally, as an indicator of the strength of the collapse, we find that modifying the best least-squared fit Poisson distributions by including just eight universal frustration values (f0 through f7) decreases our reduced χ2 value for 166 degrees of freedom from 8.1 to 0.95. Additionally, our DFFT model is favored by the likelihood ratio test with probability p < 0.001 for accepting the hypothesis that the frustration values should be taken to be zero and a vexation-only model be used. This latter test confirms that the aforementioned reduction in χ2 is not a result of overfitting (Methods).

Predictions of crowd density under new circumstances

An important consequence of the physical independence of fN from vb is that it should be possible to use the frustrations extracted from the quasi-1D chamber to predict fly distributions in distinct vexations (Fig. 3). We demonstrate this capability by predicting the measured density distributions for large numbers of flies (on the order of 100) in three distinct geometries and temperature gradients (Fig. 3a). Using measurements of just a few flies in each chamber, we extract density distributions and determine the corresponding vexation vb. Combining this few-fly vexation for each environment with the many-fly frustration fN extracted from the quasi 1D geometry, we predict the fly distributions under dense conditions. Fig. 3b shows this procedure for the stair-case geometry. We find that the individual fly probability distributions (density normalized by total number of flies) for low and high densities are significantly different (Fig. 3c). In contrast, including the interactions through our DFFT approach predicts a more homogeneous population that matches the observed distribution (Fig. 3d). These results demonstrate that, using our DFFT analysis, it is indeed possible to make accurate predictions by combining vexations from low-density experiments in different environments with a frustration that corresponds to a particular behavior (“mood”).

Fig. 3.

Fig. 3

Predictions of large crowd distributions in three new environments. a Experimental observations of dense crowds (124, 219, and 189 flies) in three chambers with different geometries, two with applications of heat creating temperature differences of up to 20 °C. b Measured single-fly probability distributions, NAve/NTot. cd DFFT protocol applied to the stair-case geometry. c Measurement of the density for 3 flies is used to determine the vexation, vb. d Combining this vexation with the extracted quasi 1D frustration from Fig. 2 leads to the high density DFFT prediction. e Comparison of single-fly probabilities for the sparse and dense populations shows significant population shifts as indicated by a correlation coefficient r = 0.73 and a σmean = 3.8. f DFFT analysis that incorporates interactions predicts the measured dense population distribution within statistical uncertainty (r = 0.96 with a σmean = 1.0). Vertical error bars correspond to s.d. of bin-occupation distributions and horizontal error bars correspond to s.e.m. of the observed density within a given bin

Frustration used to quantify the “mood” of a crowd

Conversely, by keeping the environmental conditions fixed and analyzing different time points in the experiments or changing the ratio of male to female flies, the resulting change in “mood” can be quantified by extracting the corresponding functionals. For example, after spending about six hours in the chamber without food or water, the flies exhibit transient groups or clusters of about 10-20 individuals. This change in behavior is quantified by the different curvatures for the frustrations fN characterizing the initial (blue curve) and deprived states (red curve) in Fig. 4. The nearly flat frustration associated with this behavior indicates that male flies are willing to surmount their natural repulsion and form higher density groups under deprivation conditions, a previously undocumented spontaneous self-organized change in collective behavior31,32,35. Attraction between individuals can be induced by introducing female flies. For groups of flies with equal numbers of males and females which have been separated for several days, we find pair formation (yellow ellipses). This behavior is characterized by a sharp downward curvature in the frustration at low N (yellow curve). Exposing this population to similar deprivation conditions drives formation of larger groups (purple circle) at the expense of pair formation. This behavior is captured by the shift of downward curvature in the frustration to larger bin occupations of N≈7 (purple curve). These data establish that the DFFT approach has the power to detect and quantify changes in social behaviors.

Fig. 4.

Fig. 4

Extracting frustrations to quantify changing behavior. Frustrations measured for flies in a 4 cm square chamber. The experiment duration was seven hours. The frustrations were extracted from two different 10 minute intervals corresponding to the initial and final stages of experiments on two different populations. The blue curve (90♂) exhibits a positive curvature at all occupancies, indicating an aversion to crowding at all densities. The red curve characterizes interactions for the same population 6 hours later. The lower curvature indicates significantly reduced aversion to grouping. The yellow curve (30♂ + 25♀) exhibits a downward curvature at low occupations, reflecting mating interactions between pairs of flies (yellow ellipses). At higher occupancies, the lack of curvature indicates a more neutral response to changes in occupation number. Finally, the purple curve characterizes interactions for the same mixed-sex population 6 hours later. The downward curvature shifts to higher occupancies and is followed by a region of positive curvature. The corresponding inflection point indicates a preference for group formation with a density of about eight flies per bin. S.d. error bars calculated from the maximum likelihood (ML) covariance matrix of DFFT distribution in Eq. 3

Discussion

Collectively, these results demonstrate that top-down approaches are a promising method for predicting crowd distributions and quantifying crowd behaviors. The DFFT analysis that we present is particularly powerful because it separates the influence of the environment on agents from interactions among those agents. This separation then enables predictions of crowd distributions in new situations through mixing and matching of the vexations and frustrations from previous observations in different scenarios. In addition, the real-time quantification of frustrations opens the door to tracking behavioral changes and potentially extrapolating the time evolution of frustrations to anticipate future behaviors.

There are a number of directions in which the formal framework suggested here can be extended, paralleling developments from the traditional density-functional theory literature. Extensions to time-dependent DFT methods (TDDFT)36,37 would enable the prediction of situations in which crowds gather and disperse in response to changes in the environment. This approach would also apply to situations in which the center of mass of the entire group is moving as whole, such as in herd migration and bacterial and insect swarming. Moreover, by including the local current density (“flow”) in the functional, such approaches may even be able to describe crowds where correlated subgroups move with different local velocities, such as in flocks of birds. Likewise, extensions to multicomponent DFT38 would enable corresponding predictions and observations in crowds composed of distinct groups exhibiting interactions such as inter-group conflict, predator-prey relations, or mating behavior.

Should these results extend to human populations, the implications are profound. From publicly available video data of people milling in public spaces, this approach could predict how people would distribute themselves under extreme crowding. Additionally, a simple application running on a hand-held device could easily measure density fluctuations and extract functionals that are indicative of the current behavioral state or mood of the crowd. Through comparison with a library of functionals measured from past events, such an application could provide early warning as a crowd evolves towards a dangerous behavior. Finally, given the recent proliferation of newly available cell-phone and census data39,40 these approaches may also extend to population flows on larger scales, such as migration. Here, vexations could correspond to political or environmental drivers and frustrations to population pressures. The resulting predictions of migration during acute events would enable better planning by all levels of government officials, from local municipalities to international bodies40,41, with the potential to save millions of human lives.

Methods

Global dissatisfaction functional H[n(x)]

The main text describes a net global population dissatisfaction functional H[n(x)]. To derive this functional, we begin by considering a deterministic model, in which agents reject or accept potential moves with unit probability according to whether ΔH ≡ (V(x′) + f′(n(x′)) − (V(x) + f′(n(x)) is positive or negative, respectively. In such a model, it is clear that equilibrium is attained and all motion ceases when ΔH = 0 for all pairs of points x and x′. This statement is equivalent to the combination V(x) + f′(n(x)) attaining some constant value μ across the system,

V(x)+f(n(x))=μ. 4

This equation corresponds precisely to the Lagrange-multiplier equation for minimization of the functional

H[n(x)]f(n(x))dA+V(x)n(x)dA, 5

subject to the constraint of fixed number of agents N=n(x)dA, with μ being the corresponding Lagrange-multiplier. Here, μ plays an analogous role to the “chemical potential” from Statistical Physics.

Probability density functional P[n(x)]

To make the transition to the probability functional P[n(x)], we note that the stochastic model described in the text maps directly onto a particular Markov chain. Each step on this chain corresponds to a three-stage process. First, (a) an agent is selected at random to consider a possible move from current location x. Selecting a random agent at each time step allows agents to adjust their locations at equal rates. In this approach, choosing the physical time interval between Markov steps to be inversely related to the number of agents preserves the time scale of the overall crowd dynamics. Second, (b) a location x′ nearby x is selected at random as a move to be considered by the given agent. We note that for this work, we assume that the new location x′ is selected in a symmetric way so that that agents at x contemplate moves to x′ with the same probability that agents at x′ contemplate moves to x. This assumption seems most plausible given the systems we consider here. Other selection criteria, however, are possible and would modify the distribution below. Finally, (c) the contemplated move is accepted or rejected according to the probability 1/(eΔH + 1), where ΔH is defined specifically as the change in the value of the functional described in Eq. 5 as a result of the move.

There are two critical things to note about this Markov chain. The first is that it gives a very natural description of agent behavior. The second is that it corresponds precisely to the standard Metropolis-Barker algorithm42,43 for drawing random samples from the Boltzmann distribution P ∝ exp(−H) for a Hamiltonian H. Thus, under our proposed motion model, the population itself naturally samples from the distribution quoted in the text,

P[n(x)]=Z-1exp(-H[n(x)]). 6

Discretization Hb(fNb+vbNb)

To arrive at the discretization described in the text, it is important to note that the density n(x) appearing in the probability functional P[n(x)] corresponds to the fluctuating crowd density, as opposed to the average density nave(x). As such, in practice, this density must be described in terms of the discrete locations xa of all agents a in the crowd at any give time. The most natural description for the associated density operator is

n(x)=aδ(σ)(x,xa), 7

where δ(σ)(x, xa) is a function describing the range over which the presence of an agent at xa contributes to the density n(x) at point x. To conserve number of agents, this function must integrate to unity. The analysis carried out in the text divides space into bins b of area Ab, and estimates the density in each bin as n = Nb/Ab where Nb corresponds to the total number of agents in bin b. This definition sets the range function as

δ(σ)(x,xa)1Abifxandxaareinthesamebinb0otherwise 8

To capture relevant variations in vexation and density, the bins cannot be selected so large that these quantities vary significantly across each bin. Alternately, to avoid missing the effects of nearby agents, the bins cannot be selected to be smaller than the agent’s interaction range.

Finally, combining equations 5, 7, and 8, yields

H[n(x)]=bfNb+bvbNb, 9

where fNbf(NbAb)Ab and vbbV(x)dAAb.

Bin occupation probability distributions Pb(N)

To arrive at the final discrete probability expression in the text, there are now two routes. One can directly insert Eq. 9 above into Eq. 2 from the main text, or one can employ Eq. 9 directly to compute ΔH to determine the probabilities for moves. In the latter case, the predicted probability distribution becomes exact so long as we interpret f′(n) in the main text at points x′ and x to represent forward and reverse finite difference derivatives f+(n(x))=(f(n(x)+Δ)-f(n(x)))Δ and f-nx=fnx-fnx-ΔΔ, respectively, where Δ ≡ 1/Ab. Finally, because the Boltzmann factor above gives probabilities for individual arrangements of agents among bins, we must account for the multiple ways to realize a set of bin counts {Nb} by permuting individuals among the bins. Multiplying by the combinatorial factor Ntot!/(N1!…Nb!…), we find

P({Nb})=Ntot!Zbe-fNb-vbNbNb!, 10

where Z is a normalization factor.

As described in the text, we note that the form of the joint probability distribution above predicts the occupations of different bins to be very nearly statistically independent. The only deviation from complete statistical independence comes from the constraint of a fixed total number of agents Ntot=bNb. Due to this constraint, the probability distribution is difficult to use in making predictions. We can overcome this difficulty using a standard technique from statistical physics. Specifically, introducing a factor eμNtot removes the constraint without significantly affecting the calculated local distributions. As a result, the individual bin distributions then become statistically independent and of the form

Pb(N)=zb-11N!e-(vb-μ)Ne-fN. 11

In statistical physics this mathematical transformation corresponds to using a Grand Canonical Ensemble44 to simplify statistical calculations. Physically, this approach corresponds to relaxing the constraint of a fixed number of agents by allowing exchanges between the system being considered and a large reservoir whose vexation is controlled by μ. Mathematically, we can add and subtract a constant within the exponent, (vb − c − (μ − c)) without affecting the distribution. Accordingly, we redefine vb and μ with a constant shift such that vb ← vb − c and μ ← μ − c and, further, choose c so that μ = 0, resulting in Eq. 3 in the text. Note that motion between bins is controlled only by differences in vexations, so that none of this affects the dynamics represented in our analysis. When considering a different number of agents in the same chamber, however, μ will take on a different value and so μ − c can no longer be set to zero. Accordingly, to predict distributions for new numbers of flies, we employ Eq. 11 above and adjust μ so that the vexation of the associated reservoir fixes the new total number of flies.

Orientation and higher-order many-body interactions

Remarkably, our conclusions hold also for plausible models in which the inter-agent interactions are not explicitly expressed in terms of the local density n(x). To see this, we can consider the same behavioral rule of moves accepted according to probability 1/(eΔH + 1), but with H now defined as a sum of two parts,

HU(xa)+aV(xa), 12

where V(x) is the usual vexation function for the individual agents, and now U(xa) is some potentially complex many-body interaction of finite range depending explicitly on the locations of all of the agents xa.

As above, the form of the Markov chain associated with the move model leads directly to the Boltzmann distribution P(xa) = Z−1eH. To recover the frustration-vexation probability form analyzed throughout the text, we now follow the standard Statistical Mechanics approach of defining an pseudo-free-energy functional by integrating out internal degrees of freedom. Specifically, we will keep the bin occupancies constant while integrating over all arrangements of agents consistent with these occupancies. For sufficiently small bins in which vexation does not vary significantly, we again find to a good approximation aV(xa)=bvbNb, so that vexation simply gives a constant factor. Next, for sufficiently large bins, the net contributions to U(xa) from interactions occurring within the bins will be large compared to the boundary effects from contributions from interactions crossing bin boundaries. Thus, we can imagine decomposing the overall interaction into a sum over the bins of the interactions just among agents a within each bin b, U(xa)=bU({xa}ab), where we can improve accuracy by repeating the same agent locations {xa}ab in neighboring bins (so-called periodic boundary conditions).

Combining these approximations, and summing over all ways to assign agents to bins with counts {Nb} and over all possible locations for the agents within each bin, yields the same frustration-vexation form considered throughout the text,

PNb=Z-1NN1!NB!be-fNbe-bvbNb, 13

where B is the total number of bins, and

e-fNAAe-Ux1,,xNdA1dAN 14

defines the effective bin-frustration functional fN as an N-dimensional integral over the area of a single bin (with periodic boundary conditions applied to the interactions). Finally, we note that the above generalizes naturally to orientation-dependent interactions by considering the coordinates {xa} to include orientation, as well as spatial coordinates. If the vexation is orientation-independent, we recover precisely the form above. Otherwise, the entire framework generalizes naturally to consideration of joint location-orientation densities n(x,θ).

Experimental setup

All experiments were performed 3–15 days post-eclosion using common fruit flies (D. melanogaster) from an out-bred laboratory stock reared at room temperature on a 12 h/12h day-night cycle. Flies are anesthetized using CO2 and sorted within a few days post-eclosure. We wait for 24 h after sorting before running experiments. Most observations started between 1–5 h after the light was turned on. The experiment chambers are constructed by sandwiching a 1.5 mm thick aluminum frame between two transparent acrylic sheets. The chamber is suspended above an LED light table. Holes in the upper acrylic sheet allow for the introducing flies via aspiration from above. To heat the chambers, 2 Ω high-power resistors are adhered using JB Weld to the aluminum sheet and powered by a variable power supply. On the opposite side of the sheet, a beaker of ice water is used as a heat sink. Chamber temperature is measured for two locations using a contact thermometer to ensure no more than 2 degrees Celsius drift and consistent temperature gradients between trials. We heat one side of the chamber to temperatures between 40–50 degrees Celsius34. The opposing side of the chamber is connected to a heat sink and kept at temperatures between 25–35 degrees Celsius. We find that the resulting temperature gradient drives a strong avoidance behavior for the hotter wall while avoiding fly death as the flies avoid the high-temperature region. A video camera (AVT Marlin, Andover, MA) records overhead images of flies at frame rates around 30 fps and relays these images to a computer where they are analyzed by a custom MATLAB program in real-time. The entire apparatus was enclosed in a black box to prevent biases introduced by ambient light or additional visual cues.

Image analysis

To label fly centroids, images were thresholded to find fly silhouettes. For high density experiments, large groups become common and a more sophisticated approach is necessary to separate clusters, which may be as large at 10 flies. First, the images of several individual flies are combined to make a single, averaged fly mask. This mask is then convolved with images of fly groups. The best fits for these convolutions are used to approximate the locations of flies whose silhouettes overlap. (For additional details, see code provided under Code Availability statement below.) Labeling is then manually checked and we find this technique robust enough to label male flies with 0.25 % error or 1 in 400 flies mislabeled. The mating flies required extensive manual corrections due to changes in the fly postures and the polydispersity of fly sizes, since females are larger than males. For the analysis in this paper we sampled these positions at intervals of 1 s.

Due to wall-exclusion effects, the area of a chamber is different from the area accessible by the centroid of a fly. We thus exclude the outer area of the chamber that corresponds to approximately half the width of a fly. Areas of the bins are then extracted using images from the experiment.

To demonstrate another method for tracking flies that only measures local densities, a simpler method was used for counting flies in the “C” shaped chamber. After thresholding, the number of pixels corresponding to a fly were summed in each bin and then a discrete fly density was assigned to each bin using knowledge of the total number of flies in the chamber. This method has the advantage of computational speed, but weights larger flies more heavily and requires reanalysis for different bin sizes.

Measurement timing and thermal ramp protocol

Observations for Fig. 3 were conducted using time intervals from approximately 5–15 min after being introduced into the chamber so that the flies could explore their new chamber and adjust to a steady state. To measure the vexation of the square experiment, we performed 12 separate single fly measurements each lasting 10 min. Similar results are obtained if three flies are used over a single 10 min period. Thus, measurements of vexation in the “C” and stair shaped chambers used two and three concurrent flies and only needed a single ten minute observation to measure the vexation.

To probe the changing fly behaviors shown in Fig. 4, we track the flies for up to 9 h before flies begin to die from deprivation45,46. To test whether fly behavior is changing over our standard 10 minute time windows, we compare the probabilities, Pb(N), from the first 5 min of the window with the last 5 min and find that they are consistent. The only exception to this is during the very first 5 min after the flies are introduced into the chamber as they become oriented to their new environment that we do not include in our analysis. To elicit different behaviors and location preferences with the same population of flies, we apply a heat gradient to generate an avoidance behavior34 starting at 20 min after being introduced to the chamber. By minute 30, the chamber has reached a steady temperature and we observe that the flies exhibit an approximately constant average distribution. At minute 40, we turn the heat off and let it adjust to room temperature for the remainder of the experiment. Throughout these observations, we qualitatively observe several different behaviors. For the first 5 min, flies are most active and their frustration has a slightly higher positive curvature than the frustration for the 5–15 min period. When the chamber is heated, the frustration stays approximately the same despite the drastic change in the vexation. After the chamber cools down, flies enter a readjustment phase where they are much less active. After this readjustment phase, however, flies again exhibit behavior similar to that from the 5–15 min interval. By 6 h, flies in all the experiments switch to a grouping behavior as shown in Fig. 4.

Validation of assumptions underlying theoretical analysis

As mentioned above, we made some general assumptions developing our theory which we now validate for the walking fly system. First, to verify attainment of equilibrium and sufficient ergodicity, we consider the normalized autocorrelation function

cT(Δt)bNb(t)Nb(t+Δt)tbNb(t)Nb(t)t, 15

where <…>t indicates average over all times. This function shows the expected rapid exponential decay (Fig. 2c), and has an integral which gives the decorrelation time τ = 0.92 s. Indeed, we find this time to be quite short, typically on the order of a few seconds, for all of our experimental runs. This decay time is two orders of magnitude faster than the typical run time and does not vary significantly when computed in different time sub-windows, strongly suggesting rapid mixing and stationarity of the random process, thereby allowing the interchange of time and ensemble averages, and establishing the existence of equilibrium in the timescales under study. Our videos thus represent hundreds of independent samples drawn from the equilibrium ensemble underlying our analysis.

We next consider whether the bins are truly independently distributed as expected in Eq. 3. Accordingly, we consider the normalized time-averaged spatial-correlation function

cS(Δ)bNb(t)Nb+Δ(t)b,tNb(t)Nb(t)b,t, 16

where <…>b,t indicates average all times and bins, and Δ is the two-dimensional vector displacement between bins (Fig. 2b)). The data show essentially no correlation between bins, thereby verifying the product form of the global bin distribution function in Eq. 3 in the main text. This confirms not only that we have chosen appropriately sized bins but also, more fundamentally, establishes that there are little or no fly–fly interaction effects between bins, so that the local density approximation (LDA) form for the frustration, F[n(x)]=f(n(x))dA, indeed gives a good representation of the behavior of the fly populations at scales greater than 0.15 cm2.

Parameter estimation

To estimate the frustration and vexation for the crowds in our experiments, we start by constructing the posterior function P(fN, vb|Nb(t)), which represents the relative likelihood of different parameter choices for our model given the data (number counts within each bin) that has actually been observed. Then, to find the a posteriori estimate of the parameters, we maximize this likelihood by performing a numerical gradient minimization of

-lnP(fN,vbNb(t))=C+TBlnzbb+vbNb(t)+lnNb(t)!+fNb(t)b,t+NfN22σ2+bvb22σ2, 17

where C is an irrelevant normalization constant, B corresponds to the total number of bins in the system, T the total number of independent time samples employed, and 〈…〉b and 〈…〉b,t represent averages over either all bins or bins and times, respectively. Finally, for the last two terms, σ accounts for the range about zero of a Gaussian prior distribution on the frustration and vexation parameters. This Gaussian prior distribution reflects the fact that the frustration and vexation parameters vb and fN can in principle take any real value, but in practice generally fall in a range on the order of from about −15 to 15 because these parameters enter as exponentials in our probability models. Because the amount of data that we handle is on the order of tens of thousands of frames, the likelihood peaks strongly around its maximum, and the precise form of the Gaussian prior is largely irrelevant. Indeed, changing the value of σ from a reasonable value of 15 to an unreasonably small value of 1, only changes our final results for the frustration by 11.4%. Throughout the rest of our work, we take σ = 15.

Uncertainty in parameter estimation

The sharp peaks associated with the large amount of data ensure the accuracy of the asymptotic Gaussian approximation, in which the joint probability distribution representing the range of parameters supported by the data is a multivariate Gaussian distribution. As a result, the associated covariance matrix of uncertainties in the parameters is the inverse of the Fisher information matrix I (i.e., the second derivative of −lnP evaluated at the location of its maximum). The matrices of parameter uncertainties and cross-correlations among them are computed as follows. For our full DFFT model, with vexation and frustration, and the simple Poisson model, with vexation only, we calculate the inverses of the following matrices, respectively,

IDFFT({fN},{vb})=IffNmax×NmaxIfvNmax×BIfvTNmax×BIvvB×B, 18

and

IPoisson({vb})=IvvB×B, 19

where the matrix elements of each block are

IffN,N=TδNNb¯Pb¯N-b¯Pb¯NPb¯N 20
IfvN,b=TPbNN-N~N~PbN~ 21
Ivvb,b=TδbbN~N~2PbN~-N~N~PbN~2. 22

Here, Pb(N) is defined as in Eq. 3 in the main text, T again represents the total number of independent time frames, and the “ ~ ” indicates internal summation indices.

Finally, a subtle, but important, ambiguity arises in the extraction of frustrations and vexations. Specifically, because the exponent in the observed probabilities for each bin takes the form (ln zb + vbN + fN), making the replacements (vb → vb − α; zb → zb − β; fN → fN + β + αN;) leaves the predictions of the model unchanged, and any choice of parameters corresponding to these replacements represents the data equally well. As a result, the Fisher matrices described above are singular. To resolve this “gauge invariance” and remove the singularity, we must break the symmetry among equivalent models by adding two constraints (one for α and one for β) to our choice of fN. Here, we do this by enforcing the natural choice that f0 ≡ 0 and f1 ≡ 0, corresponding to the convention that that the frustration does not affect the probability for bins with either N = 0 or N = 1 flies. Finally, in terms of the information matrices above, implementing this constraint corresponds to dropping the first two rows and columns associated with these parameters from the IDFFT matrix.

Uncertainty in predictions of average occupations

With the uncertainties in the extraction of the vexation and frustration parameters from above, we next determined the uncertainties in our predictions of the average bin occupations for large populations in new arenas. The predicted mean densities are

N¯b=N=0NmaxNPb(N)=1zbN=0NmaxNe-(vb-μ)N-fNN!, 23

where the normalization is

zb=N=0Nmaxe-(vb-μ)N-fNN!, 24

where Pb(N) is the probability of having N flies in bin b, vb is the vexation in bin b, and fN is the frustration associated with having N flies in a bin. We accordingly computed the associated uncertainties using standard linearized error propagation as

σ(N¯b)=N¯bvb2var(vb)+N,N=2NmaxN¯bfNN¯bfNcovar(fN,fN), 25

where var(X) and covar(X, Y) represent the variance of random variable X and covariance between X and Y, respectively, as determined by the inverse of the Fisher information matrix as discussed above. Finally, the derivatives needed in Eq. 25 are

N¯bvb=-Nb2-N¯b2, 26

and

N¯bfN=-Nb-N¯bZe-Nb(vb-μ)-fNbNb!, 27

where Nb2NN2Pb(N) with Pb(N) as defined above.

A few technical notes are in order to understand the terms present in Eq. 25. First, note that cross-correlations between vexations in different bins are not relevant because N¯b depends solely on vb and not on vexations from other bins. Also, cross-correlations between extracted vexations vb and frustrations fN are zero in our case because we extract the vexations and frustrations from different, and thus independent, experiments when making our predictions for average occupations. Finally, the uncertainties in f0 and f1 are not included because these uncertainties are zero due to the gauge choice discussed in the section above.

Uncertainty in experimentally measured bin statistics

For each independent bin, we obtain from the experiment a sequence of length NT with elements each corresponding to a bin occupation that can range from zero to the maximum packing of files, N = 0,…,Nmax. From this data, we hope to extract probability parameters pN describing the bin occupation distributions studied in the main text. For simplicity of notation, we here use lower case p to denote experimentally measured probabilities.

To account for time-correlations in bin occupancies, particularly at high frame rates, we down-sample at intervals given by the decorrelation time τ and actually consider uncorrelated sequences of length T = NT/τ. The data then correspond to the result of a random process of making T independent selections among Nmax + 1 possible bin occupations. Thus, for each bin, the probability of observing a given data sequence becomes the multinomial distribution,

Th0hNmaxp0h0pNmaxhNmax, 28

where hN represents the number of times (“hits”) we observe each of the possible occupancies N.

To extract the underlying uncertainties, we note that Bayes’ theorem gives the following distribution for the probability parameters to take the values {pN} given the actually observed counts {hN},

P({pN}{hN})=P{hN}{pN}P{pN}P({hN})n=0Nmaxpnhnhn!P({pN}). 29

This posterior probability is proportional to an undetermined prior probability P({pN}) describing our a priori expectations for the values of the {pN} parameters. However, as per our discussion surrounding Eq. 17 above, in the large T limit, the Poisson-like product factor in Eq. 29 above will be highly peaked, and the unknown prior P({pN}) will not have a substantial effect on the posterior distribution.

To completely eliminate the effects of unwarranted assumptions entering through our choice of prior, we assume an uninformative prior distribution that is consistent with the invariance of the probability values under the inclusion of new samples, and choose the multivariate generalization of Haldane’s uninformative improper prior distribution47,

P({pN})=1n=0Nmaxpn. 30

With this choice, upon normalization, Eq. 29 becomes the Dirichlet distribution,

P({pN}{hN})=Γn=0NmaxhNN=0NmaxpNhN-1Γ(hN), 31

where Γ(x) is the Gamma function. This distribution yields expected values for the probabilities equal precisely to the observed frequencies p¯N=hNT. The variances of this distribution, then give our desired uncertainties,

σ(pN)=hNT-hNT2(T+1)=p¯N(1-p¯N)T+1. 32

Note that when T is large and p¯N1, the uncertainties correspond to what we would naïvely expect from Poisson counting, namely an uncertainty of hN in the counts, corresponding to an uncertainty of hNT=p¯NT in the extracted probabilities. Such an analysis, however, misses the important factor of 1-p¯N and leads to significant errors in our case.

Finally, for the uncertainty in the experimental average occupation N¯expt=NNpN, the corresponding variance is

varN¯expt=NNNNcovarpN,pN+NN2σ(pN)2, 33

where the needed covariances of the Dirichlet distribution are

covar(pN,pN)=-hNhNT2(T+1)=-p¯Np¯NT+1 34

Code availability

Readers can access the code related to parameter estimation and crowd density predictions by going to (https://github.com/MendezV/DFFT) or to (10.5281/zenodo.1285931). Readers can also access code related to image analysis procedures by visitng (https://github.com/yunuskink/Fitfly-fly-tracking) or (10.5281/zenodo.1304326). There are no access restrictions to this software.

Data availability

The fly density data that support the findings of this study are available in the Open Science Framework database at (10.17605/OSF.IO/7UBZ2).

Electronic supplementary material

Peer Review File (245.5KB, pdf)

Acknowledgements

The authors thank Xiaoning Wang, Marc-Antoine Bouvattier, Alonso Botero, Tom Corwin, Tom Mifflin, Greg Godfrey, and Nathan Sitaraman for their help with the initial stages of the project. We further thank the Cohen and Arias groups for discussions throughout this work. The work was primarily funded by the Army Research Office Army-ARO W911NF-16-1-0433. J.F.M. was also supported in part by an Office of the Vice President for Research at the University of Los Andes. Y.K. was also supported in part by funding from the National Science Foundation Graduate Research Fellowship Award No. DGE-1650441.

Author contributions

J.F.M.V.: Development and implementation of analyses to extract vexations, frustrations, and predicted mean occupations. Analysis of statistical uncertainties in all of these quantities and also in the extraction of bin-occupancy distributions from experimental data. Final display format for cross-correlating predicted mean occupancies with predictions. Theoretical parts of the Methods Section. Significant contributions to main text. Y.A.K.: Design and implementation of experiments along with development of image analysis techniques. Running data through analyses provided by Méndez Valderrama. Experimental parts of the Methods Section, design, and implementation of figures, and an early draft of the manuscript. Significant contributions to main text. Y.A.K. and J.F.M.V. contributed equally to this work. J.S.: Co-development of underlying Markov chain, proper accounting for degeneracy factor, identification of multinomial and Poisson distributions for the non-interacting case, initiation of use of maximum-likelihood estimation and Bayesian uncertainty techniques. I.C.: Significant input into design of experiments, and primary responsibility for main text. T.A.A.: Development of underlying motion model, density-functional theory analysis, and prediction of form of population fluctuations. Co-development of underlying Markov chain. Complete early draft of manuscript, and significant contributions to main text.

Competing interests

The authors declare no competing interests.

Footnotes

Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

These authors contributed equally: J. Felipe Méndez-Valderrama, Yunus A. Kinkhabwala

Electronic supplementary material

Supplementary Information accompanies this paper at 10.1038/s41467-018-05750-z.

References

  • 1.Silverberg JL, Bierbaum M, Sethna JP, Cohen I. Collective motion of humans in mosh and circle pits at heavy metal concerts. Phys. Rev. Lett. 2013;110:228701. doi: 10.1103/PhysRevLett.110.228701. [DOI] [PubMed] [Google Scholar]
  • 2.Helbing D, Farkas I, Vicsek T. Simulating dynamical features of escape panic. Nature. 2000;407:487. doi: 10.1038/35035023. [DOI] [PubMed] [Google Scholar]
  • 3.Bellomo N, Dogbe C. On the modeling of traffic and crowds: a survey of models, speculations, and perspectives. SIAM Rev. 2011;53:409–463. doi: 10.1137/090746677. [DOI] [Google Scholar]
  • 4.Leonard, N. E. & Fiorelli, E. Virtual leaders, artificial potentials and coordinated control of groups. Decision and Control, 2001. In Proceedings of the 40th IEEE Conference on, Vol. 3, 2968–2973. (IEEE, 2001).
  • 5.Couzin ID, Krause J, Franks NR, Levin SA. Effective leadership and decision-making in animal groups on the move. Nature. 2005;433:513. doi: 10.1038/nature03236. [DOI] [PubMed] [Google Scholar]
  • 6.Vicsek T, Czirók A, Ben-Jacob E, Cohen I, Shochet O. Novel type of phase transition in a system of self-driven particles. Phys. Rev. Lett. 1995;75:1226. doi: 10.1103/PhysRevLett.75.1226. [DOI] [PubMed] [Google Scholar]
  • 7.Moussad M, Helbing D, Theraulaz G. How simple rules determine pedestrian behavior and crowd disasters. Proc. Natl Acad. Sci. USA. 2011;108:6884–6888. doi: 10.1073/pnas.1016507108. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 8.An L. Modeling human decisions in coupled human and natural systems: review of agent-based models. Ecol. Model. 2012;229:25–36. doi: 10.1016/j.ecolmodel.2011.07.010. [DOI] [Google Scholar]
  • 9.Zheng X, Zhong T, Liu M. Modeling crowd evacuation of a building based on seven methodological approaches. Build. Environ. 2009;44:437–445. doi: 10.1016/j.buildenv.2008.04.002. [DOI] [Google Scholar]
  • 10.Treuille A, Cooper S, Popović Z. Continuum crowds. ACM Trans. Graph. 2006;25:1160–1168. doi: 10.1145/1141911.1142008. [DOI] [Google Scholar]
  • 11.Hinz RC, de Polavieja GG. Ontogeny of collective behavior reveals a simple attraction rule. Proc. Natl Acad. Sci. USA. 2017;114:2295–2300. doi: 10.1073/pnas.1616926114. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 12.Katz Y, Tunstrøm K, Ioannou CC, Huepe C, Couzin ID. Inferring the structure and dynamics of interactions in schooling fish. Proc. Natl Acad. Sci. USA. 2011;108:18720–18725. doi: 10.1073/pnas.1107583108. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 13.Ballerini M, et al. Interaction ruling animal collective behavior depends on topological rather than metric distance: evidence from a field study. Proc. Natl Acad. Sci. USA. 2008;105:1232–1237. doi: 10.1073/pnas.0711437105. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Berman GJ, Choi DM, Bialek W, Shaevitz JW. Mapping the stereotyped behaviour of freely moving fruit flies. J. R. Soc. Interface. 2014;11:20140672. doi: 10.1098/rsif.2014.0672. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 15.Kelley, D. H. & Ouellette, N. T. Emergent dynamics of laboratory insect swarms. Sci. Rep., 3, 1073 (2013). [DOI] [PMC free article] [PubMed]
  • 16.Boltzmann, L. Über die mechanische Bedeutung des zweiten Hauptsatzes der Wärmetheorie:(vorgelegt in der Sitzung am 8 February 1866). (Staatsdruckerei, 1866).
  • 17.Diderik Van der Waals, J. Over de Continuiteit van den Gas-en Vloeistoftoestand, volume 1. Sijthoff, 1873.
  • 18.Toner J, Tu Y. Flocks, herds, and schools: a quantitative theory of flocking. Phys. Rev. E. 1998;58:4828. doi: 10.1103/PhysRevE.58.4828. [DOI] [Google Scholar]
  • 19.Mora T, Bialek W. Are biological systems poised at criticality? J. Stat. Phys. 2011;144:268–302. doi: 10.1007/s10955-011-0229-4. [DOI] [Google Scholar]
  • 20.Cavagna A, et al. Dynamic scaling in natural swarms. Nat. Phys. 2017;13:914. doi: 10.1038/nphys4153. [DOI] [Google Scholar]
  • 21.Tennenbaum M, Liu Z, Hu D, Fernandez-Nieves A. Mechanics of fire ant aggregations. Nat. Mater. 2016;15:54. doi: 10.1038/nmat4450. [DOI] [PubMed] [Google Scholar]
  • 22.Sinhuber Ml, Ouellette NT. Phase coexistence in insect swarms. Phys. Rev. Lett. 2017;119:178003. doi: 10.1103/PhysRevLett.119.178003. [DOI] [PubMed] [Google Scholar]
  • 23.Solon AP, et al. Pressure is not a state function for generic active fluids. Nat. Phys. 2015;11:673. doi: 10.1038/nphys3377. [DOI] [Google Scholar]
  • 24.Sham LJ, Kohn Wr. One-particle properties of an inhomogeneous interacting electron gas. Phys. Rev. 1966;145:561. doi: 10.1103/PhysRev.145.561. [DOI] [Google Scholar]
  • 25.Hohenberg P, Kohn W. Inhomogeneous electron gas. Phys. Rev. 1964;136(3B):B864. doi: 10.1103/PhysRev.136.B864. [DOI] [Google Scholar]
  • 26.Diggle, P. J. Statistical Analysis of Spatial and Spatio-Temporal Point Patterns, Third Edition. Chapman & Hall/CRC Monographs on Statistics and Applied Probability. (CRC Press, 2013).
  • 27.Kim IS, Dickinson MH. Idiothetic path integration in the fruit fly Drosophila melanogaster. Curr. Biol. 2017;27:2227–2238. doi: 10.1016/j.cub.2017.06.026. [DOI] [PubMed] [Google Scholar]
  • 28.Neyman J. On a new class of contagious distributions, applicable in entomology and bacteriology. Ann. Math. Statist. 1939;10:35–57. doi: 10.1214/aoms/1177732245. [DOI] [Google Scholar]
  • 29.Taylor LR. Aggregation, variance and the mean. Nature. 1961;189:732–735. doi: 10.1038/189732a0. [DOI] [Google Scholar]
  • 30.Besson M, Martin JR. Centrophobism/thigmotaxis, a new role for the mushroom bodies in Drosophila. Dev. Neurobiol. 2005;62:386–396. doi: 10.1002/neu.20111. [DOI] [PubMed] [Google Scholar]
  • 31.Ramdya P, et al. Mechanosensory interactions drive collective behaviour in Drosophila. Nature. 2015;519:233. doi: 10.1038/nature14024. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 32.Schneider J, Atallah J, Levine JD. 3 one, two, and many—a perspective on what groups of Drosophila melanogaster can tell us about social dynamics. Adv. Genet. 2012;77:59. doi: 10.1016/B978-0-12-387687-4.00003-9. [DOI] [PubMed] [Google Scholar]
  • 33.Schneider J, Dickinson MH, Levine JD. Social structures depend on innate determinants and chemosensory processing in Drosophila. Proc. Natl Acad. Sci. USA. 2012;109:17174–17179. doi: 10.1073/pnas.1121252109. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 34.Zars M, Zars T. High and low temperatures have unequal reinforcing properties in Drosophila spatial learning. J. Comp. Physiol. A. 2006;192:727. doi: 10.1007/s00359-006-0109-6. [DOI] [PubMed] [Google Scholar]
  • 35.Ramdya P, Schneider J, Levine JD. The neurogenetics of group behavior in Drosophila melanogaster. J. Exp. Biol. 2017;220:35–41. doi: 10.1242/jeb.141457. [DOI] [PubMed] [Google Scholar]
  • 36.Runge E, Gross EKU. Density-functional theory for time-dependent systems. Phys. Rev. Lett. 1984;52:997. doi: 10.1103/PhysRevLett.52.997. [DOI] [Google Scholar]
  • 37.Chan GKL, Finken R. Time-dependent density functional theory of classical fluids. Phys. Rev. Lett. 2005;94:183001. doi: 10.1103/PhysRevLett.94.183001. [DOI] [PubMed] [Google Scholar]
  • 38.Capitani JF, Nalewajski RF, Parr RG. Non-born–oppenheimer density functional theory of molecular systems. J. Chem. Phys. 1982;76:568–573. doi: 10.1063/1.442703. [DOI] [Google Scholar]
  • 39.Wesolowski A, et al. Quantifying the impact of human mobility on malaria. Science. 2012;338:267–270. doi: 10.1126/science.1223467. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 40.Hauer ME. Migration induced by sea-level rise could reshape the US population landscape. Nat. Clim. Change. 2017;7:321–325. doi: 10.1038/nclimate3271. [DOI] [Google Scholar]
  • 41.Clark PU, et al. Consequences of twenty-first-century policy for multi-millennial climate and sea-level change. Nat. Clim. Chang. 2016;6:360–369. doi: 10.1038/nclimate2923. [DOI] [Google Scholar]
  • 42.Metropolis N, Rosenbluth AW, Rosenbluth MN, Teller AH, Teller E. Equation of state calculations by fast computing machines. J. Chem. Phys. 1953;21:1087–1092. doi: 10.1063/1.1699114. [DOI] [Google Scholar]
  • 43.Barker AvA. Monte carlo calculations of the radial distribution functions for a proton? electron plasma. Aust. J. Phys. 1965;18:119–134. doi: 10.1071/PH650119. [DOI] [Google Scholar]
  • 44.Reif F. Chapter 8, Fundamentals of Statistical and Thermal Physics. New York: McGraw Hill; 1965. [Google Scholar]
  • 45.Ji F, Zhu Y. A novel assay reveals hygrotactic behavior in Drosophila. PLoS. One. 2015;10:e0119162. doi: 10.1371/journal.pone.0119162. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 46.Bell WJ, Cathy T, Roggero RJ, Kipp LR, Tobin TR. Sucrose-stimulated searching behaviour of Drosophila melanogaster in a uniform habitat: modulation by period of deprivation. Anim. Behav. 1985;33:436–448. doi: 10.1016/S0003-3472(85)80068-3. [DOI] [Google Scholar]
  • 47.Haldane, J. A note on inverse probability. Math. Proc. Camb. Philos. Soc. 28, 55–61 (1932).

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Peer Review File (245.5KB, pdf)

Data Availability Statement

The fly density data that support the findings of this study are available in the Open Science Framework database at (10.17605/OSF.IO/7UBZ2).


Articles from Nature Communications are provided here courtesy of Nature Publishing Group

RESOURCES