Skip to content

Commit 34fc3e1

Browse files
authored
Merge pull request #20 from TuringLang/phg/model_abstraction
Add function stubs as sketched in interface description
2 parents eee8e1c + f1792c0 commit 34fc3e1

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ version = "0.1.4"
77

88
[deps]
99
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
10-
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1110

1211
[compat]
1312
AbstractMCMC = "2, 3"
14-
StatsBase = "0.33.4"
1513
julia = "1"

src/AbstractPPL.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export VarName,
1515

1616

1717
# Abstract model functions
18-
export AbstractProbabilisticProgram
18+
export AbstractProbabilisticProgram,
19+
condition,
20+
decondition,
21+
logdensity
1922

2023

2124
# Abstract traces

src/abstractprobprog.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,53 @@ using AbstractMCMC
77
Common base type for models expressed as probabilistic programs.
88
"""
99
abstract type AbstractProbabilisticProgram <: AbstractMCMC.AbstractModel end
10+
11+
12+
"""
13+
logdensity(model, trace)
14+
15+
Evaluate the (possibly unnormalized) density of the model specified by the probabilistic program
16+
in `model`, at specific values for the random variables given through `trace`.
17+
18+
`trace` can be of any supported internal trace type, or a fixed probability expression.
19+
20+
`logdensity` should interact with conditioning and deconditioning in the way required by probability
21+
theory.
22+
"""
23+
function logdensity end
24+
25+
26+
"""
27+
decondition(conditioned_model)
28+
29+
Remove the conditioning (i.e., observation data) from `conditioned_model`, turning it into a
30+
generative model over prior and observed variables.
31+
32+
The invariant
33+
34+
```
35+
m == condition(decondition(m), obs)
36+
```
37+
38+
should hold for models `m` with conditioned variables `obs`.
39+
"""
40+
function decondition end
41+
42+
43+
"""
44+
condition(model, observations)
45+
46+
Condition the generative model `model` on some observed data, creating a new model of the (possibly
47+
unnormalized) posterior distribution over them.
48+
49+
`observations` can be of any supported internal trace type, or a fixed probability expression.
50+
51+
The invariant
52+
53+
```
54+
m = decondition(condition(m, obs))
55+
```
56+
57+
should hold for generative models `m` and arbitrary `obs`.
58+
"""
59+
function condition end

0 commit comments

Comments
 (0)