The paper is available at CoRR, http://arxiv.org/abs/1112.2681. In addition to the technical details, it contains an appendix which presents the proof of proposition 1.
We implemented the inference algorithm presented in the paper in the XSB logic programming system. This proof-of-concept prototype is implemented as a meta-interpreter and currently supports discrete and Gaussian distributions. The meaning of various probabilistic predicates (e.g., msw, values, set_sw) in the system are similar to that of PRISM system. This implementation illustrates how the inference algorithm specializes to the specialized techniques that have been developed for several popular statistical models such as HMM, FMM, Hybrid Bayesian Networks and Kalman Filters.
Download: https://www.cs.stonybrook.edu/~cram/constdist/code.tar
The package contains the following three files:
- sf.P: the meta-interpreter for computing success functions.
- prog.P : contains sample code for various statistical models.
- readme.txt : gives a short tutorial for writing probabilistic logic programs in our framework.
Example: Consider a factory with two machines a and b. Each machine produces a widget structure from a specific normal distribution and color of a widget is generated from an independent normal distribution. In the following program, msw(m, M) chooses either machine a or b, msw(w(M), Z) gives a product structure Z, msw(pt, Y) gives a color Y, and finally X = Y + Z returns a painted widget X.
Here, at the beginning 'import {}/1 from clpr' is needed for writing constraints. Since this is a meta-interpreter, make sure to declare your claueses 'dynamic' at the beginning of your code.% import {} for constraints. :- import {}/1 from clpr. % declare clauses as dynamic. :- dynamic widget/1, msw/2. % FMM with linear constraint. Widget code. (Example 2) widget(X) :- msw(m, M), msw(w(M), Z), msw(pt, Y), {X = Y + Z} . % Define msw relations, their values and distributions. msw(m, _). values(m, [a, b]). set_sw(m, [0.3, 0.7]). msw(w(_), _). values(w(_), real). set_sw(w(a), norm(2, 1)). set_sw(w(b), norm(3, 1)). msw(pt, _). values(pt, real). set_sw(pt, norm(0.5, 0.1)).
- msw/2 defines a random variable. E.g., msw(m, M) defines a random process 'm' and 'M' is the random variable or outcome of the random process.
- values/2 defines the set of values a random variable can take. For discrete random variable, its values are represented as a list. On the other hand, for continuous random variable it's represented as 'real'.
- set_sw/2 defines a probability mass function or probability density function of a random variable.
Similar to PRISM, PMFs are written as list of probabilities.
norm(_,_) is used to denote a normal/Gaussian distribution. E.g., norm(2,1) denotes a Gaussian with mean 2 and variance 1.In the above program, we defined three random processes namely m, w and pt; and their associated values and distributions. Note that we also used a constraint { X = Y + Z } to define that random variable X is a linear combination of Y and Z.
For illustration purposes, we included a sample program file called prog.P. It includes code for mixture models, hidden markov models and kalman filters. Now that you've written a probabilistic program, execute the following commands in XSB command prompt to run your program.
- Load the interpreter or success function code (sf.P)
| ?- [sf].- Load your code (say written in prog.P)
| ?- [prog].- To get the probability/distribution of some clause/predicate (e.g., widget(X)), invoke the following command:
| ?- prob(widget(X)).Note that like PRISM, prob(G) returns the probability of G. For programs with continuous random variables, it returns the distribution of the random variables in the goal predicate. For example, prob(kf(1, T)) gives the filtered distribution of state T after observing one symbol. In general, prob(G) returns the success function of the goal G. Please see the paper for definition and general form of success functions. To illustrate the success functions of some goals, let's consider the following examples.
- In the example kalman filter program in prog.P, prob(kf(1,T)) returns (norm(-0.0667,0.6667)[T])
which represents the Gaussian distribution (mean: -0.0667 and variance: 0.6667) of variable T.| ?- prob(kf(1, T)). Probability/Density (norm(-0.0667,0.6667)[_h60]) T = _h60;- In the example mixture model program in prog.P, prob(fmix(X)) returns (norm(2,1)[X] * 0.30) + (norm(3,1)[X] * 0.70)
which represents a mixture distribution. Here, machine 'a' and 'b' are selected with probability of 0.30 and 0.70 respectively, and the products produced by machine a and b has distributions norm(2,1) and norm(3,1) respectively.| ?- prob(fmix(X)). Probability/Density (norm(2,1)[_h128] * 0.3000) + (norm(3,1)[_h128] * 0.7000) X = _h128;- (norm(0,1), [(1,X), (-2, Y)]) denotes a Gaussian distribution (mean:0 and variance:1) of X - 2Y.
Note that for continuous random variables, prob/1 returns a distribution, not any specific probability. Probability can be computed over an interval by integrating the success function on that interval/range.
Send an email to:
- cram at cs dot sunysb dot edu.
- maislam at cs dot sunysb dot edu.