Skip to content
Tutorials Center
My learning

Topics

Lesson 41 of 46 ยท Projects and Practice

Project: Build a Conformity Simulation

Build a small agent-based model of an Asch-style study in Python, test group size and an ally, read the results honestly and learn what a toy model can and cannot show.

Models do not replace experiments, but building one is a great way to check whether you understand a theory. In this project you will build a tiny agent-based model of an Asch-style line study. Each simulated person has a private judgment and a different tendency to go along with others. You will then run virtual experiments on group size and on the effect of one ally, compare the results with the patterns from the chapter, and write down what the model leaves out.

Three cards: define the model, run it, read the results
A toy model is a way to test your reasoning, not a source of evidence about real people.

Everything below is a simulation. The numbers are invented to illustrate ideas and must never be quoted as findings about people.

What you will learn

  • How to turn a verbal theory into explicit rules and parameters.
  • How to run virtual experiments and summarize them.
  • How to compare model output with real findings, and what a mismatch teaches.
  • Limits of simulations.

Key terms

Agent-based model: a simulation where individual "agents" follow simple rules and group patterns emerge.

Parameter: a number you choose that controls model behavior.

Seed: a number that makes random simulations reproducible.

Sensitivity analysis: checking how results change when parameters change.

Step 1: Define the rules

Our model follows the story in the Asch lesson:

  1. A participant privately sees the right answer and would give it.
  2. A group of k confederates all give the wrong answer, one after another.
  3. The participant has a conformity weight w between 0 and 1 (a stable personality-like trait, drawn at random for each simulated person).
  4. The pull of the group grows with its size but saturates: pull(k) = 1 - 0.5 ** k (so 1 confederate gives 0.5, 2 give 0.75, 3 give 0.875...).
  5. The participant conforms on a trial with probability w * pull(k).
  6. An ally (one confederate who gives the right answer) cuts the pull by 70 percent.
Python Step 1: one simulated participant

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 2: Run virtual experiments

Now run 3,000 simulated participants per condition and compare group sizes and the ally condition. Notice the shape: more confederates raise conformity with diminishing returns, and an ally lowers it. That qualitative pattern echoes Asch, but we built it into the rules, so it does not count as evidence.

Python Step 2: group size and an ally

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 3: Sensitivity analysis

A model result should not depend on one fragile number. Change the average conformity weight and see what happens. Try the three distributions below.

Python Step 3: does the result depend on the personality mix?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: Read the results

Ask yourself:

  • What does the model reproduce? The levelling off with group size and the ally effect, but only because we coded them.
  • What does it ignore? Task difficulty, informational influence, culture, relationships and anything about why people conform. It treats conformity as one number per person.
  • What would real evidence look like? An experiment with real participants, a pre-registered plan, a control condition and honest reporting.
  • What would you add next? A second route for informational influence, task ambiguity or a cost of speaking out.

Extensions

  1. Add a difficulty parameter that raises conformity when the task is harder.
  2. Let a participant's answer depend on the previous trial (a "momentum" effect).
  3. Draw a figure comparing three distributions of personalities.
  4. Write a short paragraph describing the model for a reader who does not code.

Common misconceptions

"If the model matches the study, the theory is proven." A match shows the model is consistent, not that the theory is true.

"Simulated numbers are findings." They are consequences of the rules you wrote.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why does matching Asch's pattern not prove the model correct?

    We coded saturation and the ally effect, so reproducing them is expected.
  2. 2. What is a sensitivity analysis?

    It tests how fragile a result is.
  3. 3. What does setting a seed do?

    The same seed gives the same sequence.
  4. 4. Which is a limitation of this model?

    Real conformity depends on many more factors.

Summary

  • An agent-based model turns a verbal theory into explicit rules.
  • Virtual experiments help you think, but they are not evidence about people.
  • Check sensitivity, state limitations and plan how real data would test the idea.

Next: Project: a bystander model