Did you know ... Search Documentation:
Pack plrand -- prolog/prob/strand.pl
PublicShow source

This module provides tools for working in a sort of random generator plus store of mutable references monad (using DCG lanugage to manage state threading).

To be done
- I'm not happy with the state of this module (no pun intended... no wait a minute, that's a pretty good pun actually: the state representation is one of the problems). The use of an untagged union is not good, and the stuff trying to compute marginals doesn't really belong in a low level module like this.
 strand is det
Start a DCG shell (see dcgshell//0) with an empty store and the current state of the plrand random generator.
 strand(+Cmd:dcg(strand)) is det
Run Cmd in a DCG where the state is of type strand = pair(store,plrand:state).
 strand(+Cmd:dcg(strand), +RS1:plrand:state, -RS2:plrand:state) is det
Run Cmd in a DCG where the state is of type strand = pair(store,plrand:state), taking and returning initial and final states of plrand generator.
 clear// is det
Clear everything out of the store. Runs in strand DCG.
 hold_store(+Cmd:dcg(strand))// is det
Runs Cmd leaving the store unchanged.
 pure(+Dist:tagged_dist(A), -X:A, +S1:pair(store,number), -S2:pair(store,number)) is det
pure(+Dist:tagged_dist(A), -X:A, +S1:pair(store,rndstate), -S2:pair(store,rndstate)) is det
Samples or gets probability of value X with tagged distribution Dist. NB: 2nd half of DCG state type is an UNTAGGED union of numbers (probabilities) and random states.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 pure1(Arg1, Arg2, Arg3, Arg4)
 marginal_prob(Arg1, Arg2, Arg3, Arg4)
 marginal_prob(Arg1, Arg2, Arg3, Arg4, Arg5)