text:
Article | Open | Published:

# Fair Topologies: Community Structures and Network Hubs Drive Emergence of Fairness Norms

## Abstract

Fairness has long been argued to govern human behavior in a wide range of social, economic, and organizational activities. The sense of fairness, although universal, varies across different societies. In this study, using a computational model, we test the hypothesis that the topology of social interaction can causally explain some of the cross-societal variations in fairness norms. We show that two network parameters, namely, community structure, as measured by the modularity index, and network hubiness, represented by the skewness of degree distribution, have the most significant impact on emergence of collective fair behavior. These two parameters can explain much of the variations in fairness norms across societies and can also be linked to hypotheses suggested by earlier empirical studies in social and organizational sciences. We devised a multi-layered model that combines local agent interactions with social learning, thus enables both strategic behavior as well as diffusion of successful strategies. By applying multivariate statistics on the results, we obtain the relation between network structural features and the collective fair behavior.

## Introduction

Human’s deep presuppositions of fairness and inequality are proven in a wide range of contexts, such as the relationship between relative income and reported job satisfaction1, happiness2, health and longevity3, and reward-related brain activity4. These attitudes towards fairness play an important role in governing human behavior in social, economic, and organizational activities5,6,7. Earlier studies on fairness norms that were largely restricted to industrial societies showed relatively small fairness variation among different populations, suggesting that fairness norms were mostly the result of universal behavior patterns. This was later challenged by the seminal work of Henrich et al.8 and a number of other studies that show significant variations in fairness attitudes across different societies9, 10 and organizations11,12,13. These studies hypothesize the role of certain social and institutional factors on the scale and intensity of fairness norms8, 14,15,16. However, a systematic explanation of variation in fairness norms across different human societies has remained an open question that motivates our paper. Here, we hypothesize that the overall structure of social interactions, as captured by the network topology, can causally influence fairness norms and can also be linked to the hypothesized factors that have been suggested by earlier empirical studies. We take a computational approach to investigate the role of macro-level structural features of social networks in explaining the inter-societal variation of fairness norms.

The variations of fairness across societies have been largely attributed to cultural differences, yet interpretations have been mixed16,17,18. Cross-country results of experimental studies using canonical economic games under different conditions of the balance of power between two parties suggest that difference in the national culture results in differing beliefs about fairness19. Studies that attempted to attribute variations of these beliefs to country-level cultural variables 20, 21 show a relationship between the behavior of individuals and the scale of respect for authority 15. Moreover, recent experimental studies tentatively suggest religion as one of the influential factors affecting individuals’ fair behavior22. As a canonical paradigm to investigate fairness, the majority of these studies use the Ultimatum Game.

The Ultimatum Game (UG hereafter) has been the bedrock of a large number of studies that investigate the systematic deviation of human altruistic behavior from theoretical models that are based on the homo economicus assumption6, 23, 24. In the UG, two players are supposed to decide about sharing a fixed amount of money; one player acts as the Proposer and the other plays the role of the Responder. The proposer offers a split of the amount and the responder accepts or rejects. No bargaining is allowed. If the responder accepts, both players receive their amount based on the split; otherwise neither player receives anything. A rational responder, seeking to maximize her utility, would accept even the smallest positive offer. Being aware of the rationality of his partner, a rational proposer would therefore claim almost the entire amount. However, the results of a large number of experimental studies using the UG contradict with the prediction of pure rational models; most proposers offer a fair share and most responders reject low (but nonzero) offers25,26,27. The division of the money in the UG represents a measure for fairness norms.

Experimental studies based on the Ultimatum Game have reported significant cross-societal variations in average size of the offers by the proposers and the rejection rates by the responders. Table 1 shows the results of a number of key empirical studies of variation of fairness norms across different societies together with attributed institutional factors. The variation has particularly been bolder when experiments are conducted in non-industrial societies. In8 for example, the UG was played in 15 small-scale societies; the mean offer varied between 0.26 to 0.58 (as a proportion) and the rejection rate for low offers (offers of 0.2 or less) had a range between 0 to 0.8. Later studies conducted in other non-industrial societies have shown comparable large variations14. What social and institutional factors cause such variations? One potential key determinant is the macro-level structure of social networks. Experimental studies have previously shown that network structure of social interaction has a significant impact on evolution of collective behavior related to cooperation and competition28, inequality29, and exploration/exploitation30. Moreover, empirical studies based on experimental UG suggest factors that can be related to social structure. A series of studies that explored the motivation for fairness in anonymous interactions across dramatically diverse population show that fairness co-varies with Payoffs to Cooperation (PC) and Market Integration (MI) where PC represents the size of a group’s payoff from cooperation in economic production, and MI represents how much people rely on market exchange in their daily lives as opposed to rely on home-grown or hunted8.

To explain network topology parameters that affect fairness norms and their cross-society variations, we devised a multi-layered computational model that combines local agent interactions with social learning, thus enables both strategic behavior as well as diffusion of successful strategies. At the heart of this model, agents interact according to a one-shot UG, and update their strategies based on an evolutionary process. The behavior of agents is simulated on a wide range of carefully selected networks that generate variations of structural features and multivariate statistics is used to identify the relation between average strategies of agents at the equilibrium and the network’s structural features.

Our model offers two main contributions: (1) It indicates a causal relationship between changes of structural characteristics of social network and variation of fairness norms. (2) It identifies structural features that are aligned with the findings of empirical studies of inter-societal variations of fairness norms and sheds some light on role of social structure as one of key determinants in explaining the variation of fairness across societies. Concurring with previous computational studies31, 32, the results of our study show that structures that are close to all-inclusive interactions (full-graph) exhibit less fairness. Our study, however, identifies two other structural drivers that have been missing in the literature: community structure, represented by network modularity index, and network hubiness, represented by skewness of degree distribution of the network. The latter two network parameters also help to further clarify some of the empirical findings that relate social institution parameters to fairness norms.

## Results

To study the effect of structure on agents’ strategies playing the UG, we developed a computational agent-based model based on evolutionary game theory on networks33. Each agent has a strategy vector containing the offer value and the acceptance threshold, each varies between 0 and 1; where higher values represent stronger fairness norms. In each evolutionary round, agents interact based on a pairwise UG while using the same strategy vector against all partners and collect payoffs (Equation 1). Once all agents have completed one round of the UG with all their partners, game scores are calculated (Equation 2).

An evolutionary process based on the agents’ game scores (Equation 3) represents learning and strategy adoption by agents. That is, agents stochastically adopt the strategy of their neighbors with higher game scores where the probability of adoption is an increasing function of the difference between the two agents’ scores. The evolutionary process represents cultural evolution through social learning but it can also represent genetic evolution, both of which have been linked to the emergence of fairness in the UG34. In the context of cultural evolution, an individual tends to imitate the strategy of another individual with a higher payoff and mutation denotes either exploring a new strategy or incorrectly imitating the strategies used by other individuals. In the context of genetic evolution, individuals are born and die, and mutation creates variation into the gene pool.

The interaction structure of agents is determined by the topology of the network where agents are represented as nodes and only interact with their immediate neighbors in the network. To make simulations computationally efficient, we sparsed the search space of network structures based on key structural features that represent characteristics of social structure (see Supplementary Information for details). The structural features that we selected for this study are network average degree, girth and average shortest path that represent compactness of the society, and transitivity that represents dyadic closures in the population. We use the network modularity index to measure the strength of community structure. Modularity is an emergent structural feature of many evolving networks35 and has also been found to have a significant impact on the emergence of prosocial behavior36, 37. To capture the role of hierarchy and relative power structure, we measure the degree of hubiness of the network calculated based on the degree distribution. Hubiness is a structural feature of a wide range of real networks, such as co-authorship networks38, the World Wide Web39, and the dependency network of natural languages 40, 41, that are formed through the mechanisms of growth and preferential attachment where new nodes prefer to link to the more connected nodes42, 43. Huby structures are argued to result in economic efficiency for a certain range of network parameters44. In such network structures, the higher tendency to link to highly connected nodes results in higher skewness of degree distribution since several nodes are directly connected to a few central nodes (hubs). By changing the parameters of network models including Barabási-Albert Scale-Free39, Watts-Strogatz Small-World45, Erdős-Rényi Random graph46, Tree, and Lattice, we generated 26 network structures that sufficiently cover variations of the structural features (Methods).

In each simulation run, agents’ strategies (i.e., offer value and acceptance threshold) are initialized from a uniform distribution. Agents continue interactions in the network environment (i.e., play the UG and update strategies) until their strategies stabilize for a consecutive window of time. For each network structure, we averaged over strategies at the equilibrium for 1024 initializations, for which average strategy remains robust (see Supplementary Information Section 3). The simulation took approximately 40 minutes for all network structures on a 256-core cluster. The results of the simulation were aggregated in a data table, in which rows represent network structures and columns represent structural features as well as the average values of strategies at the equilibrium (see Supplementary Information Section 4).

In order to find the key structural features that drive fairness in the population of agents, we used Principal Component Analysis (PCA) on the simulation data37. PCA helps us to represent the variations of structural features and strategy vectors based on fewer number of linearly uncorrelated components and determine variations of which variables are related. The variables in the PCA include network characteristics (i.e., average degree, average path length, transitivity, modularity, and hubiness) and average strategy vector (i.e., $$\tilde{p}$$: average offer and $$\tilde{q}$$: average acceptance threshold) of all runs for a network at the equilibrium. We used modularity index, a scalar value that represents the number of links within communities compared to links between communities47, as a measure for community structure. We used the heuristic method in48 for calculating the modularity of network structures. To measure hubiness of the structures, represented by the lack of symmetry in the degree distribution, we used the coefficient of skewness from49 (Methods).

Figure 1 shows the results of the PCA on the correlation matrix constructed from the simulation data. We used the first two components that cumulatively account for 80% of the total variance in the whole data set. Figure 1b shows the biplot for the first two components and their correlations with network characteristics and average strategies at the equilibrium. In the biplot, average offer has an opposite direction to the average degree and is approximately orthogonal to the average path length and girth. However, the average offer value is more aligned with modularity and hubiness, suggesting a significant effect of these two structural features. The correlations between network structural features together with average strategies and principal components are provided in Fig. 1a. Average offer is significantly loaded on PC1 and PC2 while modularity is only highly loaded on PC1 and hubiness is highly loaded on PC2. Average degree is negatively loaded on PC1.

Panel (a) in Fig. 2 shows the level of fairness, measured by average offer value, versus skewness of degree distribution (hubiness). The lowest level of fairness belongs to the Full and Erdös-Rényi networks, and the highest is attributed to Tree structures. The results show that an increase in hubiness led to higher fairness. Variation of hubiness is mainly generated by varying the power of preferential attachment in the Barabási-Albert scale free and the number of children in Tree networks (Supplementary Information Section 1). However, average offers are higher in Tree structures than those in the Barabási-Albert networks. Not only do tree structures have skewed degree distribution but they also have stronger community structure. The rest of the networks with lower hubiness are located along the y-axis; however, the level of fairness varies among these structures. This indicates that hubiness is not the only structural feature affecting the level of fairness. Panel (b) in Fig. 2 depicts the level of fairness versus modularity index and shows that an increase in network modularity results in an increase in the level of fairness. Variation of modularity index has been generated by different lattice structures and Watts-Strogatz network model, in which modularity index varies by changing the probability of rewiring (Supplementary Information Section 1). These structures have similar hubiness and are located along the y-axis in Panel (a). The difference of modularity index and the level of fairness between Tree structures and the Barabási-Albert networks are evident in Panel (b) i.e., Barabási-Albert and Tree structures do not have much variation in modularity index, yet Tree structures have stronger community and exhibit higher level of fairness.

To find out how the role of structure in evolution of fairness can be affected by other factors, we investigated two other conditions. (1) Since it is less likely that individuals offer/request more than half of the pie, we eliminated large values for initial strategies and used uniform distribution U(0, 0.5) instead of U(0, 1) for initialization. Figure 3a shows that the effect of hubiness has been eliminated and the average offer value is completely aligned with modularity as a result of initializing the strategies from U(0, 0.5). (2) We considered the case where agents do not have information about their partners’ degree and used accumulated payoff (without normalizing by the agents’ degree) in the strategy adoption process. Figure 3b shows that the effect of hubiness is amplified and average offer value is highly correlated with hubiness when accumulated payoff is used as the game score. Under this condition, our simulation results show higher fairness for all network structures used in this study comparing to the case where normalized accumulated payoff by degree is used as the game score.

## Discussion

Our results identify three key structural features of social networks to explain the variation of fairness across different populations: average degree, community structure, and hubiness. Average degree of a network with a fixed number of nodes represents the density of interactions among a population. The results of our model show that populations with a large number of social interactions per individual exhibit lower levels of fairness. This is consistent with previous findings31, 32, 50 and is due to the fact that the increase in the density of social interactions leads to a well-mixed population and weakens the effect of structure, thus reduces overall level of fairness.

The intuition behind the role of community structure, captured by network modularity, in variations of fairness is as follows. When the interaction between agents follows a network structure, the success of a strategy S 1 invading a population with strategy S 2 not only depends on the payoff that is obtained from the encounter with the vast majority (i.e., E{S 2, S 1} and E{S 1, S 2}) but also on local interactions of the invaders (i.e., E{S 2, S 2} and E{S 1, S 2})31. When initial strategies are randomly distributed, a subset of agents will have a fair strategy. A strong community structure would help formation of clusters around agents with similar fair strategies and increases the chance of the fair strategy to take over the population. This concurs with an earlier study that investigates the level of fairness in a range of networks sorted according to a measure of order that shows that the level of fairness decreases as the community structure weakens51.

Another structural feature that promote fairness in our model is hubiness, which is measured by the skewness of degree distribution. Prior studies have shown the significant role of huby structures (structures dynamically generated through the mechanisms of growth and preferential attachment) in the evolutionary dynamics of formation of social norms52,53,54. Our results suggest societies in which few individuals play the role of hubs, which are connected to large number of low-degree individuals, exhibit higher levels of fair behavior in the UG. The intuition is similar to how average degree affects fairness, as explained earlier. Given that higher number of interactions decreases fairness (as the structure becomes closer to a well-mixed population), for a fixed average degree, the structure in which degree of a larger number of nodes is smaller exhibit a higher fairness. That is, the connections are shifted from a majority of nodes to a few hubs while total average degree is constant which results in skewed degree distribution.

Additionally, our model shows that the magnitude of impact for structural drivers of fairness is in general a function of agents’ initial strategies and the information available to individual agents. Our model shows that the rule of hubiness can be degraded when initial values of offers and acceptance thresholds are not larger than half of the pie. We also show that agents’ lack of information about the number of social ties of their neighbors can increase the impact of hubiness. The higher impact of hubiness under this condition is due to the intensified role of hubs in promoting fair strategies. In the evolutionary process of strategy adoption, the strategy of hubs is more likely to be copied by other agents since hubs collect higher game scores due to having large number of interactions (without considering the agent degree in the game score). Since a subset of hubs are initialized randomly to play fair, their strategies are copied even more aggressively by their neighbors, compared to the case when game score is normalized by degree. Further studies can incorporate various conditions of information uncertainty, such as neighbors’ payoffs and neighbors’ local structure, as well as the level of information access (global vs. local) into the model. This can provide insights about how the level of information access in a social network can affect collective fair behavior.

Empirical data that directly supports the effect of social network structure on fairness is often difficult to gather. On the one hand, isolating the effect of social structure from other factors in field experiments is often hard. On the other hand, lab experiments that simultaneously accommodate sufficiently large number of subjects on various network structures is challenging. Despite these limitations, we can attribute some of the factors that are empirically hypothesized to explain fairness in cross-country and cross-organization to social network parameters. Here, we first compare our findings to the results of two empirical studies that demonstrate significant cross societal differences in playing the UG. The first one is a series of papers8, 22 led by Henrich based on playing a number of fairness related games, including the UG, in 15 diverse small-scale societies that suggest that societies in which the size of a group’s payoff from cooperation in economic production (Payoffs to Cooperation) is higher, and those in which people rely on the market for their daily life (Market Integration) have higher levels of fairness. The second study14 is based on results of playing the UG in two multi-village Tanzanian ethnic groups (Pimbwe and Sukuma) which are embedded in similar environments and political systems, yet have drastically different social institutions. The significantly higher levels of fairness among Sukuma members are attributed to two important institutional factors between the two groups: Firstly, unlike Pimbwe whose loosely linked clans are controlled by a single chief in a central village, the Sukuma (the original inhabitants of the area) live in multiple chiefdom system with a high level of cooperation among chiefdoms. Secondly, Pimbwe has smaller scale cooperative units, mostly limited to family and friends within each village, whereas in Sukuma there are larger scale cooperative units at the village level that go beyond family boundaries. The average within-village (between village) offers in the UG for the Sukuma is reported 42% (4 times) higher than the Pimbwe.

Our results are in agreement with key hypotheses of these empirical findings. The determining role of Payoffs to Cooperation in the Henrich’s study and the impact of the scale of cooperative units on fairness in ethnic groups in the Tanzania study can be explained by the significant role of network modularity in increasing fairness norms. That is, in a society with a stronger community structure, there are more interactions within each group as opposed to between groups, hence people are more likely to be involved in group cooperation for an economic production. The role of Market Integration in the first study and governance structure (single chiefdom versus multiple interacting chiefdoms) can further be supported by our result which points to the impact of network hubiness on fairness norms. Clearly, the multi-chiefdom governance of the Sukuma suggests a social structure with higher level of hubiness compared to Pimbwe. We also expect societies with high market integration to include entities with which a large number of people have social interactions (as opposed to relying on home-grown products which results in a flat structure).

Additionally, cross-organizational studies of fairness suggest structural parameters that are related to hubiness. Cross-organizational study of fairness shows that the more connections there are from employees to managers, the higher the perception to fairness is13. In organizations with such structure, managers play the role of the hub and the more connections to the hub results in a more skewed distribution of number of interactions of individuals. Another study that investigates fairness across organizations shows that for a given number of workers, the lower the organization complexity (defined by the number of levels of hierarchy), the higher the perception of fairness is11. That is, for a fixed number of individuals, the decrease in the number of organizational levels results in having few individuals with a larger number of interactions and a more skewed degree distribution in the network of social interactions.

Our model determines structural features whose variations cause changes in the collective fair behavior. However, even the most similar results from empirical studies imply that fairness co-varies with the structural changes of social network. A future direction is to experimentally evaluate the causality between structural features of social network and variations of fairness, and create setups comparing similar societies side by side where the only difference is the connectivity structure of individuals’ social interactions. In order to overcome common hurdles of running such experiments in physical labs (e.g., recruiting large number of subjects), one can use the online labor market as subject pool55. Finally, results of this work can help with future directions of empirical research in fairness norms: So far, the variations in fairness norms have been mostly observed in non-industrial societies with drastically different institutional structures. Our results can be used to design better cross-societal studies within industrial countries by targeting sub-groups whose social interactions vary according to the findings of this research.

## Methods

### Model

Since the focus of our investigation is on the effect of interaction structure, we do not model additional mechanisms such as reputation56, empathy57, and spite58 that have been used in previous computational UG models. We modeled the UG on graphs31, 50, 51, 59,60,61 and employed a computational agent-based framework consisting of four levels37: game (behavioral), strategy, evolution, and network. At the behavioral level, we use a one-shot pairwise UG62 and without loss of generality we assumed the amount to be divided is one unit. The strategy of each agent i {1, …, N} is characterized by s i  = (p i , q i ), where p i  [0, 1] is the amount that i offers when she acts as the proposer and q i  [0, 1] is the acceptance threshold when she plays the role of the responder. In each generation, every agent i plays the UG with all agents j in her neighborhood with a fixed strategy and equal probability of being the proposer or the responder i.e., in each interaction between two given agents, one of the agents is randomly and with equal chance selected as the proposer and the other agent is assigned as the responder (in some alternative models the chance of being the proposer/responder can be a function of the agent’s degree or the outcome of its previous interactions63). The payoff of an agent i in interaction with agent j is calculated according to Equation 1. We considered two conditions for the game score: (1) total accumulated payoff of each agent i is used as the game score, $${{\rm{\Pi }}}_{i}^{T}$$, (2) For each agent i the accumulated payoff is normalized by the agent’s degree (k i ) in the network and is used as the game score, $${{\rm{\Pi }}}_{i}^{{k}_{i}}$$ (Equation 2).

$${{\rm{\Pi }}}_{i\leftarrow j}=\{\begin{array}{cc}1-{p}_{i} & {\rm{if}}\,i\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{proposer}}\,(j\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{responder}})\,{\rm{and}}\,{p}_{i}\ge {q}_{j}\\ 0 & {\rm{if}}\,i\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{proposer}}\,(j\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{responder}})\,{\rm{and}}\,{p}_{i} < {q}_{j}\\ {p}_{j} & {\rm{if}}\,j\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{proposer}}\,(i\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{responder}})\,{\rm{and}}\,{p}_{j}\ge {q}_{i}\\ 0 & {\rm{if}}\,j\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{proposer}}\,(i\,{\rm{acts}}\,{\rm{as}}\,{\rm{the}}\,{\rm{responder}})\,{\rm{and}}\,{p}_{j} < {q}_{i}\end{array}$$
(1)
$$\begin{array}{c}{{\rm{\Pi }}}_{i}^{T}=\sum _{j\in N(i)}{{\rm{\Pi }}}_{i\leftarrow j}\\ {{\rm{\Pi }}}_{i}^{{k}_{i}}=\frac{1}{{k}_{i}}\sum _{j\in N(i)}{{\rm{\Pi }}}_{i\leftarrow j}\end{array}$$
(2)

Agents’ strategies evolve based on a social learning rule. The implicit assumption of this model is the ability of the agents to assess and learn from their peers—as opposed to adaptive models, in which agents learn from their previous interactions64. The evolutionary strategy update process is as follows. Every agent i randomly selects an agent j in the neighborhood, if the score of j is greater than the score of i then i adopts the strategy of j with a probability W(s i  → s j ). The probability of the strategy adoption is given by the Fermi rule in equation 3 in which β is the selection intensity.

$$W({s}_{i}\to {s}_{j})={[1+exp(\beta ({{\rm{\Pi }}}_{i}-{{\rm{\Pi }}}_{j}))]}^{-1}$$
(3)

In order to account for innovation in each strategy update, a small perturbation is introduced in the value of the strategy vector. That is, if agent i adopts the strategy of j then (p i , q i ) = (p j  + δ 1, q j  + δ 2) with δ 1 and δ 2 being randomly and independently picked from a small interval [−δ, δ]. Once the strategy update is completed, payoffs are reset to zero for the next evolutionary round.

### Network generation

Finding a set of networks that represent the interaction structure between agents in our model is challenging as they should balance the trade-off between generating the variation of structural features and the computational efficiency. We carefully selected 26 structures by changing the parameters of network formation models to sufficiently capture variations of structural features in this study (see Supplementary Information Section 1 for details). The structures selected for this study are as follows. Four Barabási-Albert networks, four Watts-Strogatz networks, five Tree structures, four Erdős-Rényi networks, and four networks based on Watts-Strogatz model to generate required variation of average path length. The other network structures are a 2D-Lattice, 3D-Lattice, Circular Lattice, Ring, and a fully connected graph (see Supplementary Information - Figure S1). Additionally, we selected the size of the networks to keep the model computationally efficient while the effect of structure remains significant in the evolution of agent’s strategies (see Supplementary Information - Figure S3). The size of most networks used in this study is 100 nodes with two exceptions for circular lattice and 3D lattice which have 125 (5 × 5 × 5) nodes. We also verified that the results are not sensitive to the deviation of 100~125 nodes in the network size. We measured the skewness of degree distribution (g 1) for each network structure using $${g}_{1}=\frac{{m}_{3}}{{m}_{2}^{\mathrm{3/2}}}$$ where m 2 and m 3 are, respectively, the second and the third moments of the degree distribution. Larger values (in magnitude) of g 1 indicate more skewness in the distribution49. To measure the strength of the community structure (Q), we first used the algorithm suggested in48 to partition the network into communities of densely connected nodes, with the nodes belonging to different communities being only sparsely connected. Next, we measured modularity index using $$Q=\frac{1}{2m}\sum _{i,j}[{A}_{ij}-\frac{{k}_{i}{k}_{j}}{2m}]\delta ({c}_{i},{c}_{j})$$ where, for an unweighted graph, A ij represents an edge between i and j, k i is the degree of vertex i, c i is the community to which vertex i is assigned, function δ(u, v) is 1 if u = v and 0 otherwise, and m is the number of edges in the graph47.

### Numerical simulation

In each initialization, we populated the network with agents for each structure and draw a random value for p i and q i independently from a uniform distribution U(0, H) for each agent where H {0.5, 1}. Unlike similar computational models where the value at the equilibrium is calculated by averaging strategies over a certain number of generations after a transient stage with a fixed and large number of generations, we used an adaptive convergence criteria (see Supplementary Information Section 2 for details). In our model, the evolutionary process continued over a number of generations until no more than one agent updates its strategy for a consecutive window of 100 generations. To enhance convergence, we considered a noise threshold of ε = 0.05 for strategies below which agents do not adopt a new strategy. This approach (1) ensures that evolutionary process continues until strategies of all agents stabilize in the population and (2) is more computationally efficient as the number of generations for the convergence becomes a function of the network structure as well as the initialization. We determined the number of initializations so that the average value over all runs for each network structure is reasonably robust (see Supplementary Information Section 3 for details). We used 1024 initializations for each network structure and calculated the average value of strategies for each network. This ensures less than 1% variation in the average strategy at the equilibrium for our case. We used β = 0.1 for the selection intensity and δ = 0.005 for perturbation in strategy adoption. All runs converged for these simulation parameters across all network structures selected for this study. Although our simulation results suggest that the population becomes stable in a wide range of network structures, the analysis of the evolutionary dynamic of games on various structures is an open question65. Most of the models in the literature are based on the prisoner dilemma and do not consider structure66 or are limited to special structures67, 68. The analysis of the evolutionary dynamics of the UG and the stability of certain population states on networks with different structural features is an important future step of this research.

### Data Availability

https://dx.doi.org/10.6084/m9.figshare.4240031.v2

Publisher's note: Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## References

1. 1.

Clark, A. E. & Oswald, A. J. Satisfaction and comparison income. Journal of public economics 61, 359–381 (1996).

2. 2.

Luttmer, E. F. Neighbors as negatives: Relative earnings and well-being. Quarterly Journal of Economics 120, 963–1002 (2005).

3. 3.

Marmot, M. Status syndrome. Significance 1, 150–154 (2004).

4. 4.

Fliessbach, K. et al. Social comparison affects reward-related brain activity in the human ventral striatum. science 318, 1305–1308 (2007).

5. 5.

Kahneman, D., Knetsch, J. L. & Thaler, R. H. Fairness and the assumptions of economics. Journal of business S285–S300 (1986).

6. 6.

Thaler, R. H. Anomalies: The ultimatum game. The Journal of Economic Perspectives 2, 195–206 (1988).

7. 7.

Rabin, M. Incorporating fairness into game theory and economics. The American economic review 1281–1302 (1993).

8. 8.

Henrich, J. et al. In search of homo economicus: behavioral experiments in 15 small-scale societies. The American Economic Review 91, 73–78 (2001).

9. 9.

Blake, P. et al. The ontogeny of fairness in seven societies. Nature (2015).

10. 10.

Lamba, S. & Mace, R. The evolution of fairness: explaining variation in bargaining behaviour. Proceedings of the Royal Society of London B: Biological Sciences 280, 20122028 (2013).

11. 11.

Schminke, M., Cropanzano, R. & Rupp, D. E. Organization structure and fairness perceptions: The moderating effects of organizational level. Organizational Behavior and Human Decision Processes 89, 881–905 (2002).

12. 12.

Schminke, M., Ambrose, M. L. & Cropanzano, R. S. The effect of organizational structure on perceptions of procedural fairness. Journal of Applied Psychology 85, 294 (2000).

13. 13.

Lamertz, K. The social construction of fairness: Social influence and sense making in organizations. Journal of Organizational Behavior 23, 19–37 (2002).

14. 14.

Paciotti, B. & Hadley, C. The ultimatum game in southwestern tanzania: Ethnic variation and institutional scope 1. Current Anthropology 44, 427–432 (2003).

15. 15.

Oosterbeek, H. & Sloof, R. & Van De Kuilen, G. Cultural differences in ultimatum game experiments: Evidence from a meta-analysis. Experimental Economics 7, 171–188 (2004).

16. 16.

Chuah, S.-H., Hoffmann, R., Jones, M. & Williams, G. Do cultures clash? evidence from cross-national ultimatum game experiments. Journal of Economic Behavior & Organization 64, 35–48 (2007).

17. 17.

Roth, A. E., Prasnikar, V., Okuno-Fujiwara, M. & Zamir, S. Bargaining and market behavior in jerusalem, ljubljana, pittsburgh, and tokyo: An experimental study. The American Economic Review 1068–1095 (1991).

18. 18.

Roth, A. E. Bargening experiments. In Kagel, J. H. & Roth, A. E. (eds.) The Handbook of Experimental Economics, The Handbook of Experimental Economics, chap. 4, 253–348 (snthoeunh, Princeton University Press, 1995).

19. 19.

Buchan, N. R., Croson, R. T. & Johnson, E. J. When do fair beliefs influence bargaining behavior? experimental bargaining in japan and the united states. Journal of Consumer Research 31, 181–190 (2004).

20. 20.

Inglehart, R. Culture and democracy. Culture matters: How values shape human progress 80–97 (2000).

21. 21.

Hofstede, G. Cultures and organizations: Software of the mind, vol. 1 (McGraw-Hill, New York, 1991).

22. 22.

Henrich, J. et al. Markets, religion, community size, and the evolution of fairness and punishment. science 327, 1480–1484 (2010).

23. 23.

van Damme, E. et al. How werner güth’s ultimatum game shaped our understanding of social behavior. Journal of economic behavior & organization 108, 292–318 (2014).

24. 24.

Skyrms, B. Evolution of the social contract (Cambridge University Press, 2014).

25. 25.

Henrich, J. et al. Costly punishment across human societies. Science 312, 1767–1770 (2006).

26. 26.

Güth, W. & Kocher, M. G. More than thirty years of ultimatum bargaining experiments: Motives, variations, and a survey of the recent literature. Journal of Economic Behavior & Organization 108, 396–409 (2014).

27. 27.

Straub, P. G. & Murnighan, J. K. An experimental investigation of ultimatum games: Information, fairness, expectations, and lowest acceptable offers. Journal of Economic Behavior & Organization 27, 345–364 (1995).

28. 28.

Rand, D. G., Nowak, M. A., Fowler, J. H. & Christakis, N. A. Static network structure can stabilize human cooperation. Proceedings of the National Academy of Sciences 111, 17093–17098 (2014).

29. 29.

Nishi, A., Shirado, H., Rand, D. G. & Christakis, N. A. Inequality and visibility of wealth in experimental social networks. Nature 526, 426–429 (2015).

30. 30.

Mason, W. & Watts, D. J. Collaborative learning in networks. Proceedings of the National Academy of Sciences 109, 764–769 (2012).

31. 31.

Page, K. M., Nowak, M. A. & Sigmund, K. The spatial ultimatum game. Proceedings of the Royal Society of London B: Biological Sciences 267, 2177–2182 (2000).

32. 32.

Killingback, T. & Studer, E. Spatial ultimatum games, collaborations and the evolution of fairness. Proceedings of the Royal Society of London B: Biological Sciences 268, 1797–1801 (2001).

33. 33.

Szabó, G. & Fath, G. Evolutionary games on graphs. Physics reports 446, 97–216 (2007).

34. 34.

Rand, D. G., Tarnita, C. E., Ohtsuki, H. & Nowak, M. A. Evolution of fairness in the one-shot anonymous ultimatum game. Proceedings of the National Academy of Sciences 110, 2581–2586 (2013).

35. 35.

Heydari, B. & Dalili, K. Emergence of modularity in system of systems: Complex networks in heterogeneous environments. IEEE Systems Journal 9, 223–231, doi:10.1109/JSYST.2013.2281694 (2015).

36. 36.

Gianetto, D. A. & Heydari, B. Sparse cliques trump scale-free networks in coordination and competition. Scientific reports 6, 21870 (2016).

37. 37.

Gianetto, D. A. & Heydari, B. Network modularity is essential for evolution of cooperation under uncertainty. Scientific reports 5 (2015).

38. 38.

Wagner, C. S. & Leydesdorff, L. Network structure, self-organization, and the growth of international collaboration in science. Research policy 34, 1608–1618 (2005).

39. 39.

Barabási, A.-L. & Albert, R. Emergence of scaling in random networks. science 286, 509–512 (1999).

40. 40.

Lu, Q., Xu, C. & Liu, H. Can chunking reduce syntactic complexity of natural languages? Complexity 21, 33–41 (2016).

41. 41.

Ferrer-i Cancho, R. Hubiness, length, crossings and their relationships in dependency trees. arXiv preprint arXiv:1304.4086 (2013).

42. 42.

Kunegis, J., Blattner, M. & Moser, C. Preferential attachment in online networks: Measurement and explanations. In Proceedings of the 5th Annual ACM Web Science Conference, 205–214 (ACM, 2013).

43. 43.

Barabási, A.-L. Network science (2016).

44. 44.

Heydari, B., Mosleh, M. & Dalili, K. Efficient network structures with separable heterogeneous connection costs. Economics Letters 134, 82–85 (2015).

45. 45.

Watts, D. J. & Strogatz, S. H. Collective dynamics of ‘small-world’ networks. nature 393, 440–442 (1998).

46. 46.

ERDdS, P. & R&WI, A. On random graphs i. Publ. Math. Debrecen 6, 290–297 (1959).

47. 47.

Newman, M. E. Modularity and community structure in networks. Proceedings of the national academy of sciences 103, 8577–8582 (2006).

48. 48.

Blondel, V. D., Guillaume, J.-L., Lambiotte, R. & Lefebvre, E. Fast unfolding of communities in large networks. Journal of statistical mechanics: theory and experiment 2008, P10008 (2008).

49. 49.

Zwillinger, D. & Kokoska, S. CRC standard probability and statistics tables and formulae (CRC Press, 1999).

50. 50.

Sinatra, R. et al. The ultimatum game in complex networks. Journal of Statistical Mechanics: Theory and Experiment 2009, P09012 (2009).

51. 51.

Kuperman, M. & Risau-Gusman, S. The effect of the topology on the spatial ultimatum game. The European Physical Journal B 62, 233–238 (2008).

52. 52.

Santos, F., Rodrigues, J. & Pacheco, J. Graph topology plays a determinant role in the evolution of cooperation. Proceedings of the Royal Society of London B: Biological Sciences 273, 51–55 (2006).

53. 53.

Santos, F. C. & Pacheco, J. M. Scale-free networks provide a unifying framework for the emergence of cooperation. Physical Review Letters 95, 098104 (2005).

54. 54.

Gómez-Gardenes, J., Campillo, M., Flora, L. & Moreno, Y. Dynamical organization of cooperation in complex topologies. Physical Review Letters 98, 108103 (2007).

55. 55.

Mason, W. & Suri, S. Conducting behavioral research on amazon’s mechanical turk. Behavior research methods 44, 1–23 (2012).

56. 56.

Nowak, M. A., Page, K. M. & Sigmund, K. Fairness versus reason in the ultimatum game. Science 289, 1773–1775 (2000).

57. 57.

Page, K. M. & Nowak, M. A. Empathy leads to fairness. Bulletin of mathematical biology 64, 1101–1116 (2002).

58. 58.

Forber, P. & Smead, R. The evolution of fairness through spite. Proceedings of the Royal Society of London B: Biological Sciences 281, 20132439 (2014).

59. 59.

Iranzo, J., Román, J. & Sánchez, A. The spatial ultimatum game revisited. Journal of theoretical biology 278, 1–10 (2011).

60. 60.

Szolnoki, A., Perc, M. & Szabó, G. Accuracy in strategy imitations promotes the evolution of fairness in the spatial ultimatum game. EPL (Europhysics Letters) 100, 28005 (2012).

61. 61.

Szolnoki, A., Perc, M. & Szabó, G. Defense mechanisms of empathetic players in the spatial ultimatum game. Physical review letters 109, 078701 (2012).

62. 62.

Güth, W., Schmittberger, R. & Schwarze, B. An experimental analysis of ultimatum bargaining. Journal of economic behavior & organization 3, 367–388 (1982).

63. 63.

Wu, T., Fu, F., Zhang, Y. & Wang, L. Adaptive role switching promotes fairness in networked ultimatum game. Scientific reports 3 (2013).

64. 64.

Duan, W.-Q. & Stanley, H. E. Fairness emergence from zero-intelligence agents. Physical Review E 81, 026104 (2010).

65. 65.

Allen, B. et al. Evolutionary dynamics on any population structure. Nature 21723, 1476–4687 (2017).

66. 66.

Harper, M. & Fryer, D. Stationary stability for evolutionary dynamics in finite populations. Entropy 18, 316 (2016).

67. 67.

Lieberman, E., Hauert, C. & Nowak, M. A. Evolutionary dynamics on graphs. Nature 433, 312–316 (2005).

68. 68.

Chen, Y.-T. et al. Sharp benefit-to-cost rules for the evolution of cooperation on regular graphs. The Annals of Applied Probability 23, 637–664 (2013).

## Acknowledgements

This work is in part supported by the National Science Foundation (NSF) under Grant No. CMMI-1548521. Authors are grateful to David Gianetto for the insightful comments on the computational framework.

## Author information

### Affiliations

1. #### School of Systems and Enterprises, Stevens Institute of Technology, Hoboken, NJ, 07030, USA

• Mohsen Mosleh
•  & Babak Heydari

### Contributions

B.H. and M.M. designed research, performed research, analyzed data, and wrote the paper.

### Competing Interests

The authors declare that they have no competing interests.

### Corresponding authors

Correspondence to Mohsen Mosleh or Babak Heydari.

## Electronic supplementary material

### DOI

https://doi.org/10.1038/s41598-017-01876-0

• ### Population Structure Promotes the Evolution of Intuitive Cooperation and Inhibits Deliberation

• Mohsen Mosleh
•  & David G. Rand

Scientific Reports (2018)

• Ran Xu


text:
## Remarks on a numerical method for unilateral contact including friction.(English)Zbl 0762.73076

Unilateral problems in structural analysis IV, Proc. 4th Meet., Capri/Italy 1989, ISNM 101, 129-144 (1991).
[For the entire collection see Zbl 0745.00040.]
We submit in this article a discretization by classical finite elements $$P_ 1$$ of the unilateral contact problem with Coulomb friction. Existence, as well as uniqueness when the value of the friction coefficient $$\mu$$ is small, has been obtained. A fixed point theorem is used to establish unicity for small $$\mu$$, therefore convergence of the successive approximation algorithm follows.

### MSC:

 74S05 Finite element methods applied to problems in solid mechanics 74A55 Theories of friction (tribology) 74M15 Contact in solid mechanics

Zbl 0745.00040

format: plain


text:
# What is health Ethics

###### Question:

What is health Ethics

### 2) Angle A is in the third quadrant with Tan A Determine the EXACT value of theother two trig ratios

2) Angle A is in the third quadrant with Tan A Determine the EXACT value of the other two trig ratios...

### HELP ASAP PLEASE!What is the output?if (x == 1):print ('ONE')else:print ('TWO')

HELP ASAP PLEASE! What is the output? if (x == 1): print ("ONE") else: print ("TWO")...

### Afree morpheme and a bound morpheme

Afree morpheme and a bound morpheme...

### Olivia likes to knit hats and mittens for friends and family. Last fall, she knitted 4 hats and 5 pairs of mittens, which took a total of 78 hours. This

Olivia likes to knit hats and mittens for friends and family. Last fall, she knitted 4 hats and 5 pairs of mittens, which took a total of 78 hours. This fall, she knitted 5 hats and 5 pairs of mittens, which took a total of 85 hours. If each hat and each pair of mittens takes the same amount of time...

### 30.075, 0.75%, 4 20. which of the following correctly orders the values above from least to greatest?

30.075, 0.75%, 4 20. which of the following correctly orders the values above from least to greatest?...

### How did russell means influence the corse of events for the rights of native americans

How did russell means influence the corse of events for the rights of native americans...

### Pls help ASAP i don’t have time

Pls help ASAP i don’t have time $Pls help ASAP i don’t have time$...

### Pls help cause I have a small brain lol

Pls help cause I have a small brain lol $Pls help cause I have a small brain lol$...

### The course project contains two parts. Part one involves designing and implementing login/logout and session controls for database

The course project contains two parts. Part one involves designing and implementing login/logout and session controls for database users on the Web. Part two involves designing and implementing a "Student Enrollment Information System" for these users. This enrollment system will allow a student to ...

### Nt Addition and Cogs truD13F.

Nt Addition and Cogs tru D 13 F....

### Aswimming pool contains 1000 gallons of water. 20 gallons is added every hour. the expression 1000 +

Aswimming pool contains 1000 gallons of water. 20 gallons is added every hour. the expression 1000 + 20h represents the number of gallons of water in the pool after a certain number of hours? a.3030gallons b.1010 gallons c.1600 gallons d.1020 gallons...

### The flow of energy through living systems can be modeled as food chains, food webs, or energy pyramids. The energy organisms

The flow of energy through living systems can be modeled as food chains, food webs, or energy pyramids. The energy organisms need to live and grow first enters the ecosystem when which of the following occurs? Plants take in light energy from the sun Decomposers break down dead organisms Primary con...

### What best describes the early presence in North America

What best describes the early presence in North America...

### How was a property colony governed in maryland

How was a property colony governed in maryland...

### Jack owns a local trucking company. with fuel costs being expensive, jack wants to evaluate how much

Jack owns a local trucking company. with fuel costs being expensive, jack wants to evaluate how much fuel, on average, he should store in his 9,000 gallon fuel tank. each year jack uses 90,000 gallons of diesel (usage is spread evenly throughout the year). jack knows with certainly that he can have ...

### Is achilles is suggesting they advance forward when he says, 'tis time to save the few remains of war'

Is achilles is suggesting they advance forward when he says, "tis time to save the few remains of war" (homer 9). correctly written?...

### Determine the number of x-intercepts that appear on a graph of each function.f)= (rt 1)(x-3)(x- 4)

Determine the number of x-intercepts that appear on a graph of each function. f)= (rt 1)(x-3)(x- 4)...

### My question is in the picture. i'd very much appreciatelol.

My question is in the picture. i'd very much appreciatelol. $My question is in the picture. i'd very much appreciatelol.$...


text:
# Proving that if one person in any group of four knows three, then someone knows everyone.

title can't exactly capture the description of this problem so well. Here's the question in full:

"At a convention, any group of four people contains one who knows the other three. Prove there is someone at the convention who knows everyone else."

I've tried to prove this inductively, but am not sure whether or not that is the correct way to go about it.

Induction Hypothesis: Assume that there is someone at the convention who knows everyone else, given that any group of four people contains one who knows the other three (assume this is true given $n$ people).

Basis case: there are four people at the convention. Therefore, there is one in this group of four who knows the other three (everyone else at the convention).

Induction step: Prove this is true for $n+1$ people. We see that this is the same as inserting one more person into a convention with $n$ people, where there must be someone who knows everyone. Therefore, we only need to show that this person who knows everyone also knows the $n+1$th person we're inserting. And I'm stuck.

If anyone could help me out here, that would be greatly appreciated. Thanks!

I will assume that knowing someone is symmetric, i.e. if person X knows Y then Y knows X.

Lets call the $n+1$-th person B. Before B joined someone must have known everyone at the convention, call her A. Now suppose that A doesn't know B and that the convention still has the property that in all groups of 4 there is someone who knows the others. Then we have to show that there is someone else at the convention who knows everyone else.

For any pair of people C and D that aren't A or B we know that either C or D must know all of the others in the group ABCD. In both cases C and D know each other. This shows that any person that isn't A or B knows all other people that aren't A or B. Now pick a specific pair of such people one of them must also know A and B and so he knows everyone at the convention!

• Thank you for the explanation! That makes the induction so much clearer here. – user176049 Oct 25 '14 at 19:39

This is a way to do it without induction.

Choose any person, say $A$. First, we claim that $A$ knows everyone, except possibly for $2$ people. Suppose that there are three people that $A$ does not know, say $B$, $C$, and $D$. Then the quadruple $\{A,B,C,D\}$ violates the given condition, so the number of people that $A$ does not know is at most $2$.

If $A$ knows everyone, then we are done. If $A$ does not know some person, then call this person $B$.Let $C$ and $D$ be two people other than $A$ or $B$. Then in the quadruple $\{A,B,C,D\}$, the person who knows everyone else in the quadruple cannot be $A$ or $B$, so it must either be $C$ of $D$; in particular, $C$ and $D$ always know each other. This tells us two things. First, since $C$ and $D$ were chosen arbitrarily, every pair of people, not including $A$ or $B$, knows each other. Second, one of $C$ or $D$ must know both $A$ and $B$. Therefore, one of $C$ or $D$ knows everyone.

Thus, we are done!

• Thank you for the explanation on another way to approach this problem! – user176049 Oct 25 '14 at 19:39


text:
New Titles  |  FAQ  |  Keep Informed  |  Review Cart  |  Contact Us Quick Search (Advanced Search ) Browse by Subject General Interest Logic & Foundations Number Theory Algebra & Algebraic Geometry Discrete Math & Combinatorics Analysis Differential Equations Geometry & Topology Probability & Statistics Applications Mathematical Physics Math Education

Combinatorial Floer Homology
Vin de Silva, Pomona College, Claremont, CA, Joel W. Robbin, University of Wisconsin, Madison, WI, and Dietmar A. Salamon, ETH Zurich, Switzerland
 SEARCH THIS BOOK:
Memoirs of the American Mathematical Society
2014; 114 pp; softcover
Volume: 230
ISBN-10: 0-8218-9886-8
ISBN-13: 978-0-8218-9886-4
List Price: US$75 Individual Members: US$45
Institutional Members: US\$60
Order Code: MEMO/230/1080

The authors define combinatorial Floer homology of a transverse pair of noncontractible nonisotopic embedded loops in an oriented $$2$$-manifold without boundary, prove that it is invariant under isotopy, and prove that it is isomorphic to the original Lagrangian Floer homology. Their proof uses a formula for the Viterbo-Maslov index for a smooth lune in a $$2$$-manifold.

• Introduction
Part I. The Viterbo-Maslov Index
• Chains and traces
• The Maslov index
• The simply connected case
• The Non simply connected case
Part II. Combinatorial Lunes
• Lunes and traces
• Arcs
• Combinatorial lunes
Part III. Floer Homology
• Combinatorial Floer homology
• Hearts
• Invariance under isotopy
• Lunes and holomorphic strips
• Further developments
Appendices
• Appendix A. The space of paths
• Appendix B. Diffeomorphisms of the half disc
• Appendix C. Homological algebra
• Appendix D. Asymptotic behavior of holomorphic strips
• Bibliography
• Index


text:
# Create multiple multirows in a table

I have currently a table with the below code and i want to get it in the form of the image ive posted below.

\begin{table}[ht]
\caption{####}\label{table:####}
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline
\multirow{2}{*}{A} &
\multicolumn{2}{c}{B} &
\multicolumn{2}{c}{C} &
\multicolumn{2}{c|}{D} \\
&
Modell& A& A& A& A& A\\
\hline
Modell& A& A& 11461   & A& A& A\\
\hline
Modell & A & A& A& A&  A&  A\\
\hline
Modell & A & A& A& A&  A&  A\\
\hline
Modell & A & A& A& A&  A&  A\\
\hline
\end{tabular}
\end{tab}

The image represents the anticipated endresult, i just need multiple multirows to resprent my data.

• Welcome to TeX SX! Your code does not correspond to the image, and I can't really understand what you try to obtain, and what you're missing. Jul 1, 2020 at 11:42
• @Bernard iam sry i edited my post! The image is the end result i want Jul 1, 2020 at 11:52
• You don't need to use \multirow  for this table. Just replace the relevant \hlines with \cline{2-7}. Jul 1, 2020 at 11:56
• I didnt managed it, what i did was to replace the hlines with clines but doesnt that just change the vertical lines into horizontal ones? Jul 1, 2020 at 12:27
• No, it makes horizontal lines start at the second column. B.t.w., you declare 7 columns and your image has 8 Jul 1, 2020 at 12:33

You can use \cline instead of \hline, to only cover the columns from the second one on.

However, caged tables are really ugly, so I also propose a different realization.

\documentclass{article}
\usepackage{booktabs} % for the second realization

\begin{document}

\begin{table}
\centering

\caption{A caged table}\label{caged}

\begin{tabular}{|l|l|c|c|c|c|c|c|}
\hline
Model   & A  & \multicolumn{2}{l|}{B} & \multicolumn{2}{l|}{C} & \multicolumn{2}{l|}{D} \\
\hline
Model 1 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
\cline{2-8}
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\cline{2-8}
& A3 & B3.1 & B3.2 & C3.1 & C3.2 & D3.1 & D3.2 \\
\cline{2-8}
& A4 & B4.1 & B4.2 & C4.1 & C4.2 & D4.1 & D4.2 \\
\hline
Model 2 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
\cline{2-8}
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\hline
Model 3 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
\cline{2-8}
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\hline
\end{tabular}

\end{table}

\begin{table}
\centering

\caption{A better table}\label{better}

\begin{tabular}{@{}lccccccc@{}}
\toprule
Model   & A  & \multicolumn{2}{c}{B} & \multicolumn{2}{c}{C} & \multicolumn{2}{c}{D} \\
\cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(l){7-8}
&    & B1 & B2 & C1 & C2 & D1 & D2 \\
\midrule
Model 1 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
& A3 & B3.1 & B3.2 & C3.1 & C3.2 & D3.1 & D3.2 \\
& A4 & B4.1 & B4.2 & C4.1 & C4.2 & D4.1 & D4.2 \\
\midrule
Model 2 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\midrule
Model 3 & A1 & B1.1 & B1.2 & C1.1 & C1.2 & D1.1 & D1.2 \\
& A2 & B2.1 & B2.2 & C2.1 & C2.2 & D2.1 & D2.2 \\
\midrule
\end{tabular}

\end{table}

\end{document}


text:
## Converting tick-by-tick data to OHLC data using pandas

Using Python to convert tick by tick data to OHLC data : A Pandas Tutorial

In this post, we will explore a feature of Python pandas package. We usually find queries about converting tick-by-tick data into OHLC (Open, High, Low and Close) frequently. This can be accomplished with minimal effort using pandas package. The OHLC data is used for performing technical analysis of price movement over a unit of time (1 day, 1 hour etc.). We have already seen How OHLC data is used to calculate pivot points which traders use to identify key areas where reversal of price movement is possible, using which they can ideate their investment strategy.

### The first step

The first step involves fetching sample data. Let us download sample tick by tick data. For this tutorial, we will use the January data for AUD/JPY (Australian Dollar/Japanese Yen) pair that was downloaded from Pepperstone.

Pepperstone that provides free historical tick data for various currency pairs. The .csv file contains top of the book, tick-by-tick market data, with fractional pip spreads in millisecond details. This data is more than sufficient for our analysis.

### Steps on Python

As you can see the data is without any header. We will include the header and accomplish the required task programmatically.

#### Import pandas package

 import pandas as pd

Data is stored in my working directory with a name ‘AUDJPY-2016-01.csv’. As we saw earlier, the data is without a header. Hence we would add header to the data while importing it. Thus importing and adding header take place in the same line of code.

 data_frame = pd.read_csv('AUDJPY-2016-01.csv', names=['Symbol', 'Date_Time', 'Bid', 'Ask'],

index_col=1, parse_dates=True)
data_frame.head()

This is how the data frame looks like:-

We use the resample attribute of pandas data frame. The resample attribute allows to resample a regular time-series data. We shall resample the data every 15 minutes and divide it into OHLC format. If you want to resample for smaller time frames (milliseconds/microseconds/seconds), use L for milliseconds, U for microseconds, and S for seconds.

data_ask =  data_frame['Ask'].resample('15Min').ohlc()

data_bid =  data_frame['Bid'].resample('15Min').ohlc()

A snapshot of tick-by-tick data converted into OHLC format can be viewed with the following commands:-

data_ask.head()

data_bid.head()

You may concatenate ask price and bid price to have a combined data frame

 data_ask_bid=pd.concat([data_ask, data_bid], axis=1, keys=['Ask', 'Bid'])

### The Complete Code

 import pandas as pd

index_col=1, parse_dates=True)

data_bid =  data_frame['Bid'].resample('15Min').ohlc()

data_ask_bid=pd.concat([data_ask, data_bid], axis=1, keys=['Ask', 'Bid'])

### Conclusion

This was a quick way of computing the OHLC using TBT data. This can be applied across assets and one can devise different strategies based on the OHLC data. We can also plot charts based on OHLC, and generate trade signals. Some other ways in which the data can be used is to build technical indicators in python or to compute risk-adjusted returns.

### Next Step

Since you will need to be analytical & quantitative while getting into or upgrading to algorithmic trading it is imperative to learn programming (some if not all) and build foolproof systems and execute right strategies. To enable a fine learning experience QuantInsti offers a comprehensive course called Executive Programme in Algorithmic Trading (EPAT) with lecture recordings and life time access and support.

## 4 thoughts on “Converting tick-by-tick data to OHLC data using pandas”

1. November 28, 2016

In order to do back testing , I can do it on many platforms where this kind of data is readily available.
But for Live Trading, if strategy demands for some interval viz- 5, 10, 15,minutes data, is it compulsory to convert TBT data to OHLC or is there any other way to do away with without the conversion?

• November 29, 2016

If the strategy requires candlesticks data then converting into OHLC is necessary.
Some brokers/data vendors do provide 5x candlestick data otherwise it is necessary to convert into OHLC format.

• December 1, 2016

How do I convert streaming data to OHLC ?
Does the above method help me? [The above method is for the data of past and not streaming]

Secondly the tick data is not in proper format. for instance I get a dictionary of key and values in one single cell of CSV that too without datetime
I have attached a file as to show the sample of how I receive data

Can you help me on this?

• December 6, 2016


text:
# 25.2 The law of reflection

 Page 1 / 3
• Explain reflection of light from polished and rough surfaces.

Whenever we look into a mirror, or squint at sunlight glinting from a lake, we are seeing a reflection. When you look at this page, too, you are seeing light reflected from it. Large telescopes use reflection to form an image of stars and other astronomical objects.

The law of reflection is illustrated in [link] , which also shows how the angles are measured relative to the perpendicular to the surface at the point where the light ray strikes. We expect to see reflections from smooth surfaces, but [link] illustrates how a rough surface reflects light. Since the light strikes different parts of the surface at different angles, it is reflected in many different directions, or diffused. Diffused light is what allows us to see a sheet of paper from any angle, as illustrated in [link] . Many objects, such as people, clothing, leaves, and walls, have rough surfaces and can be seen from all sides. A mirror, on the other hand, has a smooth surface (compared with the wavelength of light) and reflects light at specific angles, as illustrated in [link] . When the moon reflects from a lake, as shown in [link] , a combination of these effects takes place.

The law of reflection is very simple: The angle of reflection equals the angle of incidence.

## The law of reflection

The angle of reflection equals the angle of incidence.

When we see ourselves in a mirror, it appears that our image is actually behind the mirror. This is illustrated in [link] . We see the light coming from a direction determined by the law of reflection. The angles are such that our image is exactly the same distance behind the mirror as we stand away from the mirror. If the mirror is on the wall of a room, the images in it are all behind the mirror, which can make the room seem bigger. Although these mirror images make objects appear to be where they cannot be (like behind a solid wall), the images are not figments of our imagination. Mirror images can be photographed and videotaped by instruments and look just as they do with our eyes (optical instruments themselves). The precise manner in which images are formed by mirrors and lenses will be treated in later sections of this chapter.

## Take-home experiment: law of reflection

Take a piece of paper and shine a flashlight at an angle at the paper, as shown in [link] . Now shine the flashlight at a mirror at an angle. Do your observations confirm the predictions in [link] and [link] ? Shine the flashlight on various surfaces and determine whether the reflected light is diffuse or not. You can choose a shiny metallic lid of a pot or your skin. Using the mirror and flashlight, can you confirm the law of reflection? You will need to draw lines on a piece of paper showing the incident and reflected rays. (This part works even better if you use a laser pencil.)

## Section summary

• The angle of reflection equals the angle of incidence.
• A mirror has a smooth surface and reflects light at specific angles.
• Light is diffused when it reflects from a rough surface.
• Mirror images can be photographed and videotaped by instruments.

## Conceptual questions

Using the law of reflection, explain how powder takes the shine off of a person’s nose. What is the name of the optical effect?

## Problems&Exercises

Show that when light reflects from two mirrors that meet each other at a right angle, the outgoing ray is parallel to the incoming ray, as illustrated in the following figure.

Light shows staged with lasers use moving mirrors to swing beams and create colorful effects. Show that a light ray reflected from a mirror changes direction by $2\theta$ when the mirror is rotated by an angle $\theta$ .

A flat mirror is neither converging nor diverging. To prove this, consider two rays originating from the same point and diverging at an angle $\theta$ . Show that after striking a plane mirror, the angle between their directions remains $\theta$ .

why static friction is greater than Kinetic friction
draw magnetic field pattern for two wire carrying current in the same direction
An American traveler in New Zealand carries a transformer to convert New Zealand’s standard 240 V to 120 V so that she can use some small appliances on her trip.
What is the ratio of turns in the primary and secondary coils of her transformer?
nkombo
How electric lines and equipotential surface are mutually perpendicular?
The potential difference between any two points on the surface is zero that implies È.Ŕ=0, Where R is the distance between two different points &E= Electric field intensity. From which we have cos þ =0, where þ is the angle between the directions of field and distance line, as E andR are zero. Thus
sorry..E and R are non zero...
By how much leeway (both percentage and mass) would you have in the selection of the mass of the object in the previous problem if you did not wish the new period to be greater than 2.01 s or less than 1.99 s?
what Is linear momentum
why no diagrams
where
Fayyaz
Myanmar
Pyae
hi
Iroko
hello
Abdu
Describe an experiment to determine short half life
what is science
it's a natural phenomena
Hassan
sap
Emmanuel
please can someone help me with explanations of wave
Benedine
A 20MH coil has a resistance of 50 ohms and us connected in series with a capacitor to a 520MV supply
what is physics
it is the science which we used in our daily life
Sujitha
Physics is the branch of science that deals with the study of matter and the interactions it undergoes with energy
Junior
it is branch of science which deals with study of happening in the human life
AMIT
A 20MH coil has a resistance of 50 ohms and is connected in series with a capacitor to a 250MV supply if the circuit is to resonate at 100KHZ, Determine 1: the capacitance of the capacitor 2: the working voltage of the circuit, given that pie =3.142
Musa
Physics is the branch of science that deals with the study of matter and the interactions it undergoes with energy
Kelly
Heat is transfered by thermal contact but if it is transfered by conduction or radiation, is it possible to reach in thermal equilibrium?
Yes, It is possible by conduction if Surface is Adiabatic
Astronomy
Yeah true ilwith d help of Adiabatic
Kelly
what are the fundamentals qualities
what is physic3
Kalilu
what is physic
Kalilu
Physics? Is a branch of science dealing with matter in relation to energy.
Moses
Physic... Is a purging medicine, which stimulates evacuation of the bowels.
Moses
are you asking for qualities or quantities?
Noman
give examples of three dimensional frame of reference
Universe
Noman
Yes the Universe itself
Astronomy
Examine different types of shoes, including sports shoes and thongs. In terms of physics, why are the bottom surfaces designed as they are? What differences will dry and wet conditions make for these surfaces?
sports shoes are designed in such a way they are gripped well with your feet and their bases have and high friction surfaces, Thong shoes are for comfort, these are easily removed and light weight. these are usually low friction surfaces but in wet conditions they offer greater friction.
Noman
thong sleepers are usually used in restrooms.
Noman


text:
# Cron job is not working [closed]

I have a cron job configured at var/spool/cron/testuser, Am calling adindex.sh file from there.

Am getting results when am directly put the command directly in prompt(php and sh), But cron is not processing this one. I tried to log the cron using tail -f /var/log/cron and got:

Feb 19 04:05:01 ip-118-139-177-76 CROND[18164]: (inwhosting) CMD (/home/testuser/cronlogs/adindex.sh)

Edit: Output for crontab -l

MAILTO=""
*/5     *       *       *       *       /home/testuser/cronlogs/adindex.sh
*/5     *       *       *       *       /home/testuser/cronlogs/sendemail.sh
*/5     *       *       *       *       /home/testuser/cronlogs/sendsms.sh

#wget --user=admin--password=pswd123 http://www.exmaple.com/advertiser/cron/updateindex?cron_key=Inw1234 -O /home/testuser/cronlogs/ad/log_date "+%Y_%m_%d_%H_%M".txt

Anybody please tell me what is going wrong?

## closed as off-topic by jasonwryan, Anthon, Timo, Zelda, slm♦Feb 20 '14 at 12:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – jasonwryan, Anthon, Timo, Zelda, slm
If this question can be reworded to fit the rules in the help center, please edit the question.

• There's a typo somewhere in your question is adindex.sh a php script or a shell script. your log shows cron is attempting to execute your command, what does your command look like why do you think it isn't running ? – X Tian Feb 19 '14 at 11:31
• My cron job is to index the solr database, and it is not indexing via cron job. I tried this via command line and works fine – Prajila V P Feb 19 '14 at 11:52
• what is the name of your script ? is it a php script or shell script ? – Kiwy Feb 19 '14 at 12:18
• can you edit your question to add the result of cron -l – Kiwy Feb 19 '14 at 12:58
• Is php in cron's \$PATH? – Hauke Laging Feb 19 '14 at 14:19

You have to execute it using sh; here is my example
MAILTO=user@linuxmental.com

• Or chmod a+x /home/user/backup.sh (assuming it has a shebang). – Patrick Feb 20 '14 at 6:07


text:
# 3.26 To record temperature using degrees celsius

 Page 1 / 2

## Memorandum

1. Temperature

2. 180 °C

4. 100 °C

6. 38 °C

7. 0 °C

1.1 –4 °C

1.2 25 °C

1.3 –12 °C

1.4 38 °C

1.5 –18 °C

1.6 –10 °C

2.1 38 °C

2.2 -18°C

3.1 10 °C

3.2 8 °C

3.3 6 °C

3.4 7 °C

3.5 –3 °C

4. 6,5 °C; 12,5 °C; 1 °C

ASSESSMENT: MEASURING

1.1 375 mℓ

1.2 0,62 kg

1.3 0,1

1.4 5 000

1.5 2 m

2.1<

2.2>

2.3<

2.4<

2.5>

3.1 l × b × h

3.2 (1 m × 1 m × 1 m) + (2 m × 2 m × 3 m)

= 1 m³ + 12 m³

= 13 m³

4.1 5 °C

23 °C

19 °C

4.2 1 380 ÷ 120 = 11,5

11 $\frac{1}{2}$ h

4.3 (43 + 41,4 + 39,8 + 42 + 41,2) ÷ 5

= 207,4 ÷ 5

= 41,48 °C

5.1 300 cm × 400 cm

3 m × 4 m

5.2 3 m × 4 m = 12 m²

5.3 W (12 × 8) + (16 × 2) + (10 × 2) = 148

S 28 + 16 = 44

5.4 $\frac{\text{44}}{\text{148}}$ = $\frac{\text{11}}{\text{37}}$

6. 7 $\frac{1}{2}$ × 4 cm²

= 30 cm²

7.1 (175 mm × 6) + (32 mm × 2) + 145 mm

= 1 835 mm

= 1,835 m

7.2 3,165 m

8.1 (18 × 4) + (12 × 2) = 96

8.2 40 min + 24 h + 6 h 15 min

= 30 h 55 min

## Content

Let's begin by looking at some general questions.

• With what instrument do we measure temperature?________________________
• At what temperature does your mother usually bake a cake?______________o C
• What is the temperature of your bath water? ±_______________________o C
• What is the temperature of boiling water? ±_______________________o C
• What was the temperature on the hottest day last summer?_______________o C
• What is the body temperature of a healthy person? ±_________________o C
• What temperature is the freezing point of water?_______________________o C

DO YOU REMEMBER THIS?

°C

## Activity: to record temperature using degrees celsius [lo 4.4.4, lo 4.6.4]

1. Read the temperature on each of the following thermometers.

 1.1_______ 1.2_______ 1.3_______ 1.4_______ 1.5_______ 1.6_______

2. Which temperature is:

2.1 the highest: ______________________________

2.2 the lowest: ______________________________

3. What will the thermometer indicate if the temperature:

3.1 rises by 8 degrees from +2 ºC? ______________________________

3.2 rises by 12 degrees from –4 ºC? _____________________________

3.3 rises by 7 degrees from –1 ºC? ______________________________

3.4 drops by 11 degrees from 18 ºC? ____________________________

3.5 drops by 10 degrees from 7 ºC? _____________________________

4. What is the reading on the following thermometers?

___________________

___________________

___________________

ASSESSMENT: MEASURING

1. Complete

1.1 ℓ = _________________________ mℓ

1.2 2,480 kg ÷ 4 = _________________________ kg

1.3 360 ÷ (_________________________ × 90) = 40

1.4 (20 × 102) + (3 × 103) = _________________________

1.5 25 % of 8 m = _________________________ m

2. Fill in>;<; =

2.1 0,015 m * 15 cm

2.2 1,37 kg * 137 g

2.3 1 m * 1 775 mm

2.4 72 min * 1 h

2.5 5 cups * 1 ℓ

3.

3.1 Write down a formula for calculating the volume of a cube.

____________________________________________________________________

3.2 Now use this formula to determine the volume of the following shape:

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

_____________________________________________________________________

#### Questions & Answers

where we get a research paper on Nano chemistry....?
what are the products of Nano chemistry?
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
Preparation and Applications of Nanomaterial for Drug Delivery
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!