Model: ProbFuzz supports three kinds of statements as part
of the model:
Assignment:
p = x + y
Observe:
observe(Normal(w*x + b), y)
or,
Conditional:
if (cond)
then
observe(DIST(w*x + b), y)
else
observe(DIST(0.5*x + b), y)
Here,
w
and
b
are parameters and
x
and
y
are data variables.
Finally, we need to specify the parameters for which we want to
compute the posterior distributions:
posterior(w)
Putting all of them together we can get something like:
x : float[10]
weight : float
bias : float
y : weight*x + bias
w := DISTX
b := DISTX
p := DISTX
cond = bernoulli(CONST)
if (cond)
then
observe(DIST(w*x + b, p), y)
else
observe(DIST(5.0*x + b, p), y)
posterior(w)
posterior(b)
posterior(p)
This is the Linear Regression with Conditionals template in
ProbFuzz.