next up previous contents
Next: Syntax Up: Tutorial Previous: A mixture prior   Contents


Using continuous distributions

The examples so far have all concerned entirely discrete spaces. Continuous distributions can be implemented by including calls to Prolog built-ins which generate floating point values according to various distributions. (In some cases it may be necessary to call C code if the Prolog you are using does not have built-ins for the distributions you need. See Section 4.3 for pointers to the C language interface.)

In Fig 18 there is a prior that adapts the mixture prior (Fig 16) so that the radii of circles is uniformly distributed over the range $[0,1]$. random/1 is a predicate of library(random) in both Sicstus and Yap.

Figure 18: A mixture prior with a (truncated) uniform distribution over the radii of circles (found in the file tutorial/slps/continuous.slp).
\begin{figure}\centering
\begin{verbatim}0.4 :: mix_hyp(Rectangle) :- hyp(Rect...
...x_dist(6).y_dist(D) :-
x_dist(XD),
D is XD + 1.\end{verbatim}
\end{figure}



Nicos Angelopoulos 2008-06-02