Causal Simulations in WebPPL

Using physics simulations inside probabilistic programs.

This is part of a project trying to model the semantics and pragmatics of causal language in a rational speech acts framework using counterfactual simulation.

Some relevant papers:

Installation

Dependencies:

Make a results directory at the top of this project directory.

mkdir results

Install node packages:

cd node_modules/utils/
npm install

Usage

webppl example.wppl --require utils

Then open results/example.html in a browser (Chrom works for sure) to view the animations for the sampled world.

You'll see a simulation of a sample from the world_prior where the velocity of at least one of balls is nonzero. E.g.

gif

In a new webppl file, you can write these html viewer files by first collecting the worlds:

utils.write(world);

And later writing the complete file.

utils.finish("label_for_files");

The input to this function is the name of the .js and .html files. So, e.g. example.html was generated with utils.finish("example").

To download gifs, you need to start a file server, because I can't easily get it to work on the File protocol (security issues, sigh). In the top of this directory:

npm install http-server -g
http-server

Then in a browser, go to http://127.0.0.1:8080/results/example.html.