This repository contains all materials for the paper "A counterfactual simulation model of causal judgments for physical events" by Tobias Gerstenberg, Noah Goodman, David Lagnado & Joshua Tenenbaum. If you have any questions about this repository, please feel to email me at gerstenberg@stanford.edu.
.
├── code
│ ├── R
│ │ ├── cache
│ │ └── data
│ ├── flash
│ │ ├── experiment1
│ │ ├── experiment2
│ │ └── preliminary_study
│ └── python
│ ├── figures
│ ├── results
│ ├── trialinfo
│ └── video
├── data
├── docs
├── figures
│ ├── clips
│ │ ├── experiment1
│ │ ├── experiment2
│ │ └── preliminary_study
│ ├── diagrams
│ └── plots
└── videos
├── experiment1
├── experiment2
└── preliminary_study
Analysis and plotting script. You can view a rendered html file of the analysis here.
Flash experiment code files.
The counterfactual simulation model is implemented in python 3.7 using the physics engine pymunk. The model.py
file contains the model code.
-
to run the counterfactual simulation model, cd into
code/python/
-
you can then run
python simulation_2ball.py 1
where the last number indicates the degree of noise that should be applied in the counterfactual simulation -
simulation_teleport.py
andsimulation_3ball.py
are used for generating model predictions for the Experiments 2 and 3 in the paper -
in each simulation file, you can set the following parameters:
n_simulations
: number of counterfactual simulations to runtrials
: which trials to run (specified as a list)noise
: noise applied to the ball's motion in the counterfactual situationrecord_data
: logical value whether or not to record the outcome of the simulationsexperiment
: experiment indicatoranimate
: logical value whether or not to show animations of the simulations
-
to create videos of the different clips, you can run the
make_videos.sh
script like sobash make_videos.sh '2balls' 0
(this would make a video of the first clip in Experiment 1)
Raw data files of the three experiments reported in the paper (two conditions each).
Illustrations of the different clips in each experiment.
Diagrams used in the paper.
Results plots.
Videos of the clips presented in the three different experiments.