A generative process is described in WebPPL by combining samples drawn from distribution objects with deterministic computation. Samples are drawn using the primitive sample operator like so:


Where dist is either a primitive distribution or a distribution obtained as the result of marginal inference.

For example, a sample from a standard Gaussian distribution can be generated using:

sample(Gaussian({mu: 0, sigma: 1}));

For convenience, all primitive distributions have a corresponding helper function that draws a sample from that distribution. For example, sampling from the standard Gaussian can be more compactly written as:

gaussian({mu: 0, sigma: 1});

The name of each of these helper functions is obtained by taking the name of the corresponding distribution and converting the first letter to lower case.

The sample primitive also takes an optional second argument. This is used to specify guide distributions and drift kernels.