diff --git a/docs/pages.jl b/docs/pages.jl index 0f5b89b1..3a096203 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -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", diff --git a/docs/src/ref/inference/enumerative.md b/docs/src/ref/inference/enumerative.md new file mode 100644 index 00000000..c9e95b83 --- /dev/null +++ b/docs/src/ref/inference/enumerative.md @@ -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. diff --git a/src/inference/enumerative.jl b/src/inference/enumerative.jl index f2d0a7c1..5e24690f 100644 --- a/src/inference/enumerative.jl +++ b/src/inference/enumerative.jl @@ -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,