WorksPhysics and Astronomy
Statistical mechanics of spontaneous behavior
Abstract
Why do a few behaviors fill most of an animal's time? The usual answer is that these behaviors are started more often, because learning and reinforcement favor them. Here we show that how long a behavior lasts can, by itself, explain much of what is observed. We consider a system that runs until it meets a constraint, such as a wall, and then resets. The fraction of time it spends in each behavior then follows the Boltzmann law, and the partition function is the mean time between resets. The four laws of thermodynamics follow as theorems from four postulates, and critical points that act as bottlenecks become the most occupied states. In 47 multi-day recordings of fruit flies, the dominant behavior accounts for only of bout starts yet fills of the time, and its typical duration identifies the individual fly. These results lay the groundwork for a statistical mechanics of behavior.
Place a fly in a closed box and record what it does. The record has a recognizable shape. Long stretches of circling alternate with short crossings and rare collisions with a wall, and of everything the fly could do, a few behaviors take up most of its time. The same is true of any agent whose activity is interrupted by encounters with a constraint, whether that constraint is a wall, the limit of its own body, or an exhausted energy reserve.
Two quantities summarize such a record. The frequency of a behavior is how often it is started, and its duration is how long it lasts once started. The time a behavior fills is the product of the two, so a behavior can dominate because it is started often or because it lasts long. The main theories of behavior, such as reinforcement learning and choice theory, explain dominance through frequency. They ask which action is selected and treat its duration as a detail.
Here we ask what a record looks like when nothing favors one behavior over another, so that only duration varies. The answer is a null theory, which plays the role that the ideal gas plays in thermodynamics. We show that this null theory is a complete statistical mechanics. The time share of each behavior follows the Boltzmann law, the partition function is the mean time between two encounters with the constraint, and the four laws of thermodynamics follow as theorems from four postulates. Dominance, the matching law, individuality, and criticality all emerge without assigning value to any behavior. Formally the construction belongs to stochastic resetting [1, 2], with one difference that matters. The reset is triggered when the system reaches the constraint, and this is what makes the partition function a time. We state the postulates, derive the free energy and the four laws, and test the theory in three simulated systems and in 47 multi-day fly recordings.
The postulates. P0 (behavior). An observer chooses a finite set of observables, such as position and heading, and a time resolution. The behavior of a system over a record is then its path through the space that these observables span [3, 4]. Because the observables are a choice, one animal supports many behaviors, and the laws below hold for each. The dynamics of depends on a hidden parameter , which we call an affordance, after Gibson’s term for what a situation offers an agent to do [5]. Each value of fixes one regime of the dynamics, for example circling or crossing. We also call it a mode. Finally, a region is bounded by the constraint . The constraint need not be a wall. A joint at the end of its range or a depleted energy store ends a bout in the same way.
P1 (reset). With the affordance held fixed, the observable follows a memoryless (Markov) dynamics until its path reaches the constraint . At that contact two things happen. The observable restarts from a fixed starting distribution, the injection law, and a new affordance is drawn from the resampling law . We call this an affordance-reset process. Since sets how often each affordance is started, it is the frequency of the theory. The stretch between two contacts is an excursion. Its length is the duration, and its mean is the dwell of . Our reference system throughout is a diffusion in a box,
where is pure rotation, which the geometry traps, and is pure drift, which crosses the box ballistically Figure 1(a). Between the two the dwell rises by more than an order of magnitude Figure 1(b).

Figure 1. The box, Eq. (1). (a) Two behaviors from one dynamics. Circling (, blue) is trapped and drift (, red) crosses. (b) The dwell rises from the ballistic crossing time to the diffusive escape time . (c) Occupation , where is the strength of the agent’s response to reward (see Reward). With no reward () and a uniform frequency the record is dominated by circling through duration alone. As reward for reaching the wall grows () drift takes over. Parameters , , , , over excursions.
P2 (the ensemble is time). Ordinary statistical mechanics averages over many copies of a system. Here there is one record and no copies, so the only primitive quantity is the occupation, the fraction of a window of length that each mode fills, . Equilibrium means that this fraction has a limit as . That limit plays the role of the thermodynamic limit, so in this theory *system size is recording duration. Under P1 successive excursions are independent and form a renewal process, and the renewal reward theorem [6] gives the long-run occupation,
In words, the time share of a mode is its frequency times its dwell, divided by the mean duration of an excursion. This is a Gibbs measure written in the two variables of the record. The frequency plays the role of the density of states, the dwell that of the Boltzmann weight, and the partition function is the mean cycle time. Equation (2) treats all modes alike. A mode that holds the system longer is simply observed for longer, an effect statisticians call length-biased sampling. This is why circling dominates the box even when every mode is started equally often [Figure 1(c), blue]. The agreement of time and ensemble averages, which ordinary statistical mechanics must assume, is here a theorem.
P2 also limits what a finite record can reveal. A window of length contains about excursions, and the occupation measured in it fluctuates around with variance , where is given in the SM. The number of excursions thus plays the part of the number of particles in a finite gas.
P3 (the dictionary). It remains to name temperature and energy. For a diffusion in a potential landscape with noise strength , the exit theory of Freidlin and Wentzel [7] shows that the dwell grows exponentially in , , where is twice the barrier to the easiest exit. Because is a property of the landscape and does not depend on the noise, the natural way to write the dwell as a Boltzmann factor is
The energy of a behavior is therefore minus its exit barrier, so a deep trap is a low-energy state. The environment sets the energies, while the temperature (the agent’s noise) and the frequency belong to the agent.
The potential. As in thermodynamics, the theory is organized around a free energy and its derivatives. The free energy of one excursion is , with a reference time, and a record of excursions has total free energy , so plays the role of system size, with conjugate . The free energy depends on four controls. These are the temperature , the volume of the domain , the strength of a reward field introduced below, and the propensities . The propensities are the shares of the frequency given to groups of behaviors, with . Each control has a conjugate, the partial derivative of with respect to that control with the others held fixed,
All conjugates are per excursion, and those of the whole record follow by multiplying by . Each has a behavioral reading. The entropy measures how far the occupation departs from the frequency. It equals minus the relative entropy , so it vanishes when duration plays no role. The pressure is the response of the free energy to enlarging the domain. The mean reward is times the average reward of the record. The behavioral chemical potential is the free-energy cost of shifting frequency into group . Proofs are in the SM.
The four laws. Each law is a theorem of P0 to P3 (Table S1 in the SM). For each one we state what frequency can do and what duration does.
| Law | Statement | Corollaries / test |
| 0th | an intensive exists, equalizes, is transitive | matching law [Eqs. (5),(6)], no learning |
| 1st | every change of is heat or work, one function behind every conjugate | Maxwell relations, global = local (non-circular), equation of state [Eq. (10)] |
| 2nd | and [Eq. (8)] | monotone relaxation, arrow of time measurable in data |
| 3rd | degeneracy of = divergence of the clock [Eq. (9)], unattainable in finite time | ground-state collapse, critical point = ground state, aging beyond the edge |
Table S1. The four laws of the affordance-reset thermodynamics. Each law is a theorem of postulates P0 to P3. The table gives its statement, its corollaries, and the test that checks it.
Zeroth law (a common scale exists). We first need the time allocated among options. Split the repertoire into disjoint groups , for example the options of a choice task. Let be the propensity of , the share of fresh affordances drawn from it, and let be the mean dwell of a visit to it, with the frequency within . Since the agent enters at a rate proportional to and each visit lasts on average, the renewal argument behind Eq. (2) gives
With uniform propensities, that is with no preference, reward, or learning, this reduces to . The time allocated to an option is then proportional to its dwell, with slope one [Fig. 2(a), heavy line]. This is the matching law of operant psychology [8, 9], the central law of choice, here produced by duration alone.
The zeroth law itself concerns what happens when propensity can flow between groups. The chemical potential is the cost of moving a little frequency into , and at equilibrium it is equal across groups. Because it is a single number, this equality is transitive. If is in equilibrium with and with , then is in equilibrium with , and serves as a common scale, as temperature does in the classical law. If allocating propensity carries a mixing entropy at a temperature , equalizing redistributes propensity as , the generalized matching law, with sensitivity
where measures how strongly the agent resists concentrating its propensity on a few groups [SM]. The theory therefore predicts undermatching, the empirically common case (median for responses and for time in Baum’s survey [10, 11]), whenever the agent’s noise is smaller than [Fig. 2(a,b), shaded].
First law (heat, work, and a state function). Let be the mean energy of the record, that is, the time average of minus the exit barrier of the current mode. A record that spends its time in deep traps has low . When a control such as the noise or the box size is changed slowly, changes for two reasons. Either the record redistributes its time among the modes while their energies stay fixed, or the environment shifts the energies while the time shares stay fixed. The first change is heat, and for a Gibbs occupation it equals exactly [SM]. The second is work, and its volume part is ,
Because the environment sets the energies directly, the law here carries no conservation statement. Its content is the decomposition itself. Every change of is heat or work, and every conjugate in Eq. (4) derives from the single function . This has testable consequences. The pressure measured from the response to volume must agree with the one computed from the mean cycle time, and the mixed derivatives must obey Maxwell relations such as [SM]. The entropy is concave in the energy with slope exactly [Fig. 2(c)]. The law requires a reward that does not depend on the box geometry, because otherwise the force measured from the geometry is not a derivative of .
Second law (two irreversibilities). The second law appears in two forms. The first concerns the approach to equilibrium, and the second concerns the equilibrium record itself. Relaxation toward the Gibbs occupation is monotonic. For any resampling rule with stationary law , the distribution of the mode after excursions obeys , so the distance to equilibrium can only decrease, an -theorem [12] [SM]. The equilibrium record also has a direction in time, and it enters at the reset. At each contact many different states are sent back to the same injection point, and this map cannot be run backward. The observed sequence is therefore irreversible even when the affordance is resampled symmetrically. Its entropy production is the occupation average of , the rate at which excursions in mode produce entropy through their reset,
with equality only when there is no reset [13, 14]. In data, the irreversibility , the relative entropy between the statistics of the observed transitions and those of the same record played backward, gives a measurable lower bound on it [SM].
Third law (unattainability). The classical third law says that absolute zero cannot be reached in finite time. Its counterpart here is that no record can be completely dominated by one behavior in finite time. Let be a set of modes that are candidates to dominate, and suppose the other modes are still started, with frequency . Every excursion lasts at least the fastest crossing of the domain, , so each cycle spends on average at least outside . Dividing by the mean cycle time gives
Pushing the time share outside toward zero therefore requires the mean cycle time to grow without limit. The bound shows how differently the two variables act. Frequency is bounded, , so it can make one behavior fill the record only by never starting the others. Duration is unbounded, so it can make one behavior fill the record with the repertoire intact, but only by making excursions ever longer. A record of length contains excursions and knows its own occupation only through a scatter [P2]. As the occupation concentrates, grows, falls below one, and the window becomes a single unfinished excursion. No finite record ever shows a fully dominated occupation. In classical thermodynamics this unattainability is an independent principle, or requires additional resource assumptions [15]. Here it is a theorem, because the partition function is itself a time.

Figure 2. Zeroth and first laws. (a) Log ratios against the dwell ratio of two options. Time shares with uniform propensity give strict matching [Eq. (5), heavy line]. Propensities after exchange follow the generalized matching law when the groups are kept separate (quenched, dashed) and bend when they are pooled (annealed, dotted) [SM]. (b) The sensitivity measured from the slope in (a) against [Eq. (6)]. Undermatching (, shaded) is the regime . (c) The entropy against the mean energy, for the trap ensemble with , is concave with slope , as the first law requires.
The limit itself is still informative. As the noise goes to zero the occupation collapses onto the mode with the deepest exit barrier, , which is the longest-dwelling mode, and the entropy tends to [SM]. A record concentrated on its most persistent behavior looks optimized, yet nothing has been optimized. A Gibbs measure has simply concentrated on its energy minimum, as a cooled gas does, and the recording time needed to observe this grows with without bound.
Criticality. The energy minimum has a further identity. When an excursion must pass through a bottleneck near a continuous transition, the passage time diverges, the phenomenon called critical slowing down. The critical point is then the longest-dwelling affordance, so it minimizes and is the ground state. Duration alone parks the record at the critical point. Figure 3 shows the simplest case, a saddle-node bottleneck

Figure 3. The critical point is the ground state. Saddle-node bottleneck, critical at . (a) From a uniform frequency (blue) the occupation (red) piles up at the critical point. (b) Excursion durations are scale-free, (dashed), cut off by noise. Inset, the collapse against . , uniform on , in (a).
reinjected at on reaching , in which the control parameter is the affordance and is critical. The passage time grows as , so from a flat frequency the occupation piles up at as [Figure 3(a)]. Because each maps to one duration, the durations follow a power law, , up to a cutoff set by the noise, [Figure 3(b)]. Observed criticality is usually read as evidence of tuning or of a self-organizing feedback [16, 17]. Here it is the null expectation for any repertoire that straddles such a transition, and it must be excluded before criticality is attributed to adaptation.
A power law of durations is the signature of a heavy-tailed repertoire, where the third law takes a sharper form. Suppose the frequency itself has a Boltzmann form in the exit barriers, , with setting how
fast the frequency decays with barrier depth. This is the trap ensemble of Bouchaud [18, 19]. The partition function is then [SM]. It is finite when the noise exceeds and diverges at , a point we call the ergodic edge, because there time averages stop converging. Beyond the edge, , the number of excursions in a window grows more slowly than the window, with . As in the trap model, the occupation of a window is then expected to remain random at all times, which is called weak ergodicity breaking, and the statistics of a record change with its length, which is called aging [18, 19]. The exponent can be read off the tail of the measured durations, so the duration exponent of a record tells how far it is from the edge.
Reward. So far every mode has been treated alike. Now let each mode get a return a reward when it is run, and let the agent respond by a simple local rule, win-stay/lose-sample. After a rewarding excursion the agent keeps the current affordance, and otherwise it draws a fresh one from . This rule changes only how often each
mode is started. Its steady state is the tilted frequency , where measures how strongly the agent responds to reward [SM], so the occupation becomes . Reward therefore acts on frequency as an external field, in the role a magnetic field plays for a spin system, and leaves duration untouched. Because dominance is measured in time, a reward that favors a short behavior must first overcome the advantage that long behaviors gain from length-biased sampling. We call this advantage the entropic force, because it arises purely from how time is counted. The crossover between the two regimes is abrupt. Two modes exchange dominance at the field , as in a first-order phase transition, and the price of crossing is the dwell ratio , the analogue of a latent heat. In the box, reward for reaching the wall favors drift, yet the field must reach before drift displaces circling [Fig. 1(c)].
Equation of state. The geometry of the domain also has a conjugate. Differentiating the free energy with respect to the volume of the domain gives the pressure, which takes an ideal-gas form,
where measures how fast the dwell of mode grows as the domain is enlarged. For a mode that escapes by diffusion the dwell grows as the square of the linear size, so in dimensions. For a mode that crosses ballistically it grows linearly, so . The pressure therefore measures how much of the record is trapped and how much is ballistic.
Verification in three systems. We test each relation in three systems chosen to share as little mechanism as possible. In each, the prediction uses only dwells measured without reward, and it is compared with an independent simulation of the dynamics [SM]. In the box () the measured exponents are for circling and for drift, against the predicted 1 and 1/2. When win-stay/lose-sample is simulated with a real reward field, circling and drift share the record equally at , against 3.85 predicted from the unrewarded dwells. The global free energy computed from the mean cycle time agrees with the integral of the local pressure to within 1 to 3%. In a one-dimensional decision process runs from to , following the prediction to within 0.016. Finally, a Braitenberg vehicle [20], a robot whose affordance is a sensorimotor wiring that is rewired at each wall contact, has an occupation that matches to within in total variation [SM].
The fly records. We test the two variables on 47 multiday recordings of Drosophila [21], each 1.3 to 7.8 days long and labeled into nine behavioral states [SM, Fig. 4]. In the data an excursion is a bout. The counterpart of the frequency is the election share of a state, the fraction
of bouts that begin in it, and the counterpart of the dwell is its mean bout duration. The idle state is elected on a median 13% of bouts yet fills 49% of the record, and the most-elected state differs from the most-occupied one in 46 of 47 flies [Fig. 4(a)]. Dominance is manufactured by duration.
Duration also carries individuality. When each record is split into two halves, the mean idle dwell of a fly replicates between the halves at , so that 91% of its variation across flies is a stable trait of the individual (split-half reliability corrected to full record length). The election share replicates at only , with 39% stable. The identity of a fly is carried by its duration scale, and its frequency is the fluctuating part. Finally, the records show anomalous scatter. In every fly the scatter of the idle occupation across windows decays with an exponent between and , where the finite-variance law gives [Fig. 4(b)], and the idle durations have tail exponents from 0.56 to 1.70, median 0.77. Both are consistent with a repertoire near the ergodic edge, where this anomalous scatter is expected.
Discussion. Several features of behavior that are usually read as signs of design turn out to be consequences of one free energy. Dominance is the Gibbs weight, the matching law is length-biased sampling, apparent optimality is the ground-state collapse of the third law, and criticality is the ground state itself. All of them are properties of duration, the variable that theories of choice set aside. Once this null part is subtracted, what remains is what a genuine account of reward must explain, and each law comes with its own test (Table S1 in the SM). The laws are verified in a diffusing particle, a decision process, and a self-rewiring robot, and the fly records show the duration structure they rest on. Like the laws of thermodynamics across substances, they are theorems of the renewal structure, and so they carry over to any mechanism that realizes it.
D.Y.T. was supported by CNPq grants 421955/2023-6 and 445096/2024-1, FAPESP grant 2013/07699-0, and Serrapilheira grant R-2401-47364. A.E.H. acknowledges support by the DFG German Research Foundation (EXC 2117-422037984) and the Human Frontier Science Program (RGP006/2025). We thank the Princeton Drosophila data initiative for the public dataset.1
Supplemental Material for Statistical mechanics of spontaneous behavior
Daniel Yasumasa Takahashi; Ahmed El Hady
This Supplemental Material gives the proofs of the results stated in the Letter, together with the numerical methods behind every quoted number. Section and equation numbers prefixed by S refer to this document, and unprefixed numbers refer to the Letter. Throughout we assume that relaxation within a basin is fast compared with the dwell, so that each excursion is quasi-stationary, that the embedded affordance chain is positive Harris recurrent, so that it has a unique stationary law, and that the mean cycle time is finite, . The small-noise results of § 3.1 further assume that the noise is small. § 6 is the one exception, since there the failure of is itself the subject. Table S1 collects the four laws with their corollaries and tests.
The Occupation Law
We prove Eq. (2). Between two consecutive contacts with the constraint, the affordance stays fixed at a value drawn from for a random duration with . The sequence of pairs , in which the are independent and identically distributed (i.i.d.) and is the th dwell, is therefore a marked renewal process, a renewal process whose cycles each carry a label. For a bounded test function , the renewal reward theorem gives the long-run time average
because the numerator is the expected reward accumulated per cycle and the denominator is the mean cycle length. Identifying the right-hand side with yields
valid whenever . If the affordance is instead redrawn from a Markov kernel , the excursions form a Markov-renewal process, and the same length-biased argument applied to the stationary law of the embedded chain gives [6], of which Eq. (12) is the special case . The condition is precisely what makes the free energy well defined, and its failure, which is the loss of ergodicity, is taken up in § 6. Finally, the almost-sure convergence in Eq. (11) turns postulate P2, the equivalence of time and ensemble averages, into a theorem.
Finite records and the fluctuation law
By P2 a finite record is a finite system, and its size is the number of completed excursions. For a window and a measurable , the error of the empirical occupation decomposes over excursions,
where is the empirical occupation measure and the are i.i.d. with mean zero, the mean vanishing by Eq. (12) itself. The central limit theorem for renewal reward processes [22] then gives
In a numerical test on a five-mode ensemble with exponential dwells and , the measured and predicted variances over 4000 independent records agree to 0.1% (ratio 1.001), with bias . Equation (S4) plays three roles. It is the finite-size scaling of the theory, it predicts how the scatter of matching data shrinks with session length, and it serves as the ruler for the third law (§ 6). Because a record resolves its own occupation only to accuracy , any limit in which diverges is one in which the record can no longer display its equilibrium.
The small-noise dictionary
We justify Eq. (3) by specializing the observable dynamics to a gradient diffusion in a single basin,
started at the bottom of the well, with the constraint placed on the basin boundary. The Freidlin and Wentzell theory of exit times [7] then gives
For a gradient field the action-minimizing path is the time reversal of the noiseless relaxation into the well, along which , so the integrand is and
which is twice the height of the barrier to the easiest exit point . The mean dwell therefore grows as , which is Kramers’ law, and writing suggests the identification
to the leading exponential order.
Zeroth law, chemical potential and matching
Partition the repertoire into disjoint sub-repertoires with propensities () and conditional laws , so and
with the mean dwell conditioned on entering . Allocating propensity among the groups carries a mixing entropy at a temperature , and the resulting free energy depends on whether the sub-repertoires are pooled (annealed) or kept separate (quenched),
The behavioral chemical potential is . Making stationary under the constraint equalizes it across groups, , and because is a single number this equality is transitive, which is the content of the zeroth law. The equalized allocation is
The quenched result is the generalized matching law with sensitivity , so strict matching corresponds to and undermatching () to . Time allocation is the length-biased image of choice,
so uniform propensity already gives , which is strict matching in time, with unit sensitivity and without any learning.
First law, heat and work, and the state function
In this thermodynamics the first law states that a single state function stands behind every operationally measured force, and that every change of the mean energy is exactly heat or work. We first assemble the potential, then prove the decomposition, and finally verify exactness.
The potential and its conjugates
The per-excursion free energy is and the total potential over a record of excursions is . From ,
so the Gibbs entropy is the conjugate of temperature. Differentiating at fixed occupation gives the remaining conjugates, namely the pressure , the mean reward , and the behavioral chemical potentials of Sec. S3. Collecting them,
and for the whole record , so that is the conjugate of the record size. Unlike its classical counterpart, this differential carries no conserved quantity, because the energy is set by the environment, is not additive over the repertoire, and is exchanged with no bath. What survives of the classical first law is the decomposition of every change of into heat and work, and that decomposition survives exactly.
The heat and work decomposition
We adopt the exact assignment , whose small-noise limit is Eq. (3). With it, holds at any noise level and the identities below are exact. Let . Any smooth change of the controls at fixed frequency gives , and the first term is exactly , because implies
The second term is the work done by the geometry. Section S7 shows that , so the two pressure meters and necessarily agree, and along quasistatic paths at fixed frequency and field
Here heat is the reshuffling of the record over its modes, and work is the displacement of the energies by the environment. A temperature path at fixed geometry is therefore pure heat whenever the barriers do not depend on , as in the Arrhenius regime of Sec. S2. On the discrete ensemble of the next subsection the stepwise identity holds to . Integrated along a temperature path, holds to , and along a volume path holds to the same accuracy, with the two pressure meters coinciding to .
Exactness and the Maxwell relations
Because every term in Eq. (25) is a first partial derivative of the single function , the form is closed and its mixed second derivatives commute, giving
We verify these on a solvable discrete model with affordances, each assigned a barrier , a frequency , a dwell-scaling exponent (so that is affine in ) and a reward , for which is a closed-form log-sum-exp. Each conjugate computed analytically agrees to machine precision with a centered finite difference of , the three Maxwell relations (S18) hold to , and holds around closed loops in the plane to . Exactness fails by construction when the reward itself depends on , because then . A pressure that is a state function therefore requires a reward schedule that does not depend on the confining geometry.
Second law, relaxation and the arrow of the record
The H-theorem
Read the record as a sequence of excursions and keep only which mode each excursion used. This sequence of modes is a Markov chain, the embedded chain, whose transition rule gives the probability of each next mode when the current mode is , and whose stationary law is the distribution of modes that the rule leaves unchanged, . Without reward every mode is drawn afresh from the frequency , so and . Under the win-stay/lose-sample rule of Sec. S8 the system instead keeps its current mode with probability and otherwise draws a new one from , so that , where puts all the weight on , and .
Let be the distribution of the mode at the th excursion, so that . Its distance from equilibrium is measured by the relative entropy , which vanishes only when . Passing two distributions through the same random rule can only make them harder to tell apart, a fact known as the data-processing inequality [12], , and since it gives
The distance to equilibrium therefore never grows, and it strictly shrinks whenever the rule mixes, that is, whenever the chain can move between modes. Because the time occupation is the distribution of modes weighted by their dwells (Sec. S1), it inherits the same descent. For a six-mode win-stay/lose-sample rule started from each of 20 random distributions, never increases by more than per step, and the stated is stationary to machine precision.
The arrow of the record
Let be the probability of an observed sequence of behavioral states over a window, and the probability of the same sequence played backward. The irreversibility
is a relative entropy, so it is never negative, and it is zero only when the record looks the same forward and backward [13, 14]. The reset breaks this symmetry, because at each contact many different states are sent to the same injection point and this map cannot be run backward. The full path therefore produces entropy at the rate whenever resets occur, even when the affordance is resampled symmetrically. Grouping states into behaviors can hide part of this asymmetry but cannot create any, so the irreversibility of the observed record is a lower bound on .
Third law and unattainability
The dwell floor and the clock bound
Every excursion must cross the domain, so at fixed geometry the mean dwell is bounded below by the time of the fastest, ballistic crossing, . For any measurable this gives
Suppose now that the controls change so that the occupation concentrates on , , while the modes outside keep a frequency . The bound then forces the partition function to diverge. Since is the mean cycle time, the elementary renewal theorem [22] gives an expected number of completed excursions in a window of , and by the fluctuation law (S4) the occupation of the window keeps a variance . No finite record therefore equilibrates at a degeneracy of the occupation measure. Classical thermodynamics treats unattainability as an independent principle or derives it from added resource assumptions [15], whereas here it is a theorem, because the normalizer of the equilibrium measure and the clock that samples it are the same number.
Ground-state collapse
As , the integral is dominated by the minimizers of (Laplace’s method), so
which is the mode with the deepest barrier and hence the longest dwell. The entropy tends to , the log frequency of the ground-state set, so strict Nernst behavior would hold only if . This is the familiar concentration of any Gibbs measure, and it is what apparent optimality and selection reduce to. The preceding subsection shows, however, that no finite record attains this limit. Displaying it would take a recording time , which diverges in Arrhenius fashion, and at the renewal process has no renewals at all, so the whole record is a single unfinished excursion.
The ergodic edge and critical slowing down
Consider the trap ensemble [18, 19], in which barriers on have the exponential frequency , decaying with depth at rate , and dwells . Its partition function is elementary,
and it diverges as at the edge . In ordinary critical phenomena the partition function stays finite while correlations diverge. Here the divergence of is itself the critical slowing down, so thermodynamics and kinetics meet in a single quantity, and by the bound of § 6 no finite record can display the edge. The dwells have the power-law tail with . For renewals accumulate at the steady rate , whereas for the mean dwell is infinite, sums of dwells are governed by a one-sided stable law, and the number of renewals grows only as , up to slowly varying corrections [22].
The critical point is the ground state
Because the Boltzmann weight is the dwell, the occupation concentrates wherever the dwell is longest. Near a continuous transition the passage time diverges, which is critical slowing down, so the longest-dwelling affordance is the critical point and has its minimum there. We make this concrete with the saddle-node bottleneck of Figure 3, the canonical form of critical slowing down and the channel of type-I intermittency, in which the affordance is the control parameter of
on . The trajectory is reinjected at on reaching , which is the constraint, and is redrawn at every contact from the uniform frequency on , so that is the critical point. The deterministic passage time is exact,
and is maximal at . In simulation the dwell matches Eq. (35) to better than 0.1% for at . The entropic force points inward and diverges at criticality. This holds near any continuous transition, since a passage time produces a force that always points toward . The peak does require a marginal-passage geometry, however. In a simple confining well varies monotonically with stiffness and has no interior maximum, which is why the relevant critical structure is the bottleneck.
By Eq. (12) the occupation is as . This square-root singularity is integrable, so the occupation concentrates at criticality while remaining normalizable, even though the mean dwell diverges logarithmically. In simulation at , the time occupation generated from the uniform frequency is tilted 5.8-fold toward across [Fig. 3(a)], and it follows the noiseless curve everywhere except in the first bin, where noise shortens the longest passages.
The durations are scale-free. Changing variables to with uniform gives , which for equals . Noise cuts this power law off, and balancing drift against noise near the bottleneck, where , gives a crossover and a duration cutoff . The power law therefore holds for and extends further as the noise falls. For every from 0.4 to 0.08 the simulated follows the noiseless law up to the cutoff, with a tail exponent of fitted between and the cutoff (3.04 at the lowest noise), and the curves collapse under [Fig. 3(b), inset]. The exponent is not universal, however. Near a general transition with passage divergence and frequency , the same change of variables gives , which recovers 3 for the saddle-node with uniform frequency (, ). Shallower divergences, or frequencies that thin out toward the transition, lower the exponent, so a measured duration exponent reflects the geometry of the bottleneck and the frequency jointly.
Observed criticality is usually taken as evidence of tuning, selection, or a self-organizing feedback [16, 17]. Here, by contrast, the system sits at a critical point simply because the critical point is the longest-dwelling state and length-biased sampling converts long dwell into high occupation. No parameter is tuned to and nothing drives the control parameter there, since it is drawn afresh from a fixed frequency at every contact and only the time occupation is reweighted. This dwell-weighted proximity to criticality differs from avalanche self-organized criticality, in which the critical state is an attractor of the dynamics. Criticality is therefore a null expectation that must be excluded before an observed critical point is attributed to adaptation, just as the neutral occupation is the null for dominance.
A frozen record, numerically
We simulate three modes with barriers , frequency and exponential dwells, using a fixed window and 300 records per temperature. In equilibrium the shallower of the two trapped modes holds a share of the time spent in the traps, but a finite record freezes into whichever trap it enters first.
| (equilibrium) | (measured) | |||
| 0.60 | 1.7 | 5852 | 0.417 | |
| 0.40 | 2.8 | 3627 | 0.378 | |
| 0.25 | 8.7 | 1148 | 0.310 | |
| 0.15 | 100 | 100 | 0.209 | |
| 0.10 | 4.0 | 0.119 | ||
| 0.08 | 0.34 | 0.076 |
Table 1.
Down to renewals the record tracks equilibrium with the scatter of Eq. (14), but at it no longer does, and at the window is a single unfinished excursion whose occupation is close to a coin flip between the traps. The collapse of § 6B is thus real yet unattainable, since it is approached only on records whose length grows with the clock.
Equation of State
From and ,
Under isotropic dilation of a fixed shape, a mode that escapes by diffusion has and hence , while a ballistic mode has and hence . For the decision process with absorbing thresholds at and drift the mean dwell is known in closed form [23], , and with it gives
which runs from as , where escape is limited by diffusion, to as , where it is limited by drift. Taking , the one-dimensional equation of state reads , which approaches the ideal-gas form at large threshold.
Reward Field and Coexistence
Under the win-stay/lose-sample rule, the affordance of each excursion is retained with a probability that depends on the reward signal the excursion produced, and is otherwise redrawn from . The embedded chain then has kernel with , and its unique stationary law is
When the mean retention is exponential, , this gives and hence, by § 2, , so the reward tilt is the exact stationary law of a local rule driven by experience. Two modes then carry equal weight when , which defines the first-order coexistence line
along which the quantity exchanged between the modes, the analogue of a latent heat, is the log dwell ratio .
The Fly Records
The analysis includes all 47 flies of the Princeton long-timescale dataset [21], recorded in four cohorts during 2022. Each fly contributes 1.3 to 7.8 days of continuous ethogram over nine behavioral states, amounting to to completed bouts per record. Bout lists of states and durations are read off the published per-frame labels without smoothing. Because the idle state holds the largest time share in 45 of the 47 flies, it serves as the reference mode below. Table S2 lists the per-fly numbers and Figure S1 shows the corresponding panels, of which (a) and (d) appear as Figure 4 of the Letter.

Figure 4. The 47 fly records [21]. (a) Election share (frequency) against occupation share (time) for every fly and state, idle in black. (b) Variance of the idle occupation across windows of length against the finite-variance law of P2 (faint dashed, slope ). Every fly decays more slowly.

Figure S1. The 47 multi-day fly records [21]. (a) Election share against occupation share for every fly and state, idle in black. Idle sits far above the diagonal and the most-entered state, the grey cluster near , sits below it. Dominance is manufactured by dwell. (b) The mean idle dwell of each fly, first half of the record against second half. The dwell scale replicates at and identifies the individual. (c) The same split for the idle election share, which replicates at . (d) Variance of the idle occupation across non-overlapping windows of length (solid, one curve per fly) against the parameter-free finite-variance law (faint dashed). Every fly decays far more slowly than the predicted slope , the anomalous scatter of a repertoire near the ergodic edge.
| fly | date | cam | days | bouts | (s) | (s) | Var | ||
| 1 | 02-17 | 1 | 4.9 | 391 286 | 1.08 | 0.51 | 0.14 | 4.05 | −0.13 |
| 2 | 02-17 | 1 | 3.3 | 295 147 | 0.98 | 0.37 | 0.10 | 3.50 | −0.26 |
| 3 | 02-17 | 1 | 6.2 | 450 054 | 1.18 | 0.48 | 0.15 | 3.89 | −0.23 |
| 4 | 02-17 | 1 | 5.0 | 388 780 | 1.11 | 0.43 | 0.11 | 4.44 | −0.32 |
| 5 | 02-17 | 2 | 4.0 | 238 256 | 1.47 | 0.58 | 0.13 | 6.58 | −0.44 |
| 6 | 02-17 | 2 | 6.8 | 305 636 | 1.92 | 0.66 | 0.15 | 8.53 | −0.40 |
| 7 | 02-17 | 2 | 7.8 | 568 555 | 1.18 | 0.48 | 0.13 | 4.44 | −0.26 |
| 8 | 02-17 | 2 | 6.1 | 466 330 | 1.13 | 0.41 | 0.13 | 3.67 | −0.26 |
| 9 | 02-17 | 3 | 6.3 | 566 283 | 0.96 | 0.40 | 0.13 | 2.96 | −0.31 |
| 10 | 02-17 | 3 | 4.3 | 370 537 | 0.99 | 0.39 | 0.12 | 3.21 | −0.19 |
| 11 | 02-17 | 3 | 3.8 | 412 364 | 0.79 | 0.29 | 0.10 | 2.30 | −0.23 |
| 12 | 02-17 | 3 | 6.5 | 680 382 | 0.83 | 0.33 | 0.10 | 2.76 | −0.29 |
| 13 | 02-17 | 4 | 4.2 | 353 781 | 1.03 | 0.45 | 0.14 | 3.34 | −0.23 |
| 14 | 02-17 | 4 | 3.1 | 292 561 | 0.92 | 0.37 | 0.11 | 3.09 | −0.29 |
| 15 | 02-17 | 4 | 5.8 | 222 122 | 2.27 | 0.68 | 0.16 | 9.90 | −0.50 |
| 16 | 03-13 | 3 | 3.5 | 399 571 | 0.77 | 0.13 | 0.07 | 1.40 | −0.21 |
| 17 | 03-13 | 3 | 3.9 | 486 935 | 0.69 | 0.24 | 0.07 | 2.45 | −0.19 |
| 18 | 03-13 | 3 | 4.8 | 364 258 | 1.15 | 0.50 | 0.16 | 3.60 | −0.18 |
| 19 | 03-13 | 3 | 4.7 | 658 925 | 0.62 | 0.21 | 0.09 | 1.37 | −0.21 |
| 20 | 03-13 | 4 | 4.3 | 409 322 | 0.91 | 0.41 | 0.15 | 2.44 | −0.19 |
| 21 | 03-13 | 4 | 3.2 | 352 333 | 0.80 | 0.34 | 0.13 | 2.11 | −0.23 |
| 22 | 03-13 | 4 | 4.4 | 421 395 | 0.91 | 0.39 | 0.11 | 3.31 | −0.09 |
| 23 | 03-13 | 4 | 2.3 | 183 990 | 1.10 | 0.45 | 0.14 | 3.56 | −0.15 |
| 24 | 03-26 | 3 | 3.8 | 299 107 | 1.10 | 0.48 | 0.09 | 5.86 | −0.15 |
| 25 | 03-26 | 3 | 3.0 | 230 023 | 1.14 | 0.45 | 0.10 | 5.09 | −0.12 |
| 26 | 03-26 | 3 | 4.8 | 354 918 | 1.16 | 0.49 | 0.10 | 5.54 | −0.16 |
| 27 | 03-26 | 3 | 5.2 | 351 347 | 1.27 | 0.53 | 0.10 | 6.94 | −0.23 |
| 28 | 03-26 | 4 | 5.0 | 286 843 | 1.52 | 0.57 | 0.12 | 7.22 | −0.16 |
| 29 | 03-26 | 4 | 5.0 | 363 482 | 1.19 | 0.43 | 0.09 | 5.41 | −0.20 |
| 30 | 03-26 | 4 | 4.1 | 212 561 | 1.68 | 0.60 | 0.13 | 7.64 | −0.26 |
| 31 | 03-26 | 4 | 4.2 | 246 522 | 1.47 | 0.57 | 0.10 | 8.06 | −0.15 |
| 32 | 04-18 | 1 | 1.3 | 73 693 | 1.56 | 0.62 | 0.18 | 5.44 | −0.11 |
| 33 | 04-18 | 1 | 6.5 | 333 881 | 1.67 | 0.62 | 0.15 | 6.88 | −0.26 |
| 34 | 04-18 | 1 | 4.9 | 284 585 | 1.48 | 0.56 | 0.10 | 8.12 | −0.25 |
| 35 | 04-18 | 1 | 4.2 | 210 159 | 1.71 | 0.62 | 0.14 | 7.43 | −0.23 |
| 36 | 04-18 | 2 | 3.4 | 199 729 | 1.46 | 0.59 | 0.11 | 7.93 | −0.14 |
| 37 | 04-18 | 2 | 4.2 | 258 578 | 1.41 | 0.59 | 0.16 | 5.16 | −0.27 |
| 38 | 04-18 | 2 | 3.0 | 215 035 | 1.21 | 0.47 | 0.10 | 5.76 | −0.09 |
| 39 | 04-18 | 2 | 5.2 | 262 675 | 1.70 | 0.59 | 0.15 | 6.87 | −0.32 |
| 40 | 04-18 | 3 | 6.0 | 218 551 | 2.37 | 0.73 | 0.16 | 10.46 | −0.36 |
| 41 | 04-18 | 3 | 4.8 | 236 393 | 1.77 | 0.61 | 0.13 | 8.29 | −0.26 |
| 42 | 04-18 | 3 | 4.8 | 256 197 | 1.62 | 0.60 | 0.13 | 7.52 | −0.27 |
| 43 | 04-18 | 3 | 3.7 | 228 231 | 1.40 | 0.49 | 0.11 | 6.15 | −0.19 |
| 44 | 04-18 | 4 | 5.3 | 271 608 | 1.67 | 0.61 | 0.13 | 7.56 | −0.37 |
| 45 | 04-18 | 4 | 6.8 | 310 335 | 1.89 | 0.65 | 0.14 | 8.51 | −0.34 |
| 46 | 04-18 | 4 | 2.0 | 129 516 | 1.33 | 0.59 | 0.14 | 5.52 | −0.07 |
| 47 | 04-18 | 4 | 4.1 | 268 135 | 1.32 | 0.51 | 0.08 | 8.10 | −0.14 |
Table S2. The 47 flies of Ref. [21]. Columns give the fly identifier, the 2022 recording date and camera, the record length in days, the number of completed bouts, the mean bout time , the idle occupation share , the idle election share , the mean idle dwell , and the measured decay exponent of the idle occupation scatter across windows, whose finite-variance value would be .
Dominance is manufactured by dwell. The occupation factorizes exactly as , where is the election share, the fraction of completed bouts that enter , and is the mean dwell. If dominance reflected preference, the structure would sit in , but the data place it in . The flies elect idle on a median 0.13 of bouts (range 0.07 to 0.18) yet spend a median 0.49 of the record in it (range 0.13 to 0.73), a four to six fold length bias. The most-entered state is the unstereotyped state in all 47 flies, whereas the most-occupied state is idle in 45, and the two coincide in only a single fly Figure S1. Across the full nine-state repertoire the variance of log occupation is carried mainly by the election shares, with the dwell accounting for a median variance fraction of 0.18 per fly. Election thus decides which states appear in the repertoire at all, while dwell decides which of them dominates the record.
Individuality lives on the dwell axis. Across flies the variance of splits into a dwell fraction of 1.39 and an election fraction of 0.44. Fractions can exceed one because the covariance terms with are negative and absorb the balance. Consistently, correlates with at 0.90 but with only at 0.65. To separate a stable trait from finite-record noise we split every record into two halves by time. The mean idle dwell replicates between the halves at (Spearman 0.82), so that 91% of its across-fly variance is stable after the Spearman-Brown correction to full record length, and the occupation follows at . The election share, in contrast, replicates at only , with 39% stable [Fig. S1(b,c)]. The identifying trait of an individual fly is therefore its dwell scale, while its election rate is the fluctuating component. Two confounds can be set aside. The correlation of with record length is only 0.17, so the length bias of heavy-tailed sample means contributes little. The two halves do share arena, camera, and week, which could inflate all replication numbers together, but a shared setting cannot produce the contrast between and .
The finite-variance scatter law fails in every fly. Postulate P2 fixes the scatter that a finite record can have, with the plug-in of Eq. (14). In every one of the 47 flies, however, the measured variance of idle occupation across non-overlapping windows decays far more slowly, with log-log slopes from to against the predicted [Fig. S1(d)], as expected in the anomalous regime of a repertoire near the ergodic edge (Sec. S6 C). The idle dwell tail has survival exponents near unity, 0.56 to 1.70 by the maximum-likelihood fit of Ref. [24] and 0.75 to 1.84 by the Hill estimator [25]. Single records in this regime have random growth exponents, and the bout count averaged over flies grows sublinearly, as over three decades. As a check, the analysis pipeline recovers ground truth on seeded Pareto ensembles, returning growth exponents of 1.00, 1.00, 0.67 and 0.50 against for an exponential control and for , 0.7 and 0.5.
Numerical Methods
Every prediction uses only mean dwells and reward rates measured in fixed-affordance runs without reward, and it is compared against a separate simulation of the dynamics under win-stay/lose-sample resampling, in which the Gibbs weight never enters. Table S3 lists the parameters.
| System | Parameters | Sampling |
| Box | , , , , reward offset , uniform frequency | excursions |
| Decision | thresholds , 15 values | crossings/threshold |
| Vehicle | sensors at , gain , base speed , wheel noise , | rewirings |
Table S3. Simulation parameters. The box and vehicle are simulated with many parallel realizations undergoing repeated excursions. The decision process uses the closed-form first-passage law as a check on the simulated dwells.
Box
We integrate Eq. (1) on with an absorbing wall and reinjection near the centre. The rotational part of the vector field is integrated exactly, by Strang splitting of rotation against drift and noise, because explicit Euler multiplies the orbit radius by at each step. That spurious outward spiral of per orbit shortens the circular dwell by and corrupts , which it returns as 0.61 in place of 1. With exact rotation the circular dwell is , against the analytic two-dimensional Bessel first-passage value . The exponents (circling) and 0.496 (drift) come from regressing on across the box sizes. Reward for reaching the wall enters through the rate of wall contact , where the offset keeps it bounded on short excursions, and the equation of state then gives falling from 1.07 at to 0.73 at . For coexistence, the two end modes alone give by Eq. (39), while summing the tilt over all modes places equal
occupation on circling () and drift () at 3.85. Simulating the reward rule with retention gives this crossing at . If retention instead depends on the reward of each excursion, as , Eq. (38) predicts 4.05 and the simulation gives 4.05.
Decision process
A one-dimensional accumulator runs between absorbing thresholds with reinjection at 0. Across fifteen thresholds spanning to 15.6 the simulation reproduces the closed-form mean first-passage time to better than 0.5%. The measured follows Eq. (37) to within 0.016, from at the diffusive end to 1.004 at the drift end, and the resulting pressure matches to 0.4%.
Braitenberg vehicle
A differential-drive vehicle with pose and two light sensors at moves in a square arena with a light at its centre. With crossing fraction the wheel speeds are and , so that steers away from the light and toward it, while the mean speed does not depend on . Noise enters on the wheels, so translational diffusion is emergent, and the wiring is redrawn independently at each wall contact. Over rewirings the measured time occupation matches , with taken from separate fixed-wiring runs, to a total-variation distance of , and the trapped wiring holds 46.3% of the record against 46.4% predicted from a 10.5-fold dwell contrast. Fitting on pairs of arena sizes across to 2.8 gives for the ballistic wirings and for the trapped wiring, whose excess over 1 reflects that the trapped label describes the mode only asymptotically.
References
- [1]M. R. Evans and S. N. Majumdar, Phys. Rev. Lett. 106, 160601 (2011).
- [2]M. R. Evans, S. N. Majumdar, and G. Schehr, J. Phys. A: Math. Theor. 53, 193001 (2020).
- [3]G. J. Berman, D. M. Choi, W. Bialek, and J. W. Shaevitz, J. R. Soc. Interface 11, 20140672 (2014).
- [4]A. E. X. Brown and B. de Bivort, Nat. Phys. 14, 653 (2018).
- [5]J. J. Gibson, The Ecological Approach to Visual Perception (Houghton Mifflin, Boston, 1979).
- [6]E. Çinlar, Introduction to Stochastic Processes (Prentice-Hall, Englewood Cliffs, NJ, 1975).DOI
- [7]M. I. Freidlin and A. D. Wentzell, Random Perturbations of Dynamical Systems, 3rd ed. (Springer, Heidelberg, 2012).
- [8]R. J. Herrnstein, J. Exp. Anal. Behav. 4, 267 (1961).
- [9]W. M. Baum, J. Exp. Anal. Behav. 22, 231 (1974).
- [10]W. M. Baum, J. Exp. Anal. Behav. 32, 269 (1979).
- [11]J. H. Wearden and I. S. Burgess, J. Exp. Anal. Behav. 38, 339 (1982).
- [12]T. M. Cover and J. A. Thomas, Elements of Information Theory, 2nd ed. (Wiley, Hoboken, NJ, 2006).
- [13]U. Seifert, Rep. Prog. Phys. 75, 126001 (2012).
- [14]G. E. Crooks, Phys. Rev. E 60, 2721 (1999).
- [15]L. Masanes and J. Oppenheim, Nat. Commun. 8, 14538 (2017).
- [16]P. Bak, C. Tang, and K. Wiesenfeld, Phys. Rev. Lett. 59, 381 (1987).
- [17]M. A. Muñoz, Rev. Mod. Phys. 90, 031001 (2018).
- [18]J.-P. Bouchaud, J. Phys. I (France) 2, 1705 (1992).
- [19]C. Monthus and J.-P. Bouchaud, J. Phys. A: Math. Gen. 29, 3847 (1996).
- [20]V. Braitenberg, Vehicles: Experiments in Synthetic Psychology (MIT Press, Cambridge, MA, 1984).
- [21]G. C. McKenzie-Smith, J. F. Ayroles, J. W. Shaevitz, and S. W. Wolf, Drosophila melanogaster Long Timescale Data 2022, Princeton Data Commons, doi:10.34770/1sab-8845 (2023).
- [22]W. Feller, An Introduction to Probability Theory and Its Applications, Vol. II, 2nd ed. (Wiley, New York, 1971).
- [23]R. Bogacz, E. Brown, J. Moehlis, P. Holmes, and J. D. Cohen, Psychol. Rev. 113, 700 (2006).
- [24]A. Clauset, C. R. Shalizi, and M. E. J. Newman, SIAM Rev. 51, 661 (2009).
- [25]B. M. Hill, Ann. Stat. 3, 1163 (1975).