Skip to content

ameya98/WebPPL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebPPL

WebPPL is a Probabilistic Programming Language, built over JavaScript. This repository contains gists written in WebPPL that highlight WebPPL's inference capabilities.

Inference over Stochastic L-Systems

Create generative trees guided by a stochastic L-system here! Graphics made with the help of d3.js. Performs inference with WebPPL over the number of leaves to identify the depth selected. The depth is the number of times the L-system rules are applied to the current string.

The use of WebPPL complicates the 'save' and 'restore' operations in the L-system, because all JS functions must be referentially transparent, ie, they should not alter state. This means the stack used to restore states must be implicit - see the perform_action() function if interested.

All graphics are SVG elements, so tools like svg-grabber can be used to save your favorite trees. Credit to Tipue for the nice radio button CSS!

a tree in d3

Bayesian Regression

Bayesian regression allows us to estimate parameters as well as the probability density over the parameter space, conditional on training data. See bayesian_regression.js to see how to perform Bayesian linear regression in WebPPL.
In our example, when attempting to learn y = -2x + 20, we get the following densities over the slope (m) and intercept (c) in y = mx + c respectively, showing a good fit.

slope density intercept density

The peaks near m = -2 and c = 20 are clear.

References