Introduction

Collective behavior is fundamental to systems as diverse as group living in animals1,2, flocking in artificial active matter such as colloids3 and the well-known phenomena of phase transitions in condensed matter4. We know from statistical mechanics of physical systems that interactions between constituents should underlie such collective behavior, which may be applied in a biological context to phenomena such as condensation in midges5,6, schooling, milling and swarming in fish7,8,9, coordinated turning in flocks of birds10,11, clustering in penguin huddles12,13 and the collective movement of sheep14,15,16. In fact, the ultimate goal of many recent studies on the collective behavior in animal systems is to infer the interactions from available experimental trajectories, and construct reliable models for their behavior7,17,18,19,20,21.

In physical systems, the relationship between constituent interactions and their spatial correlations is precisely defined22 so that characterization of these interactions is possible through measurements of two-body and higher-order correlations. Although higher–order correlations can be important at high densities where individuals are strongly coupled, at low density Kirkwood superposition which presumes that 3-body correlations are captured by 2-body correlations is highly accurate22. In the context of animal behavior, social forces, as a proxy to the many–body correlations, have been inferred in previous studies7,17,18,23,24,25. In the case of fish, this may be done either using the force map technique7,17,20 or sophisticated fitting techniques of relevant observables19,21. Often, such a force inference is done for two-fish systems, thought to be the minimal system allowing us to gain an understanding of the complexities of many–fish behavior. However, we still do not fully understand the effect of many–body correlations in animal groups, for the lack of direct determination even though the relevant methods to measure such correlations are well established26,27,28.

Another phenomenon, which is exhibited by systems small in comparison to the thermodynamic limit of a very large number of interacting agents is intermittency between multiple states. In equilibrium, in the thermodynamic limit, outside phase coexistence, a system will adopt a single state. In contrast, small systems can exhibit intermittency between multiple states29,30. Intermittent behavior can be found also in large out of equilibrium systems, for example in the case of active matter31,32,33. The number of constituents in biological systems is necessarily small in a thermodynamic sense and by analogy the role of system size and fluctuations can have significant consequences34, such as variations in the speed of different fish16,35,36,37,38. Indeed, a bistable state was observed for zebrafish, where the schooling and shoaling states coexist8,39. Furthermore, a system of golden shiner fish with a tristable state has been observed, as the fish group exhibits a milling state in which individuals rotate around the group center9. This intermittent, multi-stable feature is also observed in other animal species40,41,42, and it has been reproduced in computer simulations of different agent-based models43,44,45. However, how these interactions scale with group size is poorly understood, likewise the relationship of group size and collective behavior is not extensively explored9.

Here, we use methods from statistical mechanics of many-body systems to systematically investigate higher–order correlations and multistable states in a model system of zebrafish. We consider system sizes of N = 2, 3, 4, and 50 fish, by reconstructing their 3D trajectories with a custom 3D tracking system46. Such an approach allows us to probe changes in the correlations between the fish across the group sizes. That the correlations we observe are quite well reproduced with a pairwise model shows that triplet and higher–order interactions are small, justifying the use of such a model. For a group of N ≥ 3 zebrafish, we observe the existence of schooling, milling and swarming states, which have been seen in other fish species8,9,41. We find that groups of three fish exhibit transitions between these states and thus may be said to exist in a tristable state. This behavior can be reproduced with a simple agent-based model. We examine larger groups up to N = 50, and find a gradual emergence of the dominance of the swarming state, but there is no other effect of group size under our analysis. Locally, however, sub–systems of 3 fish within larger systems exhibit behavior which is hard to distinguish from that of isolated groups of 3 fish. This last point suggests that the fish interact predominantly with their nearest neighbors with more distant fish acting as a background.

Results

Groups of between 2 and 50 wild type zebrafish were observed in a bowl-shaped tank with parabolic section. As indicated in Fig. 1, the geometry was selected because we want to measure the 3D behavior of the zebrafish, since the fish naturally swim in 3D in rivers47. The movement of the zebrafish was recorded with three synchronized cameras, illustrated in Fig. 1. In the images from different cameras, we calculate the 2D feature points belonging to the different fish. Knowing the intrinsic parameters and the positions of the cameras from a calibration process, we reconstructed the 3D coordinates of the fish and linked these coordinates into trajectories. We collected datasets from the same group of adult zebrafish repeatedly, to minimize the variance in the behavior among different groups48. Further details are given in the Methods and ref. 46. We also implement a minimal agent–based model in which the interactions between the fish are parameterized, as we discuss below.

Fig. 1: Experimental set–up.
figure 1

3D reconstruction of fish trajectories with 3 synchronized cameras. The locations of the fish were determined in each 2D image, to calculate the 3D coordinates. The 3D coordinates are subsequently linked into 3D trajectories.

Order parameters

We characterize the dynamical states of the fish with two order parameters. The polarization order parameter Op, is defined as

$${O}_{p}=\frac{1}{N}\left| \mathop{\sum }\limits_{i=1}^{N}\frac{{{{{{{{{\bf{v}}}}}}}}}_{i}}{| {{{{{{{{\bf{v}}}}}}}}}_{i}| }\right|,$$
(1)

where vi is the velocity of the ith fish. The value of Op will be ≈ 1 if all the fish swim in the same direction, and will be ≈ 0 if the swimming directions of the fish are random. Similarly to ref. 9, we call the states with a high Op value (here Op > 0.65) schooling. We also define the rotation order parameter Or, as

$${O}_{r}=\frac{1}{N}\left| \mathop{\sum }\limits_{i=1}^{N}\frac{{{{{{{{{\bf{v}}}}}}}}}_{i}}{| {{{{{{{{\bf{v}}}}}}}}}_{i}| }\times \left(\frac{{{{{{{{{\bf{r}}}}}}}}}_{i}-{{{{{{{{\bf{r}}}}}}}}}_{{{{{{{{\rm{cm}}}}}}}}}}{| {{{{{{{{\bf{r}}}}}}}}}_{i}-{{{{{{{{\bf{r}}}}}}}}}_{{{{{{{{\rm{cm}}}}}}}}}| }\right)\right|$$
(2)

where ri is the location of the ith fish, and rcm is the location of the group center. For a group of fish rotating around the same axis, the value of Or will be ≈ 1. We term the states with a high Or value (here Or > 0.65) milling. Disordered states with low Or and Op values (here Op, Or < 0.35) are termed swarming. Note that these order parameters require the instantaneous velocities of the fish, obtained by tracking the fish between two frames, rather than extended trajectories of each fish. Moreover the spatial correlations that we present require only instantaneous snapshots. Throughout, we set the unit of length to be the average body length of the fish, 30 mm.

In most of our analysis, we neglect differences between individuals. However, our agent–based model allows us to probe the effect of a velocity distribution in the fish population as opposed to a constant velocity for each agent. In some situations, this can be significant16,35,36,37,38. We have investigated the effects of such a distribution to which we return below.

Experimental results

Our experimental set–up is indicated schematically in Fig. 1, from which we obtain different trajectories of up to 50 zebrafish. We measure spatial correlations between the fish as shown in Fig. 2. Here, Fig. 2a defines the orientation, range and velocities of two interacting fish in the laboratory frame. In Fig. 2b, the same two fish are considered, this time in the comoving reference frame of fish i. Henceforth, we consider this latter representation and turn to consider 2–body spatial correlations. We shall consider groups of different numbers of fish and these we term \({{{{{{{{\mathcal{F}}}}}}}}}_{N}\) where N is the number of fish. When we consider the local sub–group of a fish and its n − 1 nearest neighbors in a larger group N, we shall write \({{{{{{{{\mathcal{F}}}}}}}}}_{N}^{n}\). Beginning with two fish, \({{{{{{{{\mathcal{F}}}}}}}}}_{2}\), we see that there are three peaks, corresponding to typical configurations where one fish is following another (the front peak which we have labeled β), and the configuration where the two fish are swimming side-by-side (the two side peaks which we have labeled α and γ). When we consider three fish, \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\), a similar pair correlation emerges, again with three peaks [Fig. 2d]. In the case of 50 fish, we use two representations. Figure 2e shows the same \({g}_{2}({x}^{{\prime} },{y}^{{\prime} })\) representation, while in Fig. 2f, we show the spatial distribution of the nearest fish to fish i at any moment. In the \({{{{{{{{\mathcal{F}}}}}}}}}_{50}\) system, the β peak is lost, suggesting that the fish tend not to follow one another. The emergence of the different peaks, corresponding to qualitatively different swimming configurations, indicates that the fish pass through different states, as we will explore in more detail below.

Fig. 2: Pair correlations in the zebrafish system.
figure 2

Sketch of two fish, showing the relevant quantities for this study in the laboratory reference frame (a) and in the reference frame of fish i (b). By laboratory reference frame, we mean measuring the positions and velocities of the fish with respect to a fixed point in the lab. The fish reference frame referred to in (b) corresponds to measuring positions and velocities with respect to the fish indicated at the origin. Average pair correlations g2 in the reference frame of one of the fish for (c) N = 2 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{2}\)), (d) N = 3 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{3}\)) and (e, f) N = 50 (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}\)) fish. In (e) the correlation of an arbitrary pair out of the 50 fish is shown, whereas (f) shows the correlation of the nearest neighbor pairs (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{2}\)). The letters α, β, γ mark the positions of the different peaks: α, γ indicate the side peaks in the g2 and β the front peak. Here for clarity, we have normalized the correlation distributions by the maximum value, so that the colorbar goes from 0 (white) to 1 (maximum saturation). The contour lines correspond to 0.1, 0.3, 0.5, 0.7 and 0.9. All the data for this figure are taken from the experiments.

The behavior of three fish is like that of many fish

We now consider a system of three zebrafish, \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\) in Fig. 3a–d. For geometric reasons, this is the minimum number of fish required to exhibit the three dynamical states of schooling, milling and swarming. These are shown schematically in the first row, and example experimental trajectories corresponding to each state are shown in the second row. If we consider the time-evolution of the order parameters Op and Or [Fig. 3d] we see that the three fish system is effectively a tristable state, by which we mean that the system transitions between each of the three states schooling, milling and swarming. This three state behavior is shown in more detail in Supplementary Movies 14.

Fig. 3: Three fish exhibit schooling, milling and swarming states.
figure 3

Sketched and example experimental trajectories of the different dynamical states of three fish (a) schooling, (b) milling and (c) swarming. d Time evolution of the rotational and polarization order parameters Or and Op respectively. Here, we consider a 3-fish trajectory. The times at which the different states are found are marked with the corresponding color. Density plots of Or versus Op for (e) N = 2 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{2}\)), (f) N = 3 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{3}\)), (g) N = 4 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{4}\)) and (h) N = 50 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}\)), indicating the occurrence of the different states. Density plots of Or versus Op for small local groups of N = 50 fish, consisting of n nearest neighboring fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{n}\)): (i) n = 2 (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{2}\)), (j) n = 3 (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\)) and (k) n = 4 (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{4}\)). l Density plot of Or versus Op for N = 3 fish from simulation data. The colored rectangles mark the regions of Op, Or values which indicate the occurrence of each state, with the enclosed values showing the percentage of cases that exhibit the respective state. Here the gray shading refers to the count in each bin, as expressed by the colourbar above each panel. The bins have a side of 0.025.

We now consider the effect of system size on the multistate behavior in Fig. 3e–h for the \({{{{{{{{\mathcal{F}}}}}}}}}_{2,3,4}\) and \({{{{{{{{\mathcal{F}}}}}}}}}_{50}\) systems. The time–evolution of these systems is shown in the Supplementary Movies. For the two–fish system \({{{{{{{{\mathcal{F}}}}}}}}}_{2}\) (Supplementary Movie 1), indeed the swarming state (low Op, low Or) is not seen. However for three fish \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\), it is found, although rather rarely (Fig. 3f, Supplementary Movie 2). As the number of fish increases, the weight of the swarming state increases at the expense of both the schooling and milling states so that for 50 fish \({{{{{{{{\mathcal{F}}}}}}}}}_{50}\), it dominates (Fig. 3g, h, Supplementary Movies 3, 4). This observation is consistent with previous results8,9. This increase in the swarming state appears to be gradual with no indication of anything like a “phase transition”. See Supplementary Fig. 2 where we plot intermediate system sizes for simulated data. In other words, at the level of the order parameters Op and Or, the characteristics of the “crowd” (here the 50 fish system) are already present in the 3 fish system, but not in the 2 fish case.

Local subgroups in a large system behave like isolated groups

We can also analyze local subgroups of larger systems. That is to say, we determine the order parameters (Op, Or) for the subgroups within the \({{{{{{{{\mathcal{F}}}}}}}}}_{50}\) system, which we define as the fish of interest and its nearest neighbors. In Fig. 3i–k, we show the \({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{2,3,4}\) systems. The similarity with the isolated groups \({{{{{{{{\mathcal{F}}}}}}}}}_{2,3,4}\) is quite remarkable. While the absolute values of the populations in each state vary slightly, the trend is identical. In other words, at the level of this analysis, the behavior of n = 2, 3, 4 fish is essentially unaffected by more distant neighbors, which might suggest that the fish interact weakly over longer ranges, which is consistent with earlier work on mosquitofish which showed that the nearest neighbor dominates the interaction7. The results from these dynamical order parameters then contrast somewhat with the spatial order parameters shown in Fig. 2, where we see that the β lobe of the \({{{{{{{{\mathcal{F}}}}}}}}}_{50}\) system is weaker than that in the case of \({{{{{{{{\mathcal{F}}}}}}}}}_{2}\) (Fig. 2c).

To probe this intriguing behavior further, we consider spatial correlations between the fish in more detail. In Fig. 4a1, a2, a3, we show \({g}_{2}({x}_{2}^{{\prime} },{y}_{2}^{{\prime} })\) for the different states of the 3 fish system. Here, we see that in the schooling state, the β peak is quite strong, as the fish follow each other, while in the milling state the α and γ peaks dominate. This is reasonable, since in the milling state the three fish rotate around their center of mass, so they are more likely to be found at the sides of a reference fish, with an opposite orientation from it. For the swarming state, the α and γ peaks dominate, but there is a weak β peak due to the randomness of the motion. These results are consistent with the \({g}_{2}({x}_{2}^{{\prime} },{y}_{2}^{{\prime} })\) behavior with respect to system size shown in Fig. 2, where we saw that small systems had significant α, β and γ peaks, indicating multistability between schooling, milling and swarming.

Fig. 4: Pair correlations g2 in the reference frame of one of the fish for the different states.
figure 4

a1a3 N = 3 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{3}\)) and (b1b3) local groups of n = 3 nearest neighbor fish in the case of N = 50 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\)). We distinguish between the different states as follows (a1, b1) schooling, (a2, b2) milling and (a3, b3) swarming state. Here for clarity, we have normalized the correlation distributions by their maximum value, so that the colourbar goes from 0 (white) to 1 (maximum saturation). The contour lines correspond to 0.1, 0.3, 0.5, 0.7 and 0.9. c Probability distribution of the three-fish bond angle \({\theta }_{r}^{(3)}\) of N = 3 fish in the milling (green line with circles), the swarming (orange line with circles) and the schooling (purple line with circles) states. The dashed lines show the corresponding results for \({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\).

For the local subgroups of larger system sizes, here \({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\), the pair correlations \({g}_{2}({x}_{2}^{{\prime} },{y}_{2}^{{\prime} })\) for the milling and swarming states (Fig. 4b2, b3) are similar to those for the 3 fish system (Fig. 4a2, a3), showing an increased weight of the side peaks α, γ. The schooling state, however, is quite different from the \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\) system, showing a domination of the α, γ peaks over the front peak β. Note that in this case the local subgroup of 3 nearest neighbor fish is highly polarized and the side peaks point to the fish swimming side-by-side with the same orientation, unlike the side peaks for the milling state. This implies that, during schooling, the local subgroups of larger groups swim parallel to each other instead of following each other in a line, forming more compact dynamical configurations, probably due to the limitation of available space.

More information about the many-fish configurations can be gained by considering higher–order spatial correlations. Here we examine first the probability distribution of the bonding angle between the three fish \({\theta }_{r}^{(3)}\) shown in Fig. 4c. Here, we set the range of separation between the fish to the principle peak of g2 for each state (See the SI for further details). As we see, for the \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\) system the schooling state shows a peak at smaller angles (\({\theta }_{r}^{(3)} \, \approx \, 3{0}^{\circ }\)) and an increasing probability for high angles around 180°, pointing once again to the fish following each other. In contrast, for the milling state there is a single peak at (\({\theta }_{r}^{(3)} \, \approx \, 6{0}^{\circ }\)), as expected by symmetry, whereas the result for the swarming state lies between the milling and schooling ones. Such a discrepancy between the different states is lost when exploring the local subgroup of a larger system \({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\), indicating a suppression of spatial correlations.

Among the key achievements using higher–order spatial correlations is Kirkwood superposition, where three–body correlations are predicted from two–body correlations. Specifically, g3(r12, r23, r31) ≈ g2(r12)g2(r23)g2(r31), with rij, the distance between the fish i and j. This superposition principle was originally suggested by Kirkwood49 and has since become a cornerstone to approximate triplet correlations in liquid state physics50. Kirkwood superposition holds in dilute, weakly interacting passive systems and is expected to hold even in non-equilibrium steady states as in the present case if three–body interactions are weak. To our knowledge, it has not been probed in active matter or biological systems exhibiting collective behavior until now, and there is no reason to suppose that it would hold. In Fig. 5, we show that for the three fish system, there is a discrepancy between Kirkwood superposition and the measured \({g}_{3}({\tilde{x}}_{3},{\tilde{y}}_{3})\) in the schooling state. In particular, there is a high probability of a third fish between two fish in the actual data compared to the prediction from Kirkwood superposition, as shown in the difference between Fig. 5b1, a1, which could imply the existence of some three-body interactions in the case of three fish in the schooling state.

Fig. 5: Analysis of three-body correlations in zebrafish.
figure 5

a1b3 show data from N = 3 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{3}\)) and (c1c3) local group of n = 3 fish (\({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\)) fish in the schooling state as found in the experiment. The first row (a1a3) shows the Kirkwood superposition approximation of the three fish correlation \({g}_{3}^{(K)}\) for \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\). The second row (b1, b2, b3) shows the full three fish correlation g3 for \({{{{{{{{\mathcal{F}}}}}}}}}_{3}\) and the last row (c1, c2, c3) shows g3 for \({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\). In (a1, b1, c1) we present spatial three-body correlations \({g}_{3}^{(K)},{g}_{3}\), without resolving the orientation of the two reference fish. In (a2, b2, c2) we present the three-body correlations \({g}_{3}^{(K)},{g}_{3}\) for the reference fish aligned side-by-side whereas in (a3, b3, c3) we show \({g}_{3}^{(K)},{g}_{3}\) for the reference fish aligned head-to-tail.

Here for a better visualization of the three body correlation, without loss of generality we constraint the distance of one pair, r12, within a small window around its most probable value \({r}_{\max }\). Then, assuming the x-axis to coincide with the orientation of r12, and the origin with the midpoint \({{{{{{{{\bf{r}}}}}}}}}_{O}=\left({{{{{{{{\bf{r}}}}}}}}}_{1}+{{{{{{{{\bf{r}}}}}}}}}_{2}\right)/2\), we find the 2D distribution of the third fish position \({g}_{3}({\tilde{x}}_{3},{\tilde{y}}_{3})\). A similar procedure is followed for the visualization of the Kirkwood superposition \({g}_{3}^{(K)}({\tilde{x}}_{3},{\tilde{y}}_{3})\). More details can be found in the SI and in ref. 51.

In Supplementary Fig. 4, we show that Kirkwood superposition holds well in the milling and swarming states suggesting that in these states, three–body interactions are weak. To probe further the discrepancy in the schooling state, we consider different configurations in Fig. 5. We find that in fact when two of the fish swim side–by–side parallel to each other, Kirkwood superposition holds rather well (Fig. 5a2, b2), predicting that the third fish either leads or follows the two fish. The discrepancy of the third fish between the two emerges when the fish follow one another in a line as shown in Fig. 5a3, b3. This is not the case for the subgroups \({{{{{{{{\mathcal{F}}}}}}}}}_{50}^{3}\), where even when the two fish follow each other the third fish swims parallel to them on the side (Fig. 5c3).

A minimal model

To capture the behavior of the zebrafish, we simulate an agent–based perception model. For simplicity, at first we give each agent a constant speed v0, before considering the case of variable speed. Our model is implemented in 2D which takes the confinement of the tank in the lateral plane (a circle) into account and includes strong attractions and weak aligning interactions between the fish, supplemented with a repulsion at short distances. Furthermore, we implement a field of view between the fish. As previously found, for zebrafish the attraction plays a significant role in their behavioral interactions19,21. We have observed that in simulations dominated by such attractive interactions, it is challenging to detect a prominent milling state as found here (Fig. 1). In order to overcome this difficulty we have also taken into account in our model a form of hydrodynamic interactions, in the spirit of ref. 52. Further details of our model which exhibited all three states are provided in the Methods and SI. Unless explicitly stated, the simulations were carried out with the set of parameters in Supplementary Tables I and II for the fixed and variable speed models respectively.

As shown in the SI, we find that our model predicts correctly the intermittent dynamics observed already for three fish, exhibiting schooling, milling and swarming (Supplementary Fig. 1). It shows also that by increasing the number of fish, the system spends progressively more time in the swarming state and that local subgroups of larger system behave like isolated groups. Regarding the pair correlations, our simulation results capture qualitatively well the fact that there are prominent front-and-back peaks in the schooling state, whereas the highest peaks in the milling state are those at the sides of the reference fish (Supplementary Fig. 3). The simulations also show an increased probability to find the third fish between the two reference fish, when the latter swim in a head-to-tail configuration (Supplementary Fig. 5). However, in the simulations this is mostly captured by the Kirkwood superposition, and there is not such a prominent middle peak as in the experiments (Fig. 5b3). This fact could imply the existence of some three-body interactions in the three-fish shoals in the experiments. Overall our simulations show somewhat weaker differences between the local subgroups of larger groups \({{{{{{{{\mathcal{F}}}}}}}}}_{N}^{n}\) and the corresponding isolated fish groups \({{{{{{{{\mathcal{F}}}}}}}}}_{n}\) than that found in experiments.

So far, we have assumed implicitly in our analysis of the experiments and explicitly in our simulations that all the fish are identical. Of course, in biological systems (unlike many, but not all53 physical systems), this is not the case. Variable speed impacts collective movement36,38, leadership behavior is encountered36,37, along with differences in some fish which are less risk–averse than others35. Here, we probe the effect of a variation in the distribution of speeds of individuals due to the social interactions and boundary (see SI). In fact, we find this has rather little effect on the observables we study, as shown in Supplementary Fig. 6.

An important reason for the observed discrepancies between experiment and simulation could be the simplified assumption of tank shape as a 2D circle instead of a parabolic tank (see also discussion in SI). Further limitations come from the assumption of an overdamped dynamics and the simplified description of the interactions. It would be interesting therefore to explore in further numerical studies whether more sophisticated models can improve the agreement with the experimental results presented here.

Discussion

We have considered groups of 2–50 zebrafish and characterized their behavior in terms of dynamical order parameters and spatial two- and three-body correlation functions. We further investigate the behavior of smaller local sub-groups of a larger 50 fish group. The minimum group that can exhibit the three states characteristic of the zebrafish system is three fish, and in fact, we find that this small system features most of the phenomena of larger groups, at the level of our analysis.

The main effect of increasing system size is to shift the statistical weight between the three states of the multistate system that the fish form. In particular, for small systems, the dominant states are the more ordered schooling and milling states, with the disordered swarming state exhibiting a smaller weight. Upon increasing the system size, the fish spend more and more of their time in the swarming state, with no evidence for any kind of sharp transition. Thus, remarkably, we find that, under our analysis, the basic characteristics of large groups are captured by as few as three fish.

This system size dependence would appear to be an analogue of the approach to the thermodynamic limit, well known from passive systems in equilibrium. Examples of this behavior include small atomic clusters which can exhibit structure quite different from the thermodynamic limit of a crystal (for example, five-fold symmetry)54 and confined colloidal systems which can exhibit bistable states with very different structure from the thermodynamic limit29. Here, however, the behavior of the large system is largely recovered with just three constituents.

We show that smaller subgroups of larger groups are very similar indeed to isolated systems of the same size. In this sense, the more distant fish could be thought of as a background, i.e., a kind of “fish soup”. That is to say, the similarity of near–neighbor correlations in the small groups embedded in larger groups and the isolated groups suggests that the nearest neighbor interactions dominate and the other fish are less important. This behavior in zebrafish is different from that of starlings, which exhibited scale–free correlation55, so that the behavioral change of an individual bird can be quickly propagated to the entire flock10. Instead, the behavior of zebrafish seems similar to that of the midges, because both systems turn out to exhibit disordered collective motion5 which can be described by a global force–field neglecting the explicit interaction between individuals56,57.

In our work, we also emphasize the importance of properly considering the many-body correlations in animal systems. As shown, the sampling of different trajectories of even small-sized groups of fish can give rise to mixed correlations and observables, due to their intermittent dynamics. In turn, each of the occurring dynamical states (schooling, milling, swarming) is associated with significantly different correlations and observable values. Our work opens the use of many–body spatial correlation functions for active matter, which might be applied to well-studied systems, for example, midges6, and more complex systems such as birds10,55 which may interact with more neighbors and in fish under different conditions which may cause changes in underlying social interactions35. An important test of these ideas would be to apply a similar analysis to well–controlled, and perhaps tunable experimental systems, such as active colloids3.

In a biological context, our work suggests that the fish interact mainly with their nearest neighbors. Therefore, one would expect from such an analysis that the fish system would respond locally to a change in the environment, such as the appearance of a predator35,58. However, the observations we have made pertain to the case where the environment remained unchanged, and we have no way of knowing if the social interactions between fish would be the same. Clearly, more work is needed to address this question, perhaps by employing an approach similar to that used in ref. 24, where the shape of fish shoals under predation was explored. Given the change in shape of the shoals found in that work, there is cause to imagine that predation could change the interactions in the zebrafish system considered here, suggesting that application of the analysis we have carried out here would yield interesting insights into the social interactions of the fish. Other intriguing possibilities include relating the properties of different species to the observables considered here. For example, golden shiners have a somewhat different visual field to the zebrafish considered here59. The analysis we introduce here provides a new way to relating changes in social interactions to the physical properties of the fish.

Methods

Fish husbandry

All the fish used in the experiment were wildtype zebrafish, and they were bred at the fish facility of the University of Bristol. The fish were kept at the standard living conditions60. The experiments were approved by the local ethics committee (University of Bristol Animal Welfare and Ethical Review Body, AWERB) and given a UIN (university ethical approval identifier, UB/19/050).

Experiment

The zebrafish were transferred from their living tank to a temporary tank, then introduced in the observation tank. We perform two “two-fish” experiments, and one “three-fish” experiment successively. Typically, three fish (fish A, B, and C) will be transferred to a temporary tank. The fish A and B will be introduced to the observation tank, where we carried out the first two-fish observation. Then fish B is taken back to the temporary tank, while fish C is introduced to the observation tank, so that the second two-fish experiment could be carried out. Finally, all the fish were placed in the observation tank, and we perform the three-fish observation. For the 4 and 50 fish experiment, we placed 4 or 50 fish into the observation tank from the temporary tank directly. During the observation, we discard the first 10 min to allow the fish to become familiar with the new condition, and start video recording after this period.

The experimental data were sampled as follows. For the two fish experiment, we selected 12 different pairs randomly chosen from a group of 50, and observed each pair for 1 h. For the three fish experiment, we selected 6 different triplets from a group of 50, and observed each triplet for 1 h. For four fish experiment, we selected 5 different quadruplets from a group of 50, and observed each quadruplet for 1 h. The group of 50 itself was observed for 1 h. Further details may be found in the SI.

Data processing

The movement of the zebrafish were filmed in a separate bowl-shaped observation tank whose radius r increases with the height z following z = 0.73r2. The water in the observation tank is the same to the water that the fish live in, but the observation apparatus has its own water circulation and filtration system. The temperature of the observation tank was heated by two commercial heaters, having a temperate of around 25°C. Three cameras (Basler acA2040 um) were used to record the movement of the fish, which were triggered by synchronized signals from an Arduino microchip46.

From the videos, we locate individual fish in successive frames, as 2D images. With the 2D locations from different views, we calculate their 3D locations following conventional computer vision method61,62, with the water refraction being explicitly considered46. The locations were linked into trajectories following a four frame linking procedure63. These trajectories were further linked following Xu64.

Simulation model

To probe in more detail the surprising behavior that we see (weak interactions inferred from dynamical order parameters, strong interactions inferred from spatial order parameters), we now turn to a perception model in which the zebrafish interactions are dominated by the repulsion-attraction between the fish. For completeness we also include weak alignment interactions, as well as some hydrodynamic interactions, inspired by ref. 52. Our model is as follows. We assume that the fish move in 2D with a constant speed v0 and can only change their velocity orientation given by the angle ϕi (Fig. 2a). Thus, the 2D overdamped equations of motion for fish i read

$${\dot{x}}_{i}={v}_{0}\cos {\phi }_{i}$$
(3)
$${\dot{y}}_{i}={v}_{0}\sin {\phi }_{i}$$
(4)
$${\dot{\phi }}_{i}=\frac{1}{{v}_{0}}\left({F}_{i,\phi }^{({{{{{{{\rm{wall}}}}}}}})}+{F}_{i,\phi }^{({{{{{{{\rm{int}}}}}}}})}+{\eta }_{i,\phi }\right),$$
(5)

where \({{{{{{{{\bf{F}}}}}}}}}_{i}^{(wall)}\) stands for the interactions of fish i with the wall, \({{{{{{{{\bf{F}}}}}}}}}_{i}^{({{{{{{{\rm{int}}}}}}}})}\) denotes the total interactions of fish i with all the other fish. The subscript ϕ stands for the projection of the respective forces in the turning direction

$${{{{{{{{\bf{e}}}}}}}}}_{i,\phi }=-\sin {\phi }_{i}{{{{{{{{\bf{e}}}}}}}}}_{x}+\cos {\phi }_{i}{{{{{{{{\bf{e}}}}}}}}}_{y}.$$
(6)

The term ηi,ϕ stands for a zero-mean Gaussian noise with \(\langle {\eta }_{i,\phi }(t){\eta }_{j,\phi }(t+\tau ) \rangle=2{D}_{\phi }{\delta }_{ij}\delta (\tau )\). We use as our length unit L the average body length of the zebrafish 30 mm and use the average speed of zebrafish vf = 100 mms−1 to derive the time unit as T = L/vf = 0.3 s. In these units we have Dϕ = 0.015 and v0 = 1.

We assume that the fish are confined in a circular tank of radius R = 66.7 L and model the wall avoidance interactions \({{{{{{{{\bf{F}}}}}}}}}_{i}^{({{{{{{{\rm{wall}}}}}}}})}\) by a soft repulsive potential. The interactions between the fish i and any other fish j are assumed to consist of repulsion-attraction \({{{{{{{{\bf{f}}}}}}}}}_{ij}^{({{{{{{{\rm{att}}}}}}}})}\), alignment \({{{{{{{{\bf{f}}}}}}}}}_{ij}^{({{{{{{{\rm{al}}}}}}}})}\) and hydrodynamic interactions \({{{{{{{{\bf{f}}}}}}}}}_{ij}^{({{{{{{{\rm{hyd}}}}}}}})}\), so that the total interaction force acting on fish i reads

$${{{{{{{{\bf{F}}}}}}}}}_{i}^{({{{{{{{\rm{int}}}}}}}})}=\mathop{\sum}\limits_{j \, \ne \, i}\left({{{{{{{{\bf{f}}}}}}}}}_{ij}^{(att)}+{{{{{{{{\bf{f}}}}}}}}}_{ij}^{(al)}\right)+{{{{{{{{\bf{f}}}}}}}}}_{ij}^{(hyd)}.$$
(7)

For the particular expressions of the aforementioned forces, as well as further details on the numerical simulations, we refer the reader to the SI.

Reporting summary

Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.