1/2 :: nat( 0 ). 1/2 :: nat( s(X) ) :- nat( X ).fits a geometric distribution over the natural numbers. Posing the query
The restriction to probabilistic labels that are known numbers has been proven too strong in practice. In MCMCMS we allow for functions involving a number or variables and which are evaluated at call-time. For example the following program defines a uniform distribution over element selections from a list.
:- pvars( umember(L,_E,_R), [T-length(L,T)] ). 1/L : [L] : umember( El, [El|T] ). 1 - (1/L) : [L] : umember( El, [_|T] ) :- [L-1] : umember( El, T ).
The pvars/2 directive is optional.
When it is present,
is a valid query,
whereas the query
can be used
both when the directive is present and when it is absent.
Returning to the definition of the predicate, note that the base case
is selected with probability and the recursive case with probability
. When
is the length of the list in the second argument,
this predicate will select an element from the list with uniform distribution.
An example of this happening is shown in Fig. 20.
The probability with which each element is selected, is equal to the
product of the edges in the path from the root to its leaf.
In the case of
,
. Similarly for the
other cases.
For the purposes of MCMC the query
creates a maximum
of
choice points. For example when
the path is
, where
and
are internal clause indices assigned order to the clauses of
umember/2 from top to bottom in the order they appear in the source file.
The number of, probablitistic, choice points is
a crucial dimension in the selection of a bactrack point as described in
Section 5.1, also see [Angelopoulos CussensAngelopoulos Cussens2004].
It is possible to reduce the number of choice points
creates by using the declaration
The directive,
forces the probabilistic
backtrack points of predicate with specification
to be ingnored.
Only and all the points created at calls to this predicate are ignored.
Points left by the body of clauses of such a predicate to other predicates
are valid backtracking choices.