** Next:** 2.2 Binomial Distribution
** Up:** 2 The Basics
** Previous:** 2 The Basics

##

2.1 Uniform Distribution

Now that we know the basic commands and file types used in Alchemy, we want to
start with the simplest MLN one can think of: the empty MLN. Suppose we want
to consider the output of a coin flip. We can state that the outcome of a flip
is heads with the predicate `Heads(flip)`, where `flip` ranges from,
say, 1 to 20. If `Heads(n)` is true, then flip `n` was heads; otherwise
it was tails. By supplying an empty MLN with `Heads` as the only predicate:

flip = {1,...,20}
Heads(flip)

we can perform probabilistic inference to result in a uniform distribution:

infer -i uniform.mln -r uniform.result -e empty.db -q Heads

Alchemy requires a `.db` file with evidence; here, `empty.db` is an
empty file. The resulting file `uniform.result` shows the marginal
probabilities of each grounding of `Heads` given no other evidence. In the
limit, these should approach 0.5 (note, we can trade off accuracy for speed by
varying the number of samples with the option `-maxSteps`).

Marc Sumner
2010-01-22