-
Notifications
You must be signed in to change notification settings - Fork 6
/
abstractprobprog.jl
62 lines (40 loc) · 1.48 KB
/
abstractprobprog.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using AbstractMCMC
using DensityInterface
"""
AbstractProbabilisticProgram
Common base type for models expressed as probabilistic programs.
"""
abstract type AbstractProbabilisticProgram <: AbstractMCMC.AbstractModel end
DensityInterface.hasdensity(::AbstractProbabilisticProgram) = true
"""
logdensityof(model, trace)
Evaluate the (possibly unnormalized) density of the model specified by the probabilistic program
in `model`, at specific values for the random variables given through `trace`.
`trace` can be of any supported internal trace type, or a fixed probability expression.
`logdensityof` should interact with conditioning and deconditioning in the way required by
probability theory.
"""
DensityInterface.logdensityof
"""
decondition(conditioned_model)
Remove the conditioning (i.e., observation data) from `conditioned_model`, turning it into a
generative model over prior and observed variables.
The invariant
```
m == condition(decondition(m), obs)
```
should hold for models `m` with conditioned variables `obs`.
"""
function decondition end
"""
condition(model, observations)
Condition the generative model `model` on some observed data, creating a new model of the (possibly
unnormalized) posterior distribution over them.
`observations` can be of any supported internal trace type, or a fixed probability expression.
The invariant
```
m = decondition(condition(m, obs))
```
should hold for generative models `m` and arbitrary `obs`.
"""
function condition end