   # Venture Console

This describes how to interact with VentureScript from the Venture Console, which is accessible by running the program `venture` after installing (as opposed to from Python via the Venture library bindings).

## Warning

Venture is rapidly-evolving, alpha quality research software. The key ideas behind its design and implementation have yet to be published. We are making Venture available at this early stage primarily to facilitate collaboration and support the emerging probabilistic programming community.

This release is for early adopter types who are willing to put up with much of the pain that a more mature software package would not impose. In particular, documentation is sparse and the user interface is unforgiving. Often, the only way to learn what’s going on will be to ask us or to read the source code.

While Venture should handle the most common kinds of programmer errors gracefully, there are several more subtle mistakes that can make your Venture Console session crash and lose all your state, especially if using the Puma backend. Appropriate caution is advised.

## Example: Tricky Coin

Let’s get acquianted with VentureScript with a simple coin-flipping problem.

A magician flips a coin. Do you think the coin is tricky (i.e., weighted), after having observed a series of flips?

We answer this question in three steps:

1. Construct a simple hierarchical Bayesian model,
2. Condition the model on observed coin-flips,
3. Infer whether the coin is tricky.

In our model, we draw the boolean variable `is_tricky` from a Bernoulli trial to represent our prior probability that the coin is tricky. If `is_tricky` is true, we’ll generate a random value for the bias `theta`. If the coin is fair, `theta`=0.5.

We use the `assume` directive to set up a prior model with the following values:

``````P(is_tricky) = 0.1
theta|is_tricky ~ Beta(1,1)
theta|not(is_tricky) = 0.5``````

Input to the Venture console is prefixed with the prompt `>>> `, followed by sample output (output may vary because Venture is sampling your model as you go). This example session is written in the Lisp-like textual representation of VentureScript abstract syntax.

``````\$ venture
>>> assume is_tricky = flip(0.1)
False
>>> assume theta = if (is_tricky) { beta(1.0, 1.0) } else { 0.5 }
0.5
>>> assume flip_coin = proc () { flip(theta) }``````

We then use the `observe` directive to condition the model on the data of 5 heads.

``````>>> observe flip_coin() = true
>>> observe flip_coin() = true
>>> observe flip_coin() = true
>>> observe flip_coin() = true
>>> observe flip_coin() = true``````

Now that we have a model, we can use the `infer` directive to do inference on it:

``>>> infer 100``

Inference alters the current state of the model, typically by taking steps of an MCMC chain. The default inference is (roughly) a one-random-choice-at-a-time Metropolis-Hastings kernel. Several other built-in kernels are available, and VentureScript supports expressive inference programming.

Having done some inference, we can inspect the state of the chain, or ask for predictions from it:

``````>>> sample is_tricky
True
>>> sample theta
0.837263904542
>>> sample flip_coin()
True
>>> sample flip_coin()
True
>>> sample flip_coin()
True``````

If we do some more inference, the answers might change:

``````>>> infer 100
>>> sample is_tricky
False
>>> sample theta
0.5``````