Intended Readers and Prerequisite Knowledge
This tutorial should be accessible to anyone who is comfortable with:
- Probability fundamentals (point probabilities, probability density functions, etc.)
- Statistical inference fundamentals and some methods (e.g. linear regression, conditional probability, Bayes Rule, etc.).
It will be helpful, especially for the case study models, if the reader understands some basic concepts in modern information security management and risk analysis.
If you are familiar or even experienced in Functional Programming, even better, because it will make learning WebPPL much easier. For everyone else, it would be helpful if you read Functional Programming - Why and How.
Reading Order and Navigation
The tutorial can be read sequentially, or semi-randomly guided by your curiosity. I recommend that everyone read the remaining subchapters in the introduction (In a Nutshell and Big Picture) and at least scan the chapter on “WebPPL” so you can read the code examples.
You can navigate through the content by either using the Table of Contents (links on header and footer of every page) or sequentially by using the “(Next) ▶︎” and “◀︎ (Previous)” links in the header and footer of each page.
Using the Interactive Code Boxes
Nearly all the code boxes are in interactive frames, meaning that you can both run the examples and also modify them using valid WebPPL statements. You can go through the whole tutorial and get value by only running the examples to see the output.
Here is a code example:
Now try editing the code yourself. Perhaps you could change the
2 + 4; expression to
4 + 4 * Math.pow(2,12). You could change the name of the function from
squared and change the second print statement to
squared(4). Click again to see the effects of your changes.
To restore all the example code on a given page to the original versions, refresh/reload the browser window.
Caution #1: Though it is hard to “crash” the system by typing your own code, it is possible to create (effectively) infinite loops or programs that take a loooooooooooong time to finish. Thankfully, the WebPPL interactive interpreter has abutton that you can click that (most of the time) will stop your program and return to a normal web browsing state. If that doesn’t work, you may need to close the web page, or maybe even close your browser (“Force Quit” on Macintosh).
Caution #2: The error messages emitted by WebPPL interactive interpreter are frequently cryptic, not very helpful, or and sometimes not understandable. Therefore, it is best for new programmers to make a few changes or write a few statements at a time, and check that they compile and run before continuing.
Writing Your Own WebPPL Code
At some point, you may want to write your own WebPPL code, along with some documentation, like you see in this tutorial. While you could go all the way to using an integrated development environment (IDE) and run WebPPL via the command line, it may be easier to start with the interactive interpreter and a “blank sheet” for documentation.
For this purpose we provide an Interactive Editor that allows you to create code blocks, text blocks, and to combine them into “markdown” format that you can copy/paste into a text file and save locally. (This is the workflow used to create this tutorial.)
This tutorial draws significantly on the tutorial “Modeling Agents With Probabilistic Programming”, both content and the various templates used to generate the web pages. The authors made the content and templates available here on Github for to promote use, reuse, remixing, and other extensions.
Other more specific credits are given on individual pages of this tutorial.