Revision 71891428245690d59fc43431c4ddd4a582b01999 authored by null-a on 05 July 2017, 08:06:50 UTC, committed by null-a on 05 July 2017, 08:06:50 UTC
1 parent 4da45df
Raw File
sample.rst
.. _sample:

Sample
======

.. toctree::
   :hidden:

   guides
   driftkernels

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

  sample(dist);

Where ``dist`` is either a :ref:`primitive distribution
<primitive-distributions>` or a distribution obtained as the result of
:ref:`marginal inference <inference>`.

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

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

For convenience, all :ref:`primitive distributions
<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 :ref:`guide distributions <guides>` and :ref:`drift
kernels <driftkernels>`.
back to top