We investigate here the impact of four different types of noise on the bounded confidence (BC) model of opinion formation. Without noise, the BC model for an interaction of a receiving agent
where
The four types of noise include:
Noise is drawn from a zero-mean Gaussian distribution with Gaussian width
The simulation can simply be run by executing the python model.py
. Parameters that can be changed to reproduce the results of the manuscript should be changed in the lines below # CHOOSE PARAMETERS
(l. 312)
To analyse the model, the following code should produce a very simplified version of figure 2a in the manuscript.
- Run the model for "ambiguity noise", with "uniform" and several seeds.
- Run the analysis (e.g. in a Jupyter notebook)
import xarray as xr
import matplotlib.pyplot as plt
import numpy as np
eps_vals = [0.001] + list(np.arange(0.05, 0.41, 0.05)) # TODO which BC radius values simulated (here for low resolution)
seedmax=9 # TODO how many seed values simulated
initial_condition = "2G-6AM" # or "uniform"
data = xr.merge([ xr.open_dataset(f"data/model-ambiguityNoise_lowRes_{initial_condition}Initial_eps{eps:.3f}_seeds0-{seedmax}.ncdf", engine="netcdf4") for eps in eps_vals])
data.std(dim="id").sel({"t":1e4, "mu":0.5}).mean(dim="seed").x.plot(x="nu",cmap="Reds")
plt.ylim(0.4,0)
Parameter | Description | Example Value |
---|---|---|
track_times | List of times at which a snapshot of the simulation should be saved; must include 0 (initial time) and the final time | [0,10e5] |
mu_arr | List of the |
[0.5] |
n | Number of agents | 100 |
seeds | List of the seeds to be run | list(range(1000)) |
resolution | The resolution of the phase space of bias and noise levels (eps, nu) | "low" or "high" |
ic | the description of the initial conditions to be used. We tested more options, but these are commented out to increase clarity | "uniform" or "2G-6AM" (which means a superposition of two Gaussian functions to represent climate change opinions in the society according to the six America data, see [Maibach et al. (2011)]) |
noise_type | the type of noise in the opinion formation process (see above) | "ambiguityNoise" |
conda env create -f environment.yml
Package | Version |
---|---|
python | 3.9.5 |
scipy | 1.6.2 |
numpy | 1.20.2 |
optional: networkx | 2.5.1 |
matplotlib | 3.3.4 |
xarray | 0.18.0 |
netcdf4 | 1.5.7 |