Detecting phase transitions in collective behavior using manifold's curvature

If a given behavior of a multi-agent system restricts the phase variable to a invariant manifold, then we define a phase transition as change of physical characteristics such as speed, coordination, and structure. We define such a phase transition as splitting an underlying manifold into two sub-manifolds with distinct dimensionalities around the singularity where the phase transition physically exists. Here, we propose a method of detecting phase transitions and splitting the manifold into phase transitions free sub-manifolds. Therein, we utilize a relationship between curvature and singular value ratio of points sampled in a curve, and then extend the assertion into higher-dimensions using the shape operator. Then we attest that the same phase transition can also be approximated by singular value ratios computed locally over the data in a neighborhood on the manifold. We validate the phase transitions detection method using one particle simulation and three real world examples.

1. Introduction.Multi-agent systems such as crowds of people [22,27,45], schools of fish [20,31], flocks of birds [8,28], colonies of molds [32] and ants [33] often exhibit discrete phase transitions due to variations of interaction among members [10].Specially, detecting phase transitions in crowds of people [6] is a popular research problem [7].Abrupt changes upon variation of some parameters such as speed, coordination, and structure [9,26,42] shift the phase of the system from one state to another [15,36].Numerous types of swarm decisions which determine the group dynamics are not only influenced by the intrinsic social interaction among members [14], but also by some outside factors such as threats [38] and presence of predators or food sources [40].However, with a majority of data is recorded as videos, the classical approach of detecting phase transitions by means of tracking individuals and monitoring their dynamics is constrained by the size of the group and the scale of the problem [25].Being inspired by manifold representation of collective behavior, here we develop a method of detecting phase transitions in a multi-agent system.
In manifold theory, we can reveal an invariant manifold M, in an abstract higherdimensional space which describes the collective behavior of a group such that each frame partitioned from the collective behavior video corresponds to a point p on the manifold [4].In this setup, the whole group evolves according to the underlying flow where p (t1) and p (t2) are two points representing two consecutive frames at timesteps t 1 and t 2 , respectively [17].Due to an abrupt behavioral change of the group, this mapping switches from one phase space to another and indicates a phase transition of the motion.Thus, in the presence of a phase transition, the system can be represented as two distinct sub-manifolds, M (j) for j = 1 and 2, along with singularities where the phase transition physically exists [18].Herein, the most salient scenario is that the sub-manifolds intersect and make a locus L of singularities as As an example, we estimate dimensionalities of two distinct phases, walking and running, of a crowd of people given as a video in [2].Two phases of the motion are embedded into two distinct manifolds as shown in Figure 1(a).We utilize an established dimensionality reduction routine called Isomap [39] to obtain corresponding scaled residual variances of two embedding spaces (Fig. 1(b)) of each phase.Figure 1(b) shows that the two phases are embed on manifolds with different dimensionalities.This example acts as a proof-of-concept for developing an routine to detect phase transitions.Detecting phase transitions should be naively implemented on videos before utilize dimensionality reduction schemes such as Isomap [39], Local Linear Embedding [35], as those may otherwise contain phase transitions.
A phase transition in a multi-agent system is defined as a switching of the current smooth embedding manifold into another smooth manifold with different dimensionality as trajectories of agents evolve in the phase space.Our approach of detecting phase transitions is based on revealing high curvature on the manifold which differentiate phases of the motion.We hypothesize that a phase transition is manifested in the form of change in local curvature that can be detected by a ratio of singular values computed on points sampled on the manifold.We first formulate this concept in two dimensions by proving a relation between curvature and singular value ratio in a curve, and then extend it to higher-dimensions by using the shape operator.Then, we justify that the same phase transition can also be detected by analyzing the ratios of the smallest singular value to the largest singular value which are computed locally upon neighborhoods of points sampled on the manifold.Based on the distribution of a moving sum of absolute moving difference of the singular value ratios, phase transitions are detected and their magnitudes are ordered.
This paper is organized as follows: Section 2 describes the method of detecting phase transitions.In Section 3, the method along with the detailed algorithm of detecting phase transitions in collective behavior is presented.Section 4 describes the performance of the method using one synthetic dynamical simulation of the Vicsek model and three natural experimental data sets, a crowd of human, a flock of birds, and a school of fish.We conclude the work in Section 5 with a discussion of the method including the performance and future work.
2. Method of detecting phase transitions.We declare that, in presence of a phase transition, the curvature of the underlying manifold is abruptly changed.Therein, we first approximate the point-wise curvature of a curve in two dimensions and then extend it to higher dimensions using the shape operator.Finally, we attest that the same phase transition can also be approximated locally by singular value ratios computed over the data sampled on the manifold.

2.1.
Approximating the curvature of a curve.Point-wise curvature of a curve is approximated by using singular value ratio computed over the data sampled in a neighborhood at the point.We assume that the data is evenly distributed along the curve.As in Figure 2(a), we can superimpose a neighborhood at any given point p on the curve with an arc p 1 pp 2 of a translating circle such that the arc subtends a small angle of 2T at the center O.We consider the curvature of a translating circle instead of that of the curve since they are similar in aforesaid setup.Thus, we prove the assertion providing the relationship between curvature and singular value ratios over the data sampled on a circle.
Theorem 2.1.Given a circle centered at the origin with radius r, let α number of points are uniformly distributed with density ρ on an arc which subtends an angle of 2T at the center.Let σ 1 and σ 2 (σ 1 > σ 2 ), are two singular values computed upon the data on the curve, then σ 2 /σ 1 ≈ M κ where κ = 1/r and M = α  Proof.We rotate the circular sector p 1 p 2 O such that the line bisecting the angle p 1 pp 2 which is shown by a blue arrow in Figure 2(a) is horizontal.We consider this blue arrow as the horizontal axis and compute the singular values of the data sampled from the arc.A point p(x 1 , x 2 ) on the arc is given by x 1 = r cos t , x 2 = r sin t for t ∈ [−T, T ].Expected values of variables x 1 and x 2 are computed as and respectively.We then compute pairwise covariance between variables as and The covariance matrix Σ, of the data is The covariance matrix which is approximated to 5 th order of T by using the Taylor's expansion is Let eigenvalues of Σ are λ 1 and λ 2 (λ 1 > λ 2 ), then As eigenvalues are computed upon the covariance matrix, they also relate to principal components.We denote singular values associated with principal components by σ 1 and σ 2 (σ 1 > σ 2 ) and relate them to eigenvalues as Further, since T is small.Let, α points are uniformly distributed with the density ρ on the arc, then, By ( 13) and ( 14), 2.2.Approximating the curvature of a manifold.We extend the two dimensional assertion into higher dimensions by intersecting principal sections, made by the shape operator, with the manifold.Extrinsic curvatures of a manifold in orthogonal tangential directions are measured using eigenvalues and eigenvectors of the shape operator [29,34], such that eigenvalues provide magnitudes and eigenvectors provide directions of principal curvatures along tangential directions [5].Bellow we explain the computation of the shape operator and principal sections.
Let M m = f 1 (x 1 , . . ., x m ), . . ., f m (x 1 , . . ., x m ) represents the parametric form of the manifold embedded in the Euclidean space R m+1 .For j = 1, . . ., m, provide mutually orthogonal tangential vectors and unit tangential vectors of M m at p, respectively.Thus, v(j) p ∀ j is an orthonormal basis for the tangential space at p.The shape operator S p , of the manifold M m at the point p is defined as [ 29,34].
for j = 1, . . ., m denote eigenpairs of S p , then magnitudes and directions of principal curvatures are given by κ u (j) p and u (j) p , respectively [5].The two-dimensional plane in R m+1 which is spanned by the principal direction u (j) p and the unit normal at p, N p , is defined as the j-th principal section, Thus, for j = 1, . . ., m, Π p are mutually orthogonal planes.A computational example of producing principal sections is attached in Appendix A. Intersection of p are created by using the shape operator at p, and curves C (1) and C (2)  are produced by intersecting Π  Without loss of generality, for j = 1, . . ., m, we assume that the data is distributed uniformly with a sufficient density on C (j) to contain α points in a neighborhood at the point p.For all j, singular values σ (j) 1 and σ 2 ) are computed upon the data sampled in the neighborhood of p on C (j) .By Theorem 2.1, curvature κ (j) on the curve C (j) is approximated as σ for some M (j) ∈ R + .A phase transition differentiates the manifold into two submanifolds such that each map with a different Euclidean space [24].Thus, under a phase transition, geometry permits that the curvature of some curves, C (j) 's, undergo abrupt changes which also result abrupt changes of the ratios σ A generic example.As a simple geometric example to illustrate high curvature on a manifold at a phase transition, we use a three-dimensional joined-manifold that we call a 'sombrero-hat' (Fig. 4(a)) of 2000 points produced by the equations for R ∈ U[0, 4] and θ ∈ U[0, π].This sombrero-hat intersects two sub-manifold, brim (green) and crown (blue) at the locus of singularities (red) representing a phase transition.Instead of constructing principal sections using the shape operator, for simplicity, we intuitively find a principal section in this example at the point (0, 0, 4).Since the curvature of the manifold is same in all tangential direction at this point, we choose one principal direction to be î, the unit vector along the x 1 -axis.The unit normal at this point is k which is the unit vector along the x 3 -axis.Thus, we define the plane {β 1 î + β 2 k|β 1 , β 2 ∈ R} as the principal section.Intersection of this principal section with the sombrero-hat gives a curve as shown in Figure 4(b) which 2.3.Phase transition via local data distribution on the manifold.As the construction of the shape operator at a neighborhood of each point on the manifold is computationally expensive, here we present an alternative approach to compute the singular value ratios and detect phase transitions.Therein, we first make a neighborhood N p ∈ R m+1 at each point p, such that it contains α ∈ N points by using nearest neighbor search algorithm given in [16,44].Then, we perform singular value decomposition 1 for data in each N p and denote the descending order by σ 1 , . . ., σ α for some α ∈ N. Without loss of generality, we assume that the data distribution in each C (j) is dense enough for N p to contain data from each curve C (j) , j = 1, . . ., m, made in Section 2.2.However, N p contains at least the point p, from each C (j) as shown in Figure 3 which depicts the same scenario for a two dimensional manifold M 2 , in R 3 .
According to this setting, we assert that an abrupt change which is detected by the ratio σ in some curves created through p is also detected by the ratio σ α /σ 1 computed over the data in N p on the manifold M m .In this study, we use frames partitioned from a collective motion video as data.A group of agents evolving with mutual interaction can be explained in terms of a hidden manifold structure such that each frame corresponds to a single data point on the manifold.Thus, we consider the point p on the manifold corresponds to the n-th frame of the video.Let consider N frames are embedded on the manifold, thus the distribution provides the magnitudes of the phase at each frame.Phase changes between consecutive frames are measured by moving differences of singular value ratios computed over neighborhoods of corresponding points as 1 Singular value decomposition finds singular values σ 1 , . . ., σα for some α ∈ N, and two unitary matrices U and V , such that U U = V V = Iα, those provide the decomposition As the distribution t n is highly volatile, we utilize α-points moving sum where α/2 is the ceiling function2 , and smooth the distribution.After a phase transition occurs, manifold curvature is abruptly changed and then so the singular values.Thus, a phase transition between n-th and (n + 1)-th frames can be quantified by the magnitude of Σ α n .
3. Algorithm for detecting phase transitions.This algorithm requires two inputs, one is the parameter α for number of nearest neighbors and the other is the data matrix D constructed as bellow.We assume input data is gray-scale images partitioned from a video of collective behavior.We reshape each frame into a row matrix and produce the data matrix D by concatenating each row matrix vertically such that n-th row in D represents the pixel intensities of the n-th frame for some n [11].Since the n-th row of D, denoted by D(n, :), is the coordinates of the n-th point on the manifold, Euclidean distance, denoted by d D , between any two points n and n , on the manifold is computed as Based on this distance, α nearest neighbors for the n-th point are extracted and denoted as the set N n (same as N p in Section 2.3).Then, we compute α n over N n as explained in the Section 2.3.Algorithm outputs magnitudes of phase changes Σ α n , so we can choose the largest among them as phase transitions.The method of detecting phase transitions is given as Algorithm 1.

Algorithm 1 Phase Transition Detection in Collective Behavior
Procedure PTD (α, D) 1: Perform nearest neighbor search in [16,44] to obtain α nearest neighbors for each frame in D. Here, we denote α nearest neighbors of the n-th frame in D by the set N n .2: Perform singular value decomposition over [21] on N n and denote the descending order of singular values by σ 1 , . . ., σ α for some α ∈ N. 3: Compute the ratio σ α /σ 1 for N n and denote by (σ α /σ 1 ) n where n = 1, . . ., N .4: Compute absolute moving difference of ratios, where α/2 is the ceiling function.6: Largest values of Σ α n are extracted as phase transitions.end procedure 4. Group behavioral examples.In this section, we evaluate the phase transition detection algorithm on four datasets: a synthetic dynamical simulation of the Vicsek model and three natural data sets; a crowd of people, a flock of birds, and a school of fish.

4.1.
A simulation of the Vicsek model.A swarm of self propelled particles with three imposed phase transitions simulated by the Vicsek model [42] is examined to investigate the sensitivity of the algorithm.This model outputs two-dimensional positions and orientations of particles in each time-step.
We modify the notation for set of nearest neighbors used in Section 2.3 as to denote all the nearest-neighbors of the i-th particle within a unit distance at the n-th time-step.The Vicsek model [42] updates the orientation θ n of the i-th particle at the n-th time step as and n−1 is the noise parameter sampled from a Gaussian distribution with mean zero and standard deviation σ.Here, V (i) n−1 is the average direction of motion of all the particles in N n of the i-th particle at the n-th time step is therefore updated as where δ is the time-step size and s n−1 is the speed of the i-th particle at the timestep (n−1).
We run a simulation of this model and generate a synthetic data set of a particle swarm of 50 particles in 200 time-steps with periodic boundary conditions.We set δ = 0.05 and s (i) n = 0.1 for all i and n.We impose three phase transitions by changing the noise (i) n , using a variable standard deviation for all i, in the Gaussian distribution.For n = 1, . . ., 200, we convert point-mass positions of particles at the n-th time-step, a (i) n i = 1, . . ., 50 , into a gray-colored frame such that the position of each particle is represented by a black square of pixels 10 × 10.Therein, we first convert the positions of particles into a sparse matrix A n , at each time step n = 1, . . ., 200.Then we make a rotationally symmetric Gaussian low-pass filter B of size 10 × 10 pixels with standard deviation of 10 pixels and filter the matrix A n by B to generate for n = 1, . . ., 200 [12].Each matrix C n is converted into a frame and all the frames are finally converted into a one data matrix D.
We run the phase transition detection algorithm upon D with several α values and observe that the distribution (σ 4 /σ 1 ) n generated by α = 4 (Fig. 5 clear phase changes with respect to noise changes.The plot of 20 largest phase changes (Fig. 5(b)) reveals that three phase changes at frame numbers 150, 99 and 50 are significant than others and we consider them as phase transitions.Thus, the manifold representing the whole motion is partitioned into phase transition free 4 sub-manifolds ranging 1 − 50, 51 − 99, 100 − 150 and 151 − 200.We run Isomap on each range of frames with the neighborhood parameter four and obtain the residual plots given in Figure 5(c).The Isomap residual plots indicating the embedding dimensionality by an elbow, reveal that the sub-manifolds are embedded in three, six, two, and four dimensions, respectively.

A human crowd.
A video of a human crowd available on-line at [3] containing a phase transition at the 69-th frame from walk to run is considered now.
As in Example 4.1, we first convert all the frames into a data matrix D, and then run phase transition detection algorithm on it.When α = 3, we observe that the distribution (σ 3 /σ 1 ) n given in Figure 6(a) shows clear trade-off about the frame numbers.

4.3.
A bird flock.We now detect a phase transition, differentiating phases of sitting and flying, at the 58-th frame in a video of a bird flock obtained on-line at [1].We run phase transition detection algorithm on the data matrix with α = and obtain the distribution (σ 3 /σ 1 ) n in Figure 7(a).The plot of 20 largest phase changes in Figure 7(b) illustrates that the video consists one phase transition at the 58-th frame and has the magnitude of 0.32.Then, the manifold is partitioned into two sub-manifolds representing frames in the ranges 1 − 58 and 59 − 100.Isomap running on aforesaid ranges with α = 3 reveals that the embedding dimensionalities of corresponding sub-manifolds are two and three, respectively.4.4.A fish school.Finally, we use a video of a fish school having few phase transitions to validate the method.This school is stimulated with panics and the behavior is recorded.
We execute the phase transition detection algorithm on the data matrix with α = 6 and obtain the distribution of (σ 6 /σ 1 ) n (Fig. 8(a)).The plot of phase changes (Fig. 8(c   5. Conclusions and discussion.In this study, we proposed a robust method to detect phase transitions in collective behavior using ratio of singular values encountering high curvature of the corresponding underlying manifold.We empirically observe that a phase transition in collective behavior is represented as a locus of singularities on the manifold where the curvature is significantly high.Thus, we first introduced an assertion to approximate the curvature of a curve by means of singular value ratios computed on it and then we extended the assertion to higher dimensions using the shape operator.Finally, we asserted that the same phase transition can also be detected through singular value ratios computed over the local data distribution on the manifold.We validated the method through four diverse examples; one from a simulation of the Vicsek model [42] containing three phase transitions, and the other three from natural instances of a crowd of people, a flock of birds, and a school of fish.We ran the phase transition detection algorithm on each data set with a predetermined nearest neighbor parameter (α).Algorithm outputs the distribution (σ α /σ 1 ) and 20 largest phase changes which are ranked according their magnitudes.Based on these outputs, manifold representing the whole collective behavior is partitioned into phase transitions free sub-manifolds.
In Example 4.1, we simulated a training data set of a particle swam consisting known phase transitions to test the method's performance.Noteworthy shifts of the distribution (σ 4 /σ 1 ) n from one frame to the other justify the sensitivity of the method.Therein, our method was capable of detecting the exact phase transitions at frames 50 and 150, however it approximated the phase transition at 100-th frame as at 99-th frame with one frame of error.Since this approximation is accurate enough, we partitioned the manifold into four sub-manifolds about frames 50, 99, and 150.Thus, we conclude that the method is adept at perceiving the nature of the collective behavior and spatial distribution of particles to approximate phase transitions.
The algorithm running on a fish school consisting four phase transitions (Ex.4.4) ranked their magnitudes such that it provides a good comparison between them.Embedding dimensionalities of sub-manifolds in each example revealed by isomap affirm that the data is embedded in distinct smooth sub-manifolds which are joined at singularities.Examples ensure the applicability of the method for variety of data sets ranging from simulations to natural, as it requires one input parameter α.
As we detect phase transitions based on the curvature which is a local property on the manifold, choosing the best value α is always important for the method to extract correct phase traditions.This is done by either using the prior-knowledge about the data or running the algorithm with several α's to determine the best value which differentiates and highlights phase transitions.We can always rely on a small α value when the data on the manifold is sufficiently dense [39].Since the current techniques of making videos with high frame rates, we can always generate sufficiently large quantity of frames those would then be densely represented as data points on a manifold.Thus, in this study, we run the phase transition detection algorithm with small α values taken to be all natural numbers less than 10 and then decide the best value by analyzing corresponding phase change plots.
In future, we will fabricate an automated method to determine the best α value which will give the best phase change plot to extract phase transitions.We will also establish a novel approach of detecting phase transitions under gradual changes of the behavior of a multi-agent system which is not addressed in this work.
Here we presented a phase transitions detection method of multi-agent systems usin g the curvature of the manifold representing the system.The method was validated on several instances ranging from simulation to natural to justify the broad applicability and the accuracy.

Figure 1 .
Figure 1.An abrupt phase change of the crowd behavior where a walking crowd suddenly starts running [2].(a) The first phase of the motion (walking) is embedded onto the blue colored manifold, while the second phase (running) is embedded onto the red colored manifold.Two snapshots showing walking and running at time steps t 1 and t 2 are embedded onto points p (t1) and p (t2) , respectively, in the corresponding manifolds.The locus of singularities (L) is represented by orange color.(b) The scaled residual variance with respect to the dimensionality, which the dimensionality of the underlying manifold is given by an elbow, is obtained by running Isomap upon frames in each phase with 6 nearest neighbors.Embedding dimensionalities of sub-manifolds representing walking (blue circle) and running (red square) of the crowd are three and four respectively.

Figure 2 .
Figure 2. (a) Superimposing a neighborhood of the curve C at point p with an arc p 1 pp 2 which subtend an small angle of 2T at the origin of a translating circle.(b) Zoomed and rotated secular sector p 1 p 2 O, in (a) such that the blue arrow is horizontal.

Figure 3 .
Figure 3. Local distribution of data around the point p on a two dimensional manifold (M 2 ).Principal sections Π (1) p and Π (2) p with M 2 , respectively.Π (j) p 's with the manifold makes curves C (j) ∈ R m+1 such that each passes through the point p.
Figure 3 illustrates principal sections and curves made through that when m = 2.

3 Figure 4 .
Figure 4. (a) A three dimensional sombrero-hat of 2000 points consisting two sub-manifolds (blue and green) and locus of singularities (red) is intersected with the plane {β 1 î + β 2 k|β 1 , β 2 ∈ R} to produce (b) a curve in R 3 .(c) Isomap residual plots those show embedding dimensionalities by elbows reveal that the dimensionalities of two sub-manifolds are two while the dimensionality of the locus is three.has a high curvature at the red points.Isomap residual plots indicate different embedding dimensionalities at the locus than those of two sub-manifolds.

Figure 5 .
Figure 5. Detecting phase transitions in a swarm simulated using the Vicsek model with alternating noise levels.(a) The distribution of (σ 4 /σ 1 ) n versus frame numbers.Therein, the range of frames for each sub-manifold is represented by a left-right arrow and the frame number at each phase transition is represented by a red circle along with the frame number associated.(b) The plot of 20 largest phase changes including frame numbers of three phase transitions.(c) Isomap residual variance versus dimensionality of each sub-manifold.

Figure 6 (
b) shows that only the first phase transition having a magnitude of 0.23 is significant.The manifold representing the crowd is partitioned such that frames 1 − 69 represent one sub-manifold and frames 70 − 90 represent the other sub-manifold.The snapshots in Figure6(a) show the phases walking (left) and running (right) of the crowd.Isomap running on frames 1 − 69 and 70 − 90 with α = 3 reveals that the embedding dimensionalities of corresponding sub-manifolds are three and four, respectively.

Figure 6 .
Figure 6.Detecting a phase transition between phases of walking and running in a human crowd[3].(a) The distribution of (σ 3 ) n versus frame numbers.Therein, while the snapshots show instances of the crowd in each phase, left-right arrows and the red circle represent ranges of frames in each sub-manifold and the frame at the phase transition, respectively.(b) The plot of 20 largest phase changes representing the phase transition in red along with its frame number.
)) reveals that the first four phase changes located at frames 40, 112, 185 and 222 are phase transitions.Now, the manifold is partitioned into phase transition free sub-manifolds representing frames in ranges 1−40, 41−112, 113−185, 186−222 and 223−250 as shown by left-right arrows in Figure 8(a).According to Figure 8(b), the pair of snapshots at the 40-th frame exhibits a large global abrupt change since the school reacts to the panic together.However, by the evidence observed through Figure 8(b) and snapshots, the second and the third phase transitions are abrupt and local while the last is gradual and local.Isomap is run on all sub-manifolds with α = 6 and embedding dimensionalities are obtained as two, four, three, two, and six, respectively.

Figure 7 .
Figure 7. Detecting a transition in a bird flock between phases sitting and flying [1].(a) The distribution of (σ 3 /σ 1 ) n shows ranges of frames representing two sub-manifolds by left-right arrows and instances phases of the flock by snapshots.(b) The plot of 20 largest phase changes.The frame at the phase transition is represented by red in Figures (a) and (b).

Figure 8 .
Figure 8. Detecting phase transitions in a fish school.(a) The distribution of (σ 6 /σ 1 ) n with left-right arrows showing ranges of frames in sub-manifolds and red dots showing frames at phase transitions.(b) Snapshots of the school before (left) and after (right) each phase transition.(c) The plot of 20 largest phase changes consisting four phase transitions marked in red with their frame numbers.