Skip to content

Commit

Permalink
Add documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ztangent committed Oct 21, 2024
1 parent 1146ca0 commit 358d3e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pages = [
"Custom Generative Functions" => "ref/modeling/custom_gen_fns.md",
],
"Inference Library" => [
"Enumerative Inference" => "ref/inference/enumerative.md",
"Importance Sampling" => "ref/inference/importance.md",
"Markov Chain Monte Carlo" => "ref/inference/mcmc.md",
"Particle Filtering & SMC" => "ref/inference/pf.md",
Expand Down
18 changes: 18 additions & 0 deletions docs/src/ref/inference/enumerative.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Enumerative Inference

Enumerative inference can be used to compute the exact posterior distribution for a generative model
with a finite number of discrete random choices, to compute a grid approximation of a continuous
posterior density, or to perform stratified sampling by enumerating over discrete random choices and sampling
the continuous random choices. This functionality is provided by [`enumerative_inference`](@ref).

```@docs
enumerative_inference
```

To construct a rectangular grid of [choice maps](../core/choice_maps.md) and their associated log-volumes to iterate over, use the [`choice_vol_grid`](@ref) function.

```@docs
choice_vol_grid
```

When the space of possible choice maps is not rectangular (e.g. some addresses only exist depending on the values of other addresses), iterators over choice maps and log-volumes can be also be manually constructed.
4 changes: 3 additions & 1 deletion src/inference/enumerative.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Also return an estimate of the log marginal likelihood of the observations (`lml
All addresses in the `observations` choice map must be sampled by the model when
given the model arguments. The same constraint applies to choice maps enumerated
over by `choice_vol_iter`, which must also avoid sharing addresses with the
`observations`.
`observations`. When the choice maps in `choice_vol_iter` do not fully specify
the values of all unobserved random choices, the unspecified choices are sampled
from the internal proposal distribution of the model.
"""
function enumerative_inference(
model::GenerativeFunction{T,U}, model_args::Tuple,
Expand Down

0 comments on commit 358d3e4

Please sign in to comment.