Segregation and Peer Effects#

January 24, 2021


In this notebook we explore

Hopefully by doing experiments on these models, we get some new ways of thinking about collective behavior and how outcomes may not necessarily be intuitive by looking at average behaviors.

TLDR#

These are highly simplified models of segregation and how communities of similar individuals tend to form.

For individuals more tolerant of others that are different from them, will they tend to form more “integrated” or mixed communities? How about individuals that are highly intolerant?

Paradoxically, relatively tolerant digital agents tend to want to segregate and form communities of similar individuals. While in some cases, highly intolerant digital agents tend to integrate and form an unstable mixture of different individuals.

These are simplified and do not represent actual people moving around. So it’s definitely something we shouldn’t take too seriously.

However, these are interesting mental models. One takeaway is when you deal with many things interacting with each other, it’s hard to predict what will happen.

Segregation#


Segregation between different people has always been and continue to be an interesting topic. Schelling in his 1971 paper, “Dynamic Models of Segregation” examined the dynamics of segregation via an agent-based modelling approach that led him to interesting insights.

In this section, we will replicate his work. Here are some guide questions for this exercise:

  • If individuals segregate into highly polarized groups, does that mean that they dislike the other group, e.g. racists or intolerant?

  • Is it possible for relatively tolerant individuals to form highly-segmented groupings?

  • If say we have the same population for agents 1 and 2, and they both have a threshold of 20% (they need 20% of their neighbors to be like them for them to be happy), what do you think will be average proportions of like-neighbors per agent?

  • If the populations of the two agents are not the same, e.g. we have a minority class, what will happen to the segregation patterns and proportions?

  • What if we limit movement such that agents can only move into vacant areas in their vicinity, how will this affect segregation?

  • Can we necessarily infer collective behavior from average statistics, e.g. average mixing preference/thresholds?

  • Can we necessarily infer individual preferences/thresholds from collective behavior?

Segregation in 1D#

Schelling began his model by introducing a 1-dimensional model with two types of agents (black and white) on a line.

  • Objective - the agents will move into positions that will make all / most of them happy

  • Rules

    • From the current positions, an unhappy agent is randomly selected (Schelling selected from left to right)

    • That agent will them randomly select a vacant position that will make the agent happy

      • In Schelling’s 1D set up, there were no vacant areas and the agent looks for points between other agents where it can squeeze itself into

      • Moving into vacant areas on the othat hand is more intuitive because we can think of them as empty houses people move into. You don’t really make your own space by squeezing into two occupied houses.

      • This rule is applied in Schelling’s 2D model

    • We repeat until we reach stability (nobody moves) or few people move (if there’s no fixed stability)

  • Given

    • p - a fixed proportion of agent 1, agent 2, and empty spaces (houses)

    • n - linear neighborhood (1 dimension) randomly populated by n agents and some empty spaces

    • thresholds - A fixed set of thresholds of the minimum proportion of similar nearby neighbors for each agent that will make them happy

    • k - The distance to the left and right, k, from the agent that defines nearby neighbors. Those at the far left, will have no nearby neighbors to the left and k nearby neighbors to the right

    • travel_lim - True/False whether we limit the travel to k or not

Impact of Thresholds#

  • Given k=4, n=70 (Schelling’s params), and equal number of agents, Even if say, we fix at 50% thresholds to be in a neighborhood with similar neighbors (so they will be fine with a mixed neighborhood), they still tend tend to segregate so the average proportion of like neighbors in the vicinity of each agent become ~90% (Schelling saw 81%).

  • To answer our question above, even if the thresholds are as low as 20% each, the average proportion of like neighbors become 60%-70%. Schelling called these results “striking”

100%|██████████| 30/30 [00:00<00:00, 31.84it/s]
final avg similarities agent 1, agent 2, all  0.980246913580247 0.9833333333333334 0.9816993464052288
../_images/56d2694e2ff0143e00b9c1cd6fc255f3bb02e964cc6bafcba09b78900c5dba90.png ../_images/ce6b5d0e636c1c5448204e6d8ca16f1cb1030ec595ee50d065781c8b5f45f158.png
100%|██████████| 20/20 [00:00<00:00, 71.15it/s]
Text(0.5, 0.98, 'neighborhood similarity')
../_images/87700e7129942bd9d6842fe42c0d9acc8e9400a5a9c398111b0556dea0c7db2f.png
100%|██████████| 30/30 [00:01<00:00, 27.65it/s]
final avg similarities agent 1, agent 2, all  0.7146825396825397 0.6895833333333333 0.7028711484593838
../_images/e3de0455d399fd586c989d28b08a925657e1fe8989111e85dc7ceb369bc5e126.png ../_images/a9b3204609cb4b4a6ee83987ed35858bb35d621e02f10d4cad1229f0fc3b5791.png
100%|██████████| 20/20 [00:00<00:00, 123.82it/s]
Text(0.5, 0.98, 'neighborhood similarity')
../_images/f6fc237a20d68cb38f8919ef10a0d07cd4bece97cc0c10f5dda56c1adacc516e.png

Impact of Having a Minority Class#

  • At 50% thresholds for all agents, the median neighborhood similarity for the minority is over 80% (the minority can aggregate) but there are outliers when the minority never aggregates (which is a case when the vacancies are uniformly spread apart)

  • There is a large variation in outcomes for the minority group, which means the changing the initial state may result in very different outcomes, and hence the equilibrium is not as “stable”

  • If we make the threshold conservative e.g. 20% for all, we find that the minority does not need to aggregate into one cluster and over 30% similarity is enough though still higher than the 20% value

100%|██████████| 30/30 [00:01<00:00, 27.97it/s]
final avg similarities agent 1, agent 2, all  0.9333333333333332 0.9888888888888889 0.9823529411764707
../_images/65b7bd1f4844a51567a557f34cc7164d216bc99d15ce4bc8612356aebad2a6dd.png ../_images/4c0941f88876c3e8d8b4919d72ac978c7e069d4a65c9a3417d002d5215411820.png
100%|██████████| 20/20 [00:00<00:00, 102.41it/s]
Text(0.5, 0.98, 'neighborhood similarity')
../_images/ed8169478b8320c12e5fd5844bf0145ba8d9fefa5d4416483fa8a76157e43f88.png

Travel limits#

  • Even if we limit mobility to only the nearest vacant positions, we find that for a given threshold (50%) and proportion (1:1) of agents, we still reach around 80% similarity proportions per agent although convergence is much slower than without travel limits.

  • Schelling claimed this can be a proxy for “organized movement” where individuals do not move too far apart and thus tend to cluster. He also claimed this can be a proxy for “anticipatory behavior” where agents can only move to nearby areas even if they’re not yet happy, in anticipation of more people coming in.

100%|██████████| 150/150 [00:05<00:00, 28.29it/s]
final avg similarities agent 1, agent 2, all  0.8587912087912088 0.8569444444444444 0.8579047619047618
../_images/9dbe1b23b52a1725288a6324477a6637b4ca6431ab9a61866d37a2d1b9696796.png ../_images/44a36151e35de01f271d8976b2204790d85ad8a20f1285772a42979c16fcf200.png
100%|██████████| 20/20 [00:01<00:00, 17.25it/s]
Text(0.5, 0.98, 'neighborhood similarity')
../_images/362f18b422462f46109b1e06962b904ede8b24a3a607a4c047cf23cedca00530.png

Segregation in 2D#

The 1D model already gives us insights on “emergent” properties of groups that cannot immediately be inferred from individual dispositions (thresholds). But things get much more interesting when we look at 2D models. Where we can see more interesting patterns. Besides, a 2D model arguably captures reality better since people move in space.

An intuitive way to think about this model is that each cell is a house that’s either empty or occupied by an agent. Agents will then move from house to house in order to reach the set required proportion of nearby neighbors.

  • Objective - the agents will move into positions that will make all / most of them happy

  • Rules:

    • There are two agents who can move around into vacant spaces

    • Agents are either happy or unhappy

      • They are happy if the mix neighbors surrounding them are at least as good as desired (threshold)

      • If they are happy they will stay in their position

      • Unhappy agents are selected randomly and

    • Agents belonging to the same class will all have the same threshold, but the two classes may have different thresholds - this was Schelling’s constraint for this exercise

  • Given

    • props - a fixed proportion of agent 1, agent 2, and empty spaces (houses)

    • n - the dinemsion of one side of a square neighborhood randomly populated by n agents and some empty spaces

    • thresholds - A fixed set of thresholds of the minimum proportion of similar nearby neighbors for each agent that will make them happy

    • thresholds_max - the maximum proportion of like neighbors near an agent (default = None)

    • kernels - the length of a side of a square matrix around an agent to identify nearby neighbors

    • travel_lim - True/False whether we limit the travel to only within a kernel x kernel matrix around the agent or not

50% demand leads to how much segregation?#

  • It leads to 90% segregation

  • This is a non-intuitive outcome that we see. Despite each individual having only a requirement of 50% similar individuals in the neighborhood, the collective interaction leads to disproportionate segregation. Leading to large clusters of similar neighborhoods.

  • Our agents are relatively tolerant yet the outcome’s not expected.

100%|██████████| 1000/1000 [00:01<00:00, 649.98it/s]
../_images/53e073cf23472b4f1cade2d2cc37d79d910caa2c37bd9da0b897376a5f24d433.png
final avg similarities agent 1, agent 2, all  0.9049760447002967 0.9075636736515167 0.9062952280871933
../_images/a5ec10a8eb667b09b4f2e0323b032e1cd7a9afe6baf1cc34fe69a9461dcba0ad.png ../_images/898216b9ffa4135d4b964de3b767edd8f96aa1b578b8067b23db9b1f112a180b.png ../_images/0105a6017daf273a0d51b17fdbb5aff962d3af76fcbbed56b0ebfa7e85d2de10.png

We visualize below the phase spaces showing how the similarity threshold requirements of agent 1 and agent 2 affect neighborhood similarities. We also show how the thresholds affect how large the similar clusters of neighborhoods are. The most segregated neighborhoods come from agents that have ~50% similarity threshold requirements.

What’s interesting is if all agents have 90% similarity requirement, they end up being unsegregated. So less tolerant agents become less segregated or more integrated. That is odd!

We will see in the experiments below what happens when agents are relatively intolerant (requiring 80% of their neighbors to be similar to them)

But first, let’s see what happens if we impose a travel limit on our agents with 50% similarity requirement.

100%|██████████| 10/10 [01:12<00:00,  7.28s/it]
../_images/2fddf757a7c4e6f49c650bf6c226299c264e90dbc9863f55b118bfdd8c994104.png ../_images/7a0b48521784e1679926462a4d939492b59c771acaadb955fbe2319114a1741c.png ../_images/d7c7c1b2a039d3734f31452535baff57d6186046ce4bb5fb5aec7cfa7d6fcb72.png

What happens if we impose a travel limit to just the k x k local neighborhood?#

If we limit movement to the kernel size (local neighborhood) at a time, we still get clustering though slower. Here our kernel/local neighborhood is a 5x5 grid.
More but smaller clusters tend to form compared to no travel restrictions.

100%|██████████| 1000/1000 [00:01<00:00, 580.43it/s]
../_images/3cf764820cf7b7f9550b78fb70beb0abd045cf4847c7990154e2f7674c680fe6.png
final avg similarities agent 1, agent 2, all  0.5759549874488213 0.5934919689215339 0.5848012721460831
../_images/b2b0b97fee51e56449d54b448a3bf44c169bdacbc622419315a09d9087c9a894.png ../_images/3fc45bc85dc801d84205e43e49f5264ec00909218440118a7c229a8b13b61479.png ../_images/710c1bbf12c0f0f114abfc402d6171ec637b34428562c52be6850b57536679f6.png

We plot the phase spaces.

100%|██████████| 10/10 [01:22<00:00,  8.22s/it]
../_images/dbbe13e07dbe29534014a9468e08db7e76d338b03a4b26ef54aaaf868f0cc6e7.png ../_images/c9a7f4f81fcf8f0cf851035a3466152beefce927e3bbbfada671109bfaaa3e3e.png ../_images/afd487b8abdf9c07843a4966c7df4c0366a56e47eb9f091beabbdac547493c34.png

What if we increase the local k x k neighborhood considered?#

We changed the kernel/local neighborhood to a 13x13 grid around the agent. If an agent’s demand/threshold is based on a larger area, they will tend to form larger clusters

100%|██████████| 1000/1000 [00:02<00:00, 495.61it/s]
../_images/c7ddad36336119cf80ab2078efa2e74ea092be58d03106da06be124022fbfb6d.png
final avg similarities agent 1, agent 2, all  0.8910577738738836 0.896696810404354 0.8939325768109861
../_images/8333f2b85e31c9bf7e34f61e9ecb1c6db12d447cb4031704df19c5cf8ee2ca8e.png ../_images/32501ade9cecdba543a2698a19c09f64ae5cd414cb6c9785608d311689971a00.png ../_images/ad32f2562cdbb702da329ab88967e59ea31a36a5a2a94ef17892831bc373c478.png
100%|██████████| 10/10 [02:13<00:00, 13.35s/it]
../_images/d3afa2d1ecb1967e737a7799def1c11842a4801a0588f92b99ade9f2d7bd0be9.png ../_images/9412d30ed64ea3e5b7c5e23f55db8508994ef87c66a1d97136289fe4503137d9.png ../_images/141c4ba5115e523345a446e38f26d280aafc963f1e64bf170f905442ebd385d9.png

What if we initialized from a semi-clustered initialization and then we run with different parameters?#

We start by allowing the agents to cluster below. We restrict the agent’s movement to a 5x5 grid kernel around it.

100%|██████████| 1000/1000 [00:01<00:00, 512.76it/s]
../_images/53e073cf23472b4f1cade2d2cc37d79d910caa2c37bd9da0b897376a5f24d433.png
final avg similarities agent 1, agent 2, all  0.9049760447002967 0.9075636736515167 0.9062952280871933
../_images/a5ec10a8eb667b09b4f2e0323b032e1cd7a9afe6baf1cc34fe69a9461dcba0ad.png ../_images/898216b9ffa4135d4b964de3b767edd8f96aa1b578b8067b23db9b1f112a180b.png ../_images/0105a6017daf273a0d51b17fdbb5aff962d3af76fcbbed56b0ebfa7e85d2de10.png

Then we change the local neighborhood/kernel to a 13x13 grid. We notice that this destroys the existing communities and makes it quite difficult to rebuild it. Had the agents started from a random initialization, it would have been quick to form communities (experiments above). But starting from a pre-built community and switching to a different one with different parameters is much harder. This is interesting!

100%|██████████| 2000/2000 [00:02<00:00, 904.46it/s] 
100%|██████████| 2000/2000 [00:04<00:00, 450.98it/s]
../_images/7e3468e5ed610a6d881e5d381f18e3a46d4bab7d487fda7445a0bc9c798b7eff.png ../_images/d68430510066273f55b94a08e54c0b6b33911b301f900f924e26887d784ec987.png
final avg similarities agent 1, agent 2, all  0.9049760447002967 0.9075636736515167 0.9062952280871933
../_images/fc1c61ce4ea61b17649843bd4c0d73d685973ae11d4546bc14fa894bc6eeb990.png
final avg similarities agent 1, agent 2, all  0.506894464171793 0.5191034455374173 0.5131186507503466
../_images/568e25f75933dd5f161b4bb84eb29f2871f2dd1f18d195858ab8a31ffb3d93b1.png

What if agents both have very high demands?#

Now we explore what if agents have very high demands in terms of similarity of agents in their neighborhoods? For example, we try 80% threshold requirement for agent 1 and agent 2. We find that:

  • It’s hard to find an “equilibrium” if both agents have high demands

  • This is especially the case if there’s limited free space. And because the agents dont find an equilibrium, they tend to constant move around causing a decrease in segregation.

100%|██████████| 1000/1000 [00:01<00:00, 504.93it/s]
../_images/4305ded4c33059147594312d9ad7d7ab6b08711e0bbfd41d792f37ea2ead8587.png
final avg similarities agent 1, agent 2, all  0.48939976715190414 0.5163469525273853 0.5031375479315612
../_images/33e412acff0864e2fe87024480ea3753075639c0776d94680e8317b6b9f8a3cb.png ../_images/483bf5be0297d6036fa769f0887768ae9c92afe8cbc092bdbe27573b78ba495d.png ../_images/052a7f3d2cde447d6aef9a07571536f23889048bc903830b15b3602e59b5f6cb.png

However, if we increase the space, the agents get to a stable state of segregation more easily, but they tend to be highly sparse.

100%|██████████| 5000/5000 [00:21<00:00, 235.43it/s]
../_images/d847f1a80bba0bb4b8e85a3be4f0554b064a58cdaaaa8c9f550e98e5b49f4314.png
final avg similarities agent 1, agent 2, all  0.563269623927012 0.5656334212355428 0.5644585160644388
../_images/e64488741adc7178e6832fdd3b234a982c2acded21ae2db999c68a2d57ceebc5.png ../_images/6786eebdc03a08d40011859a27bcb5eafc07ac2cdb36e883cb176fba89add12d.png ../_images/6ee660d3580e41047769a3e28210aeb811c41e160c6a520be99d20a0aee7daa6.png

We show the phase space diagrams

100%|██████████| 10/10 [02:57<00:00, 17.74s/it]
../_images/8672e7b1697aff33f82fa344b6dab73baf894d11f549e4a36b1e980092c0cb6b.png ../_images/4363a6056e2c0fde066d998313ddd8b9a9bd5676c73e13ed20661abd742aeece.png ../_images/3375a7be4c013a25530009b85b6eeaa30ce7a31c50106c74c69a243ee73d97fc.png

What if the two agent classes have different demands?#

In this case, agent 1 has 30% threshold while agent 2 has 60% threshold

  • A more demanding group will tend to form more compact clusters than a less demanding group

  • An equilibrium might be harder to achieve with limited space.

  • An equilibrium can be achieved faster with a lot of space

100%|██████████| 5000/5000 [00:06<00:00, 824.66it/s]
../_images/4ff22c417628ec02a586e06b25619919c0e9adebf7f6874437cb1899b8b6a995.png
final avg similarities agent 1, agent 2, all  0.6115512491231043 0.6266706455153158 0.6192591766956044
../_images/254e88e98021c3edf4f87d6a3636dddb8c0ae6a5174ac608af7cc4c45312a8e7.png ../_images/fa2279bc1a5aeb6c778bc077d52450f96f20069e94c614232e348caf22a255e5.png ../_images/cb0abc41211def2da36aad64fb065ee659fd96172ccd15bcb45d4fa34b9e617f.png
100%|██████████| 10/10 [01:20<00:00,  8.00s/it]
../_images/2fddf757a7c4e6f49c650bf6c226299c264e90dbc9863f55b118bfdd8c994104.png ../_images/7a0b48521784e1679926462a4d939492b59c771acaadb955fbe2319114a1741c.png ../_images/d7c7c1b2a039d3734f31452535baff57d6186046ce4bb5fb5aec7cfa7d6fcb72.png

What if we free some space? We find that the more demanding one will have a higher clustering density, as expected.

100%|██████████| 1000/1000 [00:01<00:00, 663.23it/s]
../_images/6dc762732926a3d38cc54dfe3ab9a0969e04cb1333b83ecc0c4a5a1cd13c3fde.png
final avg similarities agent 1, agent 2, all  0.8589989355479327 0.8897692453690753 0.874417463896488
../_images/524852b3d8741d169fa1bd3f0bc7c13a5a98523906373166879b0a64df8bb3e8.png ../_images/0c17c822bc76a9c5b891845734f9093ef624c30414b50f047f09fbc9a8af4dc8.png ../_images/f5226ea8d4bf816aad58762fd08bdcca7cae9857af4400eb86d9552a23cb7bd4.png
100%|██████████| 10/10 [01:13<00:00,  7.32s/it]
../_images/a23979cdb84ba66f22ae1c5ce70f944267b68440575641e6d5c70fe52a171468.png ../_images/3a9fdaa9f961607f0ed6349f311b07bbaadd53398e09b1350ec9d8e4c359afd8.png ../_images/76dd0a973fcf52a1877d61cb44577a24eab7e71d240b7d0ae6f5cc2ade51745a.png

What if the demands are the same but the proportions of the classes are different?#

  • The minority, requiring similar neighbors, will thus cluster together into fewer but more dense clusters. The minority will start from being sparse into larger and larger groups.

  • Schelling also observed this noting that “The minority tends to accumulate in denser neighborhoods than the majority”

100%|██████████| 5000/5000 [00:05<00:00, 974.34it/s] 
../_images/e8d54b92828ace9b41bb110e9cde20df16f2c3412894ea945073e741bf68ee94.png
final avg similarities agent 1, agent 2, all  0.9049135782865446 0.9689199991652309 0.9558687983786873
../_images/ea8d790851059eb2f8e6061f764c14dc1127affaf5d017f51ebf5a41e04c6a0e.png ../_images/0581d92dd95be46ff56338970897a7bc50bef98165f27b02b3a238640bf5421e.png ../_images/5e276cb1cb68c33bb747757b4fdffe778b197eb86454c9521ac8376f3b87bc19.png
100%|██████████| 10/10 [01:10<00:00,  7.04s/it]
../_images/818f312e02a33abcf2f8bf8a1e953f90fae0f9c700faef5411d98525b86cad9e.png ../_images/e9cd1e8e5e375dd29a20b7c8d104a218211559d796a610b1e11937d87e711d59.png ../_images/51fe30538d105f3d32b11a1ce66eba1e64627b815579fc8faf2a8fed42950259.png

Integrationist Preferences#

Here, we add a limit to the maximum proportion desired around the agent, meaning, the agent does not like if say > X% of the neighborhood is similar to it. In this case, we define our threshold to be between 20% to 90% similar.


We observe some aspects that Schelling also observed

  • Schelling noted “More individuals may be incapable of being satisfied” or an equilibrium is harder to reach

  • If there is a minority, they are “rationed” or shared among the majority members. Thus no big clusters form

  • It might seem that segregation is much more “static” or “stable” than integration

100%|██████████| 100/100 [00:03<00:00, 30.63it/s]
../_images/bbf40771bebbdd65f1759d8812e7429ed19498d7eae1670d5b098fb5f1db21ac.png
final avg similarities agent 1, agent 2, all  0.50076872921975 0.5145692112651683 0.507739100840569
../_images/363d8b69f1f3e98c4dc2f24f55fa7ee4cdf4fa46c149aa86eaaaef38859a3e05.png ../_images/cc2f147fdecfd6f4d9e77562500b8a9c47c0c58a945cfed2f60981c08cf6d054.png ../_images/f8a0e70e4b51cd7baf58777c2df482339db2c28ab75e975cb65bbb6bda5d4a1f.png
100%|██████████| 10/10 [02:40<00:00, 16.03s/it]
../_images/666b22e1cfb17eae9445af517cd75f0b4ffbedbe18e1f9dedbb6245e70dcd52a.png ../_images/4537a6b754455a3601b8e330ba3d2cc4ef5b35384bdaf4cda0592f79a48860d5.png ../_images/0322d9a48c2441e56c6be4a4b35f8f1237012040356f4585381cb7fa3b31d68d.png

If we make the agents sparse and allow for more empty space, an equilibrium is reached where the two agent classes are integrated with one another, with little clumping or clustering of similar agents.

100%|██████████| 100/100 [00:03<00:00, 31.49it/s]
../_images/9f693a9fdc10b4b817579e9207b2c5100fc8c00f76516389497a8bc546eccf64.png
final avg similarities agent 1, agent 2, all  0.5182092538592996 0.5087099110627543 0.5134857411548018
../_images/2cb106055a7a3e3004efd90d34ce6448457f97f24903a4bc265793212363155b.png ../_images/62f08c75e116e286aeec049dcf966a5314e55fad02c4ef5b366c074bd2a419ea.png ../_images/4622d0e33e97a10fa2f4dce865fe996ad05d21715737cd64501f7c0989e2dc21.png
100%|██████████| 10/10 [03:01<00:00, 18.19s/it]
../_images/bca6798b70dfbbe66ceb9859c65e3878dd7363e67ceb07a21e832272c9492b2c.png ../_images/cd8c1ffb8e8f1e7ab0125aea45ac3b550622875c7d333ff178747223c28c9d02.png ../_images/e6ba63d71f6eca501dd5433f381081acd0d35adc574508280544edb2eabb1dae.png

Even if we add more space, if there is a minority, they will be “rationed” among the majority so the minority will keep switching places.

100%|██████████| 100/100 [00:03<00:00, 28.52it/s]
../_images/f3e8d37830945282b331556aabbafac8d4f9f381e76b231bb3786fb8d048cc93.png
final avg similarities agent 1, agent 2, all  0.21644608470104487 0.7961650148914287 0.6789441139796044
../_images/f13e6fa9e28c43982dc585884c9af2d66d0849d93e95fe267b049f308fea7921.png ../_images/e89ac454b00b6a416ec574a08e61f75b21261f5d8d3c18354f9de63e0e45bb36.png ../_images/12e1c3deee008915bc1b06faa2d4b1d3e2c494ef5ca8e1937c4da6134a546dd3.png
100%|██████████| 10/10 [03:07<00:00, 18.72s/it]
../_images/9243f271ef0e97eb73ecd3fc043e5be61e89df551e8924f8d6914c659e024e4e.png ../_images/8dac398b5c577f24d824eeca5b7e55bff8f9c5543ff8628be65901faebd50de7.png ../_images/8e75b4b9ca174685a7d85f239b00802b7b1d2b59ac6acf9555c0ff7d786d94a0.png

Bounded Neighborhood Model#

This model sets a fixed boundary for a sub-neighborhood. Everyone is concerned about the color ratio inside the sub-neighborhood and make their decision based on this value. We can interpret this model as being analogous to becoming part of a physical space or organization e.g. a restaurant, company, school, or even riots (Granovetter).

Here, Schelling introduced the concept of “tolerance” which is the proportion of same agents in the sub-neighborhood. Granovetter will later on expand on this concept which he would call “threshold.”

In this variation of the model, Schelling introduced the possibility of each agent having different thresholds from each other. He further analyzed how the distributions of thresholds affect the stability and outcomes of the system i.e. proportions of agents in the sub-neighborhood.

Here, agents can move out or move in depending on the proportion of like-agents in the sub-neighborhood. Movement is ordered by lowest threshold breached.

  • Objective - the agents will move into positions that will make all / most of them happy

  • Rules:

    • There is/are a predefined neighborhood/s with set boundaries, we’ll refer to as subneighborhoods

    • There are two agents who can move into and out these subneighborhoods

      • They stay in the neighborhood if the mix neighbors inside the neighborhood are at least as good as desired (threshold)

      • Agents leave the subneighborhood if the proportion of neighbors are no longer preferred

      • Agents move one by one and the order by which agents leave or enter based on their preferences (thresholds)

    • Individual agents may have different thresholds following some predefined function - in this case, a linear function with thresholds from 100% (all like-neighbors needed) to 0% (no like neighbors needed)

    • Threshold distributions may be different for the two agents - but for this exercise, we assume them to be the same

  • Given

    • props - a fixed proportion of agent 1, agent 2, and empty spaces (houses)

    • n - the dinemsion of one side of a square neighborhood randomly populated by n agents and some empty spaces

We define below the function that determines the threshold of each agent. We define a smooth line from 100% to 0% and each agent will have a unique value in that range.

Text(0, 0.5, 'threshold (like neighbors / total neighbors)')
../_images/dedf1750e1c0c3a4854e08dae1c95e301b91cb0df07f7396b4e6dd614892ec83.png

We define below the fixed subneighborhood. Yellow is the subneighborhood (imagine a town), and the dark magenta is outside the subneighborhood.

<matplotlib.image.AxesImage at 0x7faba9a75390>
../_images/de77a76964ef410a64b2069e8a2f8828b384af20615b47d032351fcee1e33b81.png

What happens if there are the same number of agents 1 and agents 2?#

complete
final avg similarities agent 1, agent 2  0.43434343434343436 0.5656565656565656
../_images/07943634fe76d8eaab41356303b76a679b12e7fcb8d4bafef484f2d9ab734fe9.png ../_images/aaa7503fe117941fd0c799ce180bf57abe3339c063814be408939dbb34c35c12.png

We run another trial of the configuration above.

complete
final avg similarities agent 1, agent 2  0.4208754208754209 0.5791245791245792
../_images/38d8503beec9d6bf2abdd0fb609fa97bf524450017b9263fc3faddb8f2f488e8.png ../_images/8876ed5e4238a61077200a37d5e9422df2f51a5859f038d0c805f26b3289192c.png

What if the numbers of agent classes are slightly imbalanced?#

The minority will tend to occupy the subneighborhood.

complete
final avg similarities agent 1, agent 2  1.0 0.0
../_images/17745191a5f6c58440d5b5d297edb36efdf6dea6ed872538efb34070611eac3a.png ../_images/862415661f96018882893d99482d2ababe64b60e718e47e2061fc9d434cebd2c.png

What if we have multiple neighborhoods?#

For the same proportions of agents 1 and agents 2, segregation easily arises.

complete
final avg similarities agent 1, agent 2  0.0 1.0
../_images/b0ba8184f32c238243bcd35e9bfd1c8064f1f90307d5f99271abcaf460f6a663.png ../_images/4f8eeff60d6e4779264303f3605e24124c0611f81d9b01a53af583ee86c3b2c6.png

Threshold Models#

Thresholds from Plots#

We can now define a threshold function that is non-linear like in the distribution below, which is a truncated cumulative distribution function of an exponential distribution

../_images/9e73dd6603e639554d1731e3a4b392ffa852b7f0f9f1e4793aeb108ad5167932.png
Text(0, 0.5, 'cdf - prop. of population having <= threshold')
../_images/d3a7cb0e54c6736d55d90d00afbf23f0c630067b102d336b1878e5e4b2e53c50.png

How can we find the equilibrium from these plots?#

  • Intuitively, we have a sense that the system is in equilibrium if the previous proportion of people is the same as the next proportion

  • Analytically, that means that the proportion at time t \(r(t) = r(t+1)\)

  • Visually, we can plot from an initial proportion on the x-axis upwards to find the proportion of population with <= threshold, then we can move to the 45 degree line, and back to the CDF, and so forth until we reach a stable point. The rationale is: if there are currently, 60% (x axis) activated and 80% (y-axis_ have thresholds less than or equal that, they will have to activate (move horizontally to an x-axis proportion equal to the y-axis value) and so on.

Observations of Equilibrium Points from Plots Below#

  • For exponential distributions, we may find a stable equilibrium at a certain point between 0% and 100% activated

  • For a normal distribution, equilibria tend to be either 0% or 100% activated

Exponential Distribution#

../_images/007dbb5072f99a4f7d5a24d72cda0013dc70bd0436ccce07ffd6c74b2abe974f.png ../_images/482faf01991f3b629867efde2f4cd8f79aeae16d156da4219589f72241ecbaab.png

In the cellular automata model below, we start with 0% activated. We find that the proportion of activated grows until it becomes ~60% as we have computed above.

charts/threshold/1_dist_exp_r0_0.0/ exists
../_images/b7cf1d1bb71ee29a11115504a78d7e45053584032b243b84f6d0f1dfb3664277.png ../_images/e8122a44e8cf64d7d097994c65462a5f0c659f342895fff1664dddd5c6f69363.png

If we start with 90% of the population activated, the number of activated declines until we reach only ~60% activated, which again, is the stable equilibrium.

charts/threshold/1_dist_exp_r0_0.9/ exists
../_images/83318d648aded19d0279a8b3e68de74bd4f572b012b48b5fb4b4bc77174b4ae0.png ../_images/232bd72966e4215bbc2a20c6fe1b7c2f1024df034b145a5d41cccd4486aa7930.png

Normal Distribution#

We not investigate a threshold using the cumulative distribution function (CDF) of a normal distribution. From our analysis below, we expect either 100% activation or 0% activation depending on the starting point.

../_images/64e27ce4b5e3e71c3143b3f8c7f34c22d620f88c10323315692bae407b273cf1.png ../_images/c63653140570ca87c64f2ced4828854f9b42daa5cabd58ec9652828d9a1ac510.png

Based on the cellular automata simulation, we find that the proportion of activated goes to 100% if we start with 60% activated.

charts/threshold/1_dist_norm_r0_0.6/ exists
../_images/bdb3c01daa429c7e1335043efbbc24c65806afb2a6da0e1119bb61933f8cb390.png ../_images/7d6423249aec86ff3658ae05aa6cc421f3ac61c34c96c42a9740c69b4eaf7539.png

Based on the cellular automata simulation, we find that the proportion of activated goes to 0% if we start with 45% activated.

charts/threshold/1_dist_norm_r0_0.45/ exists
../_images/c5b67337c2b670a5809009a2d9c2bb0dcc83c4655a564ec4d64579cbfcf4c179.png ../_images/0d980f3377664b4caf4c5fd5bb07c186fb21880cf113e05eee704f0d1d471881.png

Inverse Normal Distribution#

Now let’s look at a threshold based on the inverse normal distribution.

thresh = inv_norm_dist(props, mean=0.5)
plt.plot(thresh, props)
plt.plot([0, 1], [0, 1], 'r--')
r1 = 0.2 # proportion at time t
r0 = 0
for i in range(10):
    r2 = sum(thresh <= r1) / len(thresh) # how many people will activate
    plt.plot([r1, r1], [r0, r2], 'g--')
    plt.plot([r2, r1], [r2, r2], 'g--')
    
    r1 = r2 # r1 is the new r2
    r0 = r2
plt.xlabel('thresholds / prop people activated')
plt.ylabel('cdf - prop. of population having <= threshold')    
plt.show()

plt.plot(thresh, props)
plt.plot([0, 1], [0, 1], 'r--')
r1 = 0.4 # proportion at time t
r0 = 0
for i in range(5):
    r2 = sum(thresh <= r1) / len(thresh) # how many people will activate
    plt.plot([r1, r1], [r0, r2], 'g--')
    plt.plot([r2, r1], [r2, r2], 'g--')   
    r1 = r2 # r1 is the new r2
    r0 = r2
plt.xlabel('thresholds / prop people activated')
plt.ylabel('cdf - prop. of population having <= threshold')    
plt.show()    
../_images/cc2f69b1b3bba359d15f39d90de4b3958c0b93e7089949b9129796d83d6c932f.png ../_images/c409b96528b42702205fba6c3a80f8930a6bef75052aa833b79c529a3e03d125.png
# visualize with cellular automata model

props = np.arange(0, 1, 1/(n**2)) # agents are indices, value is the (cumulative proportion)
thresh = inv_norm_dist(props, mean=0.5)

r1 = 0.2 # initial activated population
seed = 1
np.random.seed(seed)
neighborhood = np.random.choice([0, 1], size=n*n, p=[1-r1, r1]).reshape((n, n))

new_dir = f'charts/threshold/{seed}_dist_norm_r0_{r1}/'

rs = run_thresh_sim(neighborhood, props, thresh, new_dir)
plot_thresh_gif(new_dir)
plt.plot(rs)
plt.show()
charts/threshold/1_dist_norm_r0_0.2/ exists
../_images/1e4821c31ca83c39a92760c35f176b28703ccd4247e01429fece9572dc5bc622.png ../_images/117083b4fbf33daceddee9b58cc85caa70f25896da7333e8fa32b026a4f61529.png
# visualize with cellular automata model

props = np.arange(0, 1, 1/(n**2)) # agents are indices, value is the (cumulative proportion)
thresh = inv_norm_dist(props, mean=0.5)

r1 = 0.45 # initial activated population
seed = 1
np.random.seed(seed)
neighborhood = np.random.choice([0, 1], size=n*n, p=[1-r1, r1]).reshape((n, n))

new_dir = f'charts/threshold/{seed}_dist_norm_r0_{r1}/'

rs = run_thresh_sim(neighborhood, props, thresh, new_dir)
plot_thresh_gif(new_dir)
plt.plot(rs)
plt.show()
charts/threshold/1_dist_norm_r0_0.45/ exists
../_images/e72660490144a6331b26c07f6079a44ada78c8e7b782dc35463195870cd0bce5.png ../_images/a19cca70685b1d1338e13fb60a4f0d3f07dd035af215fa63eb780dafc73cb4ef.png

Stability of Equilibrium vs Threshold#

We test the stability of the equilibrium if we modify our thresholds a bit so that the mean stays the same but the standard deviation differs

  • Even if our mean stays the same at 0.5, varying the standard deviation of thresholds varies the point at which the system reaches equilibrium

  • The implication of this is we should be wary of merely looking at averages (say the average individual) to explain collective phenomena.

Text(0, 0.5, 'equilibrium proportion')
../_images/ab492d85bc409276f0e335d04b164a2589211fcedc22a14bf89d85dac24884b8.png

We visualize the results above for standard deviation = 0.3 and equilibrium point ~ 0.08.

charts/threshold/1_dist_norm_r0_0.2_0.3/ exists
../_images/2989af78a98cb3247b7da74340294c13d4073d85e4a8a8efad07d0cdae1ba6bf.png ../_images/1ca51b9323247df786d737537be9d1dae7f7ff1766fbb810c78037b5a7b7445b.png

We visualize the results above for standard deviation = 0.5 and equilibrium point ~ 0.5.

charts/threshold/1_dist_norm_r0_0.2_0.5/ exists
../_images/83f17329aba0ffda32e33f73746e6d6ab3518a3b5bed0c756dccdd6f8425f7b6.png ../_images/95bda675b931d20c8d79f95b6a4cd0cea3c465fb5cf09924e9ef417b9bfbb2a0.png

Standing Ovation Problem#

Here’s a modification of Granovetter’s activation model. We incorporate some rules that intuitively exist when we’re simulating a standard ovation after a performance. These rules are:

  • Objective - simulate a standing ovation process

  • Rules

    • The audience only sees agents within a field of view. The implications are:

      • Those at the front may have the least information about the true proportion of activated users

      • Those at the far back may have the greatest information

    • Agents have a defined field of view that can be patterned after some shape e.g. cone-shaped

    • The audience can be heterogenous

      • Like in Schelling’s and Granovetter’s models, we can apply a threshold value to indicate

        • the proportion of agents perceived to activate that will cause an agent to activate.

        • the threshold for the quality of the performance

      • We will follow Miller and Page’s model where the quality threshold is fixed at 0.5

    • Agents cannot switch seats

    • Agents can change decisions based on new information

    • The agent stands up based on some factors

      • Each agent assesses (here, randomly generated) the quality of the performance

      • If the quality exceeds the agent’s threshold the agent stands up

      • The agent who stands up from quality will remain standing

      • At t+1 onwards, agents will decide whether to stand up or not based on the proportion of agents standing up that they see

    • “Synchronous” updating is used - per time step, all agents whose thresholds are breached all stand up (or sit down)

  • Notes: Our quality assessments and threshold for peer-pressure are drawn from a normal distirbution given mean and standard deviation as parameters

  • Parameters

    • n - for an n x n matrix representing audience

    • q_thresh - quality threshold exceeding which means the agent will stand up no matter what (one threshold for all users)

    • kernel - the field of view of each agent indicated by zeros and ones on an m x m matrix

    • p_mean - the mean of a normal distribution of peer-pressure thresholds

    • p_stdev - the standard dev of a normal distribution of peer-pressure thresholds

    • q_mean - the mean of the normal distribution of performance quality assessments

    • q_stdev - the standard deviation of the normal distribution of performance quality assessments

We’d like to check:

  • Is it possible for majority to stand up even if most agents did not like the performance?

  • Stable equilibrium, i.e. proportion standing up

  • Number of iterations before reaching the stable equilibrium

  • Proportion of agents standing over time or the reverse: “Stick in the Muds” - proportion of people that did the opposite of the majority at steady state

Below is each agent’s cone of vision. The agent sees others in the bright triangle or cone of vision in front of it.

../_images/1d5ef0db93e5a6e1f513c7dbe58f239b10e408ce3dcdd235cd8c718e4555da30.png

We then define the “peer pressure” threshold parameters to be the CDF of a normal distribution. There’s one threshold for peer pressure and another for how they assessed the play.

../_images/83ce14e6fe4ad9859ef07f5b6b6e222c90498dfa5d6761966d2241403a4aa276.png ../_images/1073fc57e58b6ec62da31809c54c0811ba620c144601956c3d7469641cf7e811.png
sanity check prop people having thresh < 0.6  0.0172

We show the evolution of proportion of people who do the standing ovation. Peer pressure plays a huge role.

sim complete
../_images/09f3af2966d53d0bb25498d5b5fa1eebabd3c6fadddb4fba868b6bdc9374910c.png
Text(0, 0.5, 'proportion of users standing up')
../_images/d7fd49a44f9bbbecab42769bbada43375f4fc7bd7e29fe7fa34465ffc667b642.png