complex_systems module

complex_systems.causal_complexity module

pyrocs.complex_systems.causal_complexity.causal_complexity(A: ndarray, directed: bool = False)

Causal complexity measures the underlying causal structure of a system by considering both the system’s intricacy as well as interconnectedness. The equation within the package follows the formulations from [NVL+23], who generate a non-normalized measure of causal complexity as a product of cyclomatic complexity and 1 + feedback density as follows:

\[C = M*(1+D) = (E - N + 2P) * (1+(E_{loop}+N_{loop})/(E+N)),\]

where \(C\) is the causal complexity, \(M\) is the cyclomatic complexity, and \(D\) is the feedback density. Cyclomatic complexity reflects the number of linearly independent paths within a system of interest and can be calculated using the number of edges (\(E\)), nodes (\(N\)), and connected components (\(P\)) [ECA+16]. In contrast, feedback density captures the fraction of edges (\(E_{loop}\)) and nodes (\(N_{loop}\)) that are involved in at least one feedback loop. As such, it reflects the potential for cyclic behaviors. Jointly, the measure of causal complexity reflects the number of paths through a system weighted to reflect those with feedback loops. Thus, systems with more feedback density will have higher values of causal complexity than those systems with lower feedback density.

Parameters:

A – array

Returns:

causal complexity of the graph

pyrocs.complex_systems.causal_complexity.cyclomatic_complexity(A: ndarray, directed: bool = False)

Cyclomatic complexity reflects the number of linearly independent paths within a system of interest and can be calculated using the number of edges (E), nodes (N), and connected components (P) [ECA+16]. The equation within the package follows the formulations from [NVL+23] as follows:

\[M = E - N + 2P,\]

where \(M\) is the cyclomatic complexity, \(E\) is the total number of edges, \(N\) is the total number of nodes, and \(P\) is the number of connected components. Generally, lower cyclomatic complexity values indicate that the content has fewer interconnections and thus, can be understood more linearly (relative to higher cyclomatic complexity values).

Parameters:

A – array

Returns:

cyclomatic complexity of the graph

pyrocs.complex_systems.causal_complexity.feedback_density(A: ndarray, directed: bool = False)

Feedback density captures the fraction of edges \((E_{loop})\) and nodes (\(N_{loop}\)) that are involved in at least one feedback loop. As such, it reflects the potential for cyclic behaviors. The equation within the package follows the formulations from [NVL+23] as follows:

\[D = (E_{loop}+N_{loop})/(E+N),\]

where D is the feedback density, \(E_{loop}\) is the fraction of edges, \(N_{loop}\) is the fraction of nodes, \(E\) is the total number of edges, and \(N\) is the total number of nodes. Feedback density values are normalized between 0 and 1, where 0 indicates that no feedback loops (i.e., paths that begin and end at the same node) are present in the system while 1 indicates all nodes and edges are included in one or more feedback loops.

Parameters:

A – array

Returns:

feedback density of the graph

complex_systems.fluctuation_complexity module

pyrocs.complex_systems.fluctuation_complexity.fluctuation_complexity(A: list, L: int = 1)

Fluctuating complexity extends the characterization of discrete entropy to consider the ordering of states, by measuring the variation of probability between adjacent events. Specifically, the fluctuating complexity measures the probability of an event immediately following another event by calculating the mean squared difference between the log(probability) of these events.

The equation within the package follows the formulation from [Par10] as follows:

\[C_F = - \sum_{i,j=1}^n p_{L,ij} \left(\log_2\frac{p_{L,i}}{p_{L,j}}\right) ^2\]

where \(C_F\) is the fluctuating complexity, \(p_{L,ij}\) refers to the probability of observing event j immediately following the word I in a series of length L, and \(p_{L,i}\) and \(p_{L,j}\) correspond to the respective frequencies of event \(i\) and \(j\) within the series.

Parameters:
  • A – Sequence of symbols

  • L – If > 1, groups symbols into short subsequences of length L.

Returns:

The Fluctuation Complexity of the sequence

complex_systems.grc module

pyrocs.complex_systems.grc.grc(A: ndarray, directed: bool)

Global reaching centrality (GRC) measures the level of hierarchy within a network based on flow. The equation within the package follows the formulations from [MVV12], who quantify GRC as the difference between the maximum and the average value of the local reach centralities of nodes within the network:

\[GRC = \frac{\sum [C_R^\max - C_R(i)]}{N-1},\]

where \(C_R\) is the local reach centrality that reflects the proportion of nodes that can be reached from a particular node \(i\) (\(C_R(i)\)) or reflects the maximum value of local reach centrality within the network (\(C_R^\max\)) and \(N\) is the number of nodes present within the network. \(GRC\) values can range from 0 to 1, with lower values indicating lower hierarchy and vice versa [LNV+19].

Parameters:
  • A – Square matrix of adjacencies in the network

  • directed (bool) – If true, assume A represents a directed graph (row -> column). If false, assume A represents an undirected graph.

Returns:

Global reaching centrality of the graph