{'fraction_non_alphanumeric': 0.04257916027339936, 'fraction_numerical': 0.010496582508020644, 'mean_word_length': 4.597696662112043, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Eigen-entropy measure to study phase separation in market behavior

One of the spectacular examples of a complex system is the financial market, which displays rich correlation structures among price returns of different assets. The eigenvalue decomposition of a correlation matrix into partial correlations - market, group and random modes, enables identification of dominant stocks or"influential leaders"and sectors or"communities". The correlation-based network of leaders and communities changes with time, especially during market events like crashes, bubbles, etc. Using a novel entropy measure - eigen-entropy, computed from the eigen-centralities (ranks) of different stocks in the correlation-network, we extract information about the"disorder"(or randomness) in the market and its modes. The relative-entropy measures computed for these modes enable us to construct a"phase space", where the different market events undergo"phase-separation"and display"order-disorder"transitions, as observed in critical phenomena in physics. We choose the US S&P-500 and Japanese Nikkei-225 financial markets, over a 32-year period, and study the evolution of the cross-correlation matrices computed over different short time-intervals or"epochs", and their corresponding eigen-entropies. We compare and contrast the empirical results against the numerical results for Wishart orthogonal ensemble (WOE), which has the maximum disorder (randomness) and hence, the highest eigen-entropy. This new methodology helps us to better understand market dynamics, and characterize the events in different phases as anomalies, bubbles, crashes, etc. This can be easily adapted and broadly applied to the studies of other complex systems such as in brain science or environment.


Introduction
A financial market is a spectacular example of a complex system that is generally composed of many constituents, which may be diverse in forms but largely interconnected, such that their strong inter-dependencies and emergent behavior change with time. Thus, it becomes almost impossible to describe the dynamics of the system through some simple mathematical equations, and so new tools and interdisciplinary approaches are needed [1][2][3][4][5][6][7][8][9] . An interesting representation of the financial market has been in the form of a correlation-based network [10][11][12][13] . This has given new and useful insights into the underlying patterns and mechanisms that drive the overall behavior of this seemingly unpredictable complex system. One can look at the cross-correlations between price return time series of various stocks in a particular time epoch and infer a temporal cross-section of the underlying network structure 14, 15 that evolves with time. There are multitudes of methods such as Minimum Spanning Trees, Planar Graphs, Asset Graphs to extract the network structure from the correlation matrices [16][17][18] .
In earlier studies, interesting correlation patterns and thereby network structures were observed as time evolved, especially during critical events such as market crashes, bubbles, etc. Recently, Pharasi et. al 19,20 confirmed that during a market crash all the stocks start behaving similarly and the whole market begins to act like a single huge cluster or community. In contrast, during a bubble period, a particular sector gets overpriced or over-performs, causing accentuation of disparities among the various sectors or communities. Thus, if one were able to monitor the evolution of this network structure continuously, one would be able to acquire useful insights that would help in developing better investment strategies and manage risk.
A very recent work 21 proposed an entropy measure called "structural entropy", as a numerical characterization of the network topology based on the cross-correlation matrix of a financial market at a particular time. This way of quantifying the community structures present in financial markets can be interpreted as a method to measure the "diversity". The structural entropy measure S varies with the change in the number of communities and its heterogeneity (see SI). To calculate the entropy one has to first get the communities in the correlation matrix based network using a community detection algorithm 22,23 , and look at the normalized sizes of the communities. Then one applies the information theory based entropy formula to compute the value of S. A major drawback of this method is that there is information loss and arbitrariness in the detection of the community

Methodology and Results
Our aim is to study the time evolution of the cross-correlation matrices for N stocks over different time-epochs (of size M), as traditionally analyzed in RMT or in the analysis of adaptive complex systems like financial markets 19,20,34,35 , and characterize the epochs as different "phases" in the space of eigen-entropies. Thus, we begin by constructing a equal-time cross-correlation matrix (see Methods) with elements: C i j (τ) = ( r i r j − r i r j )/σ i σ j , where i, j = 1, . . . , N and τ indicates the end date of the time-epoch of size M. We then study the evolution of the cross-correlation structures of return matrices C(τ) and the eigenmodes over different overlapping time-epochs, shifted by ∆ days. In this paper, we compute correlation matrices for the The evolution of the market structure is captured by the cross-correlation matrices C(τ). As mentioned in details in the Methods section, we define A = |C| 2 and use the characteristic equation |A − λ 1| = 0 to compute the eigenvalues {λ 1 ...λ N }; we denote the maximum eigenvalue as λ max and the eigenvector corresponding to the maximum eigenvalue as p, such that A p = λ max p. The normalized eigenvector has components: p = {p i }, that are known as eigen-centralities. Fig. 1 (C) shows the ranked (sorted) eigen-centralities {p i } of the normalized eigenvector corresponding to the maximum eigenvalue -anomalous (green circles), bubble (blue diamonds), crash (red triangles) and normal (grey stars) periods of the financial market. For any matrix, we can perform the eigenvalue decomposition (see Methods). Fig. 2 shows the eigenvalue decompositions of the correlation matrices, for (A) normal, (B) anomalous, (C) bubble, (D) crash periods of the financial market, corresponding to the frames in Fig. 1, and in addition (E) shows the results for a random matrix taken from a Wishart orthogonal Ensemble (WOE), where we have denoted the different matrices as: full correlation (C), market mode (C M ), group mode (C G ), random mode (C R ), group-random mode (C GR ) and displayed the results in Fig. 2 (Left to Right). The last column shows the results for the ranked eigen-centralities (p i ) of the different correlation modes: full (C in black curve), market mode (C M in turquoise curve) and group-random mode (C GR in grey curve). Interestingly, for a normal period, the three curves are distinct and there are hierarchies in ranks in all curves; for the market anomaly, all the three curves almost coincide; for the bubble period, the curves corresponding to the full and the group-random modes coincide while there is a strict hierarchy in the eigen-centralities of the market mode; for crash period, the curves corresponding to the full and the market modes coincide while there is a strict hierarchy in the eigen-centralities of the group-random mode; and for the WOE, once again the curves corresponding to the full and the group-random modes coincide while there is a strict hierarchy in the eigen-centralities of the market mode. This feature is then exploited in characterizing the anomalies, bubbles, crashes and normal periods in the market, with the help of the . The market structure changes as time evolves, which is captured by the cross-correlation matrices C(τ). We define A = |C| 2 and use the characteristic equation |A − λ 1| = 0 to compute the eigenvalues {λ 1 ...λ N }; we denote the maximum eigenvalue as λ max and the eigenvector corresponding to the maximum eigenvalue as p, such that A p = λ max p. The normalized eigenvector has components: p = {p i }, that are known as eigen-centralities. (C) The ranked (sorted) eigen-centralities {p i } of the normalized eigenvector corresponding to the maximum eigenvalue are plotted, for the anomalous (green circles), bubble (blue diamonds), crash (red triangles) and normal (grey stars) periods of the financial market.  corresponding entropy functions as explained below and displayed in Fig. 3 and Fig. 4. The eigen-entropies may be computed (see Methods) from the full correlation (C), market mode (C M ) and group-random mode (C GR ). Fig. 3 (A) and (C) show the evolution of market returns r(τ), mean market correlations µ(τ), and different eigen-entropies H(τ), H M (τ), and H GR (τ) (shown in different colors; see legend), for S&P-500 and Nikkei-225 markets, respectively. The vertical dashed lines correspond to some indicative dates for bubbles (blue) and crashes (red) (see Table 1). These eigen-entropies can then be used for the characterization of market events, such as bubbles and crashes. We used a rolling mean and rolling standard deviation (with a window size of 40 days), and computed the standardized values of eigen-entropies H Std , H Std M and H Std GR . Fig. 3 (B) and (D) show the 3D-plots of the standardized values of eigen-entropy (H Std ) corresponding to the full (along z-axis), eigen-entropy (H Std GR ) corresponding to the group-random (x-axis), and eigen-entropy (H Std M ) corresponding to the market mode (along y-axis), for S&P-500 and Nikkei-225 markets, respectively. The sequence of frames display the "order-disorder" transitions in case of bubble bursts (Dot-com in USA and JPN; shown in blue) and crashes (Lehman Brothers in USA and Fukushima in JPN; shown in red). Fig. 4 shows evolution of relative-entropies and "phase separation" for S&P-500 and Nikkei-225 markets. We compute the relative-entropies H − H M , H − H GR , and H M − H GR , starting from the eigen-entropies corresponding to the full correlation, market mode and group-random mode, respectively. We then use these new variables to characterize and identify the different market events as anomalies, bubbles, bubble bursts, crashes and normal periods. Fig. 4 (B) and (D) show the 2D-plots of the phase space using relative-entropies H − H M , and H − H GR , for S&P-500 and Nikkei-225 markets, respectively. As evident, the epochs (event frames) clearly undergo "phase separation" -segregate into different market events: anomalies (green), bubbles (light blue), bubble bursts (blue), crashes (red) and normal (grey). For the first time, we have been able to display such a phenomenon in the context of financial markets, which can be very significant. The characterized events (corresponding to Fig. 4 (B) and (D)) are then indicated as vertical lines in the time-evolution plots in Fig. 4 (A) and (C). Interestingly, we find that anomalies occur just around the major crashes. Similarly, there are intriguing patterns in the appearances of bubble formations and bubble bursts.
Once we are able to characterize the epochs (event frames) into different "phases", we can create the different ensembles of anomalies, bubbles, bubbles bursts, crashes and normal events. For each type of event, we find that eigen-centralities have distinct ranges of values and the sorted eigen-centrality curves have interesting features (hierarchies) in the eigenmodes. The eigen-entropies actually quantify these features appropriately. For the S&P-500 and Nikkei-225 markets, we compute the histograms of the eigen-centralities (p i ). Fig. 5 shows the histograms (for S&P-500 (Top) and Nikkei-225 (Bottom)) for all the characterized anomalies (green circles), bubbles (light blue diamonds), bubble bursts (blue squares), crashes (red triangles), normal events (grey stars), averaged over the respective ensembles, for the full/decomposed matrices. For comparison, we also plot the results for the WOE (black squares). This helps us understand what actually happens in the market, during these different types of events (phases) and what type of hierarchies exist within the stocks's eigen-centralities. This would shed new light into the understanding of formation of bubbles, development of bursts and crashes, etc.

Summary and discussions
In summary, we have proposed a novel entropy measure, eigen-entropy, which is based on the eigenvector centrality of the different stocks in a correlation-based network, that can be determined directly from the Pearson correlation matrix of return time series. The eigenvalue decomposition of a correlation matrix into partial correlations -market, group and random modes, enabled the identification of dominant stocks and sectors (communities). The correlation-based network of leaders and , group mode (C G ), random mode (C R ), group-random mode (C GR ) and the ranked eigen-centralities (p i ) of the different correlation modes: full (C in black curve), market mode (C M in turquoise curve) and group-random mode (C GR in grey curve). Interestingly, for a normal period, the three curves are distinct and there are hierarchies in ranks in all curves; for the market anomaly, all the three curves almost coincide; for the bubble period, the curves corresponding to the full and the group-random modes coincide while there is a strict hierarchy in the eigen-centralities of the market mode; for crash period, the curves corresponding to the full and the market modes coincide while there is a strict hierarchy in the eigen-centralities of the group-random mode; and for the WOE, once again the curves corresponding to the full and the group-random modes coincide while there is a strict hierarchy in the eigen-centralities of the market mode. This feature is then exploited in characterizing the market events into anomalies, bubbles, crashes, normal periods, etc. with the help of the corresponding entropy functions as in Fig. 3 and Fig. 4.

5/26
A B C D

8/26
communities changes with time, especially during market events like crashes, bubbles, etc. We have shown that the eigen-entropy is a simple yet robust prescription to quantify the disorder in a financial market. The methodology does not have any arbitrary thresholds. Further, the relative-entropy measures computed for these eigenmodes enabled us to construct a "phase space", where the different market events undergo "phase-separation" and display "orderdisorder" transitions. The crashes occupy the region in the phase space, where H − H M 0. During the crashes, the H and H M almost touch the maximum disorder, ln N (corresponding to the random WOE). The events like "Dotcom bubble bursting" appear in the H − H GR 0 axis. The events lying far away from the origin and axes are happening during bubble formation periods. The events lying close to the origin are like anomalies happening right before or right after major crashes. This type of phase-separation behavior in financial markets is being reported for the first time. We have laid a clear prescription in how to characterize the market events as anomalies, bubbles, crashes, etc. using the relative entropies. It is not well-understood how and when bubbles form and when they burst. Our proposed methodology help us to understand the market dynamics and find the time-ordering and appearances of the bubbles (formations or bursts) and crashes, separated by normal periods. We have studied the evolution of events around major crashes and bubbles (from historical records in SI). Of course, further studies are required.
We have studied two different markets USA S&P-500 and JPN Nikkei-225, across a period of 32 years. We have observed that market behavior changes radically after 2000 (USA) and 1990 (JPN) corroborating to the findings of our earlier work 19 , where we had found that the markets have "states" with different mean market correlations and market volatilities. These results are certainly of deep significance for the understanding of financial market behaviour and designing strateigies for risk management.

Data Description
We have used the adjusted closure price time series from the Yahoo finance database 36 , for two countries: United States of America (USA) S&P-500 index and Japan (JPN) Nikkei-225 index, for the period 02-01-1985 to 30-12-2016, and for the stocks as follows:  Table S2 and Table S3 in SI.
It may be noted that we have T = 7897 days data for the Nikkei-225 index whereas T = 7998 days data for stocks. So, we add zero return entries corresponding to the missing days in the time series of JPN index for the purpose of comparison, without affecting the results or conclusions.

Cross-correlation Matrix
Returns series are constructed as is the adjusted closure price of stock i on day τ, and ∆ is the shift in days. Instead of working with a long time series to determine the correlation matrix for N USA stocks, we work with a short time epoch of M days with a shift of ∆ days.
Then, the equal time Pearson correlation coefficients between stocks i and j is defined as C i j (τ) = ( r i r j − r i r j )/σ i σ j , where ... represents the expectation value computed over the time-epochs of size M and the day ending on τ, and σ k represents standard deviation of the k-th stock evaluated for the same time-epochs. We use C(τ) to denote the return correlation matrix for the time-epochs ending on day τ.

Eigen-centrality
Generally, for any given graph G := (N, E) with |N| nodes and |E| edges, let A = (a i, j ) be the adjacency matrix, such that a i, j = 1, if node i is linked to node j, and a i, j = 0 otherwise. The relative centrality, p i , score of node i can be defined as: is a set of the neighbors of node i and λ is a constant. With a small mathematical rearrangement, this can be written in vector notation as the eigenvector equation Ap = λ p.

9/26
In general, there may exist many different eigenvalues λ for which a non-zero eigenvector solution exists. We use the characteristic equation |A − λ 1| = 0 to compute the eigenvalues {λ 1 ...λ N }. However, the additional requirement that all the entries in the eigenvector be non-negative (p i ≥ 0) implies (by the Perron-Frobenius theorem) that only the maximum eigenvalue (λ max ) results in the desired centrality measure. The i th component of the related eigenvector then gives the relative eigen-centrality score of the node i in the network. However, the eigenvector is only defined up to a common factor, so only the ratios of the centralities of the nodes are well defined. To define an absolute score one must normalise the eigenvector, such that the sum over all nodes N is unity, i.e., ∑ N i=1 p i = 1. Furthermore, this can be generalized so that the entries in A can be any matrix with real numbers representing the connection strengths. For correlation matrices C(τ), in order to enforce the Perron-Frobenius theorem, we work with A = |C| n , where n is any positive integer (we have used n = 2 in the paper; other values are discussed in SI).

Eigenvalue decomposition of the empirical cross-correlation matrix
We have used the eigenvalue decomposition of the correlation matrices into market mode (C M ), the group modes (C G ) and the random modes (C R ) and a composite group and random modes C GR . From such a decomposition, it is also possible to reconstruct the correlation matrix as aggregates of the contributions of modes C M ,C G , & C R or C M & C GR as we show below.
In general, the correlation matrix of size N × N will have N eigenvalues, say {λ 1 , ...λ N } arranged in descending order of magnitude. Then the maximum eigenvalue λ 1 = λ max of the correlation matrix, corresponds to a market mode that reflects the aggregate dynamics of the market common across all stocks, and strongly correlated to the mean market correlation µ. The group modes capture the sectoral behavior of the market, which are next few eigenvalues subsequent to the largest eigenvalue of the correlation matrix. Remaining eigenvalues capture the random modes behavior of the market (see Fig. 2). By using the eigenvalue decomposition, we can thus filter the true correlations (coming from the signal) and the spurious correlations (coming from the random noise).
For this, we first decompose the aggregate correlation matrix as where λ i and e i are the eigenvalues and eigenvectors, respectively, of the correlation matrix C. An easy way of handling the reconstruction of the correlation matrix is to sort the eigenvalues in descending order, and then rearranging the eigenvectors in corresponding ranks. This allows one to decompose the matrix into three separate components, viz., market, group and random where N G is the number of eigenvalues that satisfy the constraint λ + ≤ λ G <λ 1 , with For empirical matrices, it is very difficult to determine the exact value of λ + and hence figure out N G , for which the eigenvectors from 2 to N G would describe the sectoral dynamics. Here, we choose N G = 20 arbitrarily for the correlation decomposition (Fig. 2), corresponding to the 20 largest eigenvalues after the largest one. In order to avoid the arbitrariness, we prefer the following decomposition: Eigen-entropy Following the tradition in information theory, we propose a new measure, the eigen-entropy H = − ∑ N i=1 p i ln p i , since all the normalised eigen-centralities are non-negative (p i ≥ 0) and ∑ N i=1 p i = 1, as explained above. The eigen-entropy may be described as kind of measure of disorder or the degree of randomness in the matrix A = |C| 2 ; higher the eigen-entropy, higher is the disorder in the matrix; the highest being in the case of WOE, where H ∼ ln N.
Thus, corresponding to A = |C M | 2 and A = |C GR | 2 , we have H M and H GR , respectively.

Supplementary information
We present the supplementary information to the methodology used in the paper, especially with respect to the variations of different parameters that affect the calculation and understanding of eigen-entropy H.
We also present some detailed analyses of benchmark comparisons with the Wishart Orthogonal Ensemble (WOE) and the critical events (bubbles and crashes) in USA and JPN. The table of major events (bubbles and crashes) is given in Table S1. The tables for the lists of stocks of USA and JPN are given in Table S2 and Table S3, respectively.
Finally, we also make a very brief comparison of the measures: eigen-entropy H that we propose in this paper, with the structural entropy S that was recently introduced by Almog et al. 21 .

Methodology Effects of the variation of the epoch size M and shift ∆
The continuous monitoring of the market can be done by dividing the total time series data into smaller epochs of size M. The corresponding correlation matrices generated from theses smaller epochs are used for calculating the eigen-entropy H. In Fig. S1, we investigate the effects of the variation of parameters, epoch size M and shift ∆.
We observe that either the increase in the epoch M or shift ∆ makes the time series plot of H more smooth (less fluctuations), and vice versa. The choice of these parameters are thus arbitrary to some extent, depending on the research questions and time scale we are interested.
Effect of the variation in the powers of correlation matrices |C| n Instead of taking the square of individual elements of the correlation matrix C, to make all the elements non-negative, we can also use the even powers or the odd powers of absolute values to accomplish the same. The effect of the same is shown in the Fig. S2. As observed the values of eigen-entropy H differ with the variation of the power n of correlation matrices. This is due to the fact that with the increase in power, the dissimilarities in the elements of the correlation matrix are amplified which will then in turn changes the centrality of the matrix. For very high powers the transformed correlation matrices will act like an adjacency matrix with very high values (close to 1s) and very low values (close to 0s).
It is also interesting to note that, depending on the problem, we can decide the range of correlations to focus on by adjusting the power of the elements of the correlation matrix. Fig. S3 (A) shows the plot of sorted eigen-centralities (p i ) against rank, computed from the normalized eigenvectors corresponding to the maximum eigenvalues for 1000 independent realizations of a Wishart orthogonal ensemble (WOE). Filled black squares represent the mean eigen-centralities computed from 1000 independent realizations of the WOE, that serves as a reference (the maximum disorder or randomness) in the market correlation with N = 194. Fig. S3 (B) shows the plot of the variation of eigen-entropy H as a function of system size (correlation matrix size) N, where each point represents a mean computed from 1000 independent realizations of an uncorrelated WOE. The theoretical curve (red dash) shows the variation ∼ ln N. Fig. S3 (C) shows the histograms of the eigen-centralities (p i ) for typical Anomaly (06/01/1988) (green circles), Bubble (01/09/2000) (blue diamonds), Crash (22/09/2011) (red triangles) and Normal (28/02/1985) (grey stars) and WOE (black squares).

Study of critical events (Crashes and Bubbles)
For the events listed in Table S1, we look at the frames around that particular event and see how it moves around in the phase space in Fig.S4 and Fig.S5.

Comparison with structural entropy S
Recently, the measure of structural entropy S was introduced for the extraction of information from a correlation-based network in the form of a single representative value 21,24 . The structural entropy depends on the communities of the network and quantifies the "structural diversity". One finds that evolution of structural entropy may provide information about extreme events in the financial market, e.g., crises, bubbles, etc. Following the prescription given in Almog et al. 21 , the structural entropy may be calculated from the normalized sizes of the "communities" detected in the market after applying a community detection algorithm 24 . The detected communities can be represented by a vector (σ ) of the length equal to the total number of stocks, whose i th component σ i denotes the community to which node i was assigned to. In general, σ can possess values ranging from 1 to M, where M is the total number of communities detected by the algorithm. From this, one can then calculate the probability vector (P) by normalizing the sizes of different communities as , where c i is the size of community i.
On this probability vector P, one can apply Shannon entropy formula to obtain an entropy measure, called the structural entropy, as: S ≡ − ∑ M i=1 P i log(P i ). In Fig. S6, we compare the eigen-entropy H measure with the structural entropy S using the community detection algorithm 24 , where they obtain a modularity matrix directly from a correlation matrix, by applying random matrix theory tools and separating out just the group mode. The advantage of this method is that a modularity matrix can be supplied directly to a community detection algorithm, without using any arbitrary threshold.
When one compares the two entropy measures, it is evident that the structural entropy is very sensitive to the community detection algorithm (different algorithms yield different community structures). Even the community detection algorithm 24 , which involves identifying the group mode from the correlation matrix is not easy because the boundary (determined by the eigenvalues of the correlation matrix) between the random mode and the group mode, is not distinct (and often arbitrary). In this way, our eigen-entropy measure has an advantage that it is uniquely determined and non-arbitrary (and also has less computational complexity). Also, during a market crash, the structural entropy S behaves differently from the eigen-entropy H, as the market starts behaving like a single (huge) super-community. So, during a crash S (measure of diversity) decreases in contrast to H (measure of disorder or randomness) that increases.    Table S2. List of all stocks of USA market (S&P-500) considered for the analysis. The first column has the serial number, the second column has the abbreviation, the third column has the full name of the stock, and the fourth column specifies the sector as given in the S&P-500.  Table S3. List of all stocks of Japan market (Nikkei-225) considered for the analysis. The first column has the serial number, the second column has the abbreviation, the third column has the full name of the stock, and the fourth column specifies the sector as given in the Nikkei-225.