Skip to content

Commit 8c3aa44

Browse files
bgctwtorfjelde
andauthored
Pointpriors (#663)
* implement pointwise_logpriors * implement varwise_logpriors * remove pointwise_logpriors * revert dot_assume to not explicitly resolve components of sum * docstring varwise_logpriores use loop for prior in example Unfortunately cannot make it a jldoctest, because relies on Turing for sampling * integrate pointwise_loglikelihoods and varwise_logpriors by pointwise_densities * record single prior components by forwarding dot_tilde_assume to tilde_assume * forward dot_tilde_assume to tilde_assume for Multivariate * avoid recording prior components on leaf-prior-context and avoid recording likelihoods when invoked with leaf-Likelihood context * undeprecate pointwise_loglikelihoods and implement pointwise_prior_logdensities mostly taken from #669 * drop vi instead of re-compute vi bgctw first forwared dot_tilde_assume to get a correct vi and then recomputed it for recording component prior densities. Replaced this by the Hack of torfjelde that completely drops vi and recombines the value, so that assume is called only once for each varName, * include docstrings of pointwise_logdensities pointwise_prior_logdensities int api.md docu * Update src/pointwise_logdensities.jl remove commented code Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Update src/pointwise_logdensities.jl remove commented code Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Update test/pointwise_logdensities.jl rename m to model Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Update test/pointwise_logdensities.jl remove unused code Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Update test/pointwise_logdensities.jl rename m to model Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Update test/pointwise_logdensities.jl rename m to model Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Update src/test_utils.jl remove old code Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * rename m to model * JuliaFormatter * Update test/runtests.jl remove interactive code Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * remove demo_dot_assume_matrix_dot_observe_matrix2 testcase testing higher dimensions better left for other PR * ignore local interactive development code * ignore temporary directory holding local interactive development code * Apply suggestions from code review: clean up comments and Imports Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * Apply suggestions from code review: change test of applying to chains on already used model Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> * fix test on names in likelihood components to work with literal models * try to fix testset pointwise_logdensities chain * Update test/pointwise_logdensities.jl * Update .gitignore * Formtating * Fixed tests * Updated docs for `pointwise_logdensities` + made it a doctest not dependent on Turing.jl * Bump patch version * Remove blank line from `@model` in doctest to see if that fixes the parsing issues * Added doctest filter to handle the `;;]` at the end of lines for matrices --------- Co-authored-by: Tor Erlend Fjelde <tor.github@gmail.com> Co-authored-by: Tor Erlend Fjelde <tor.erlend95@gmail.com>
1 parent 067ac4c commit 8c3aa44

File tree

10 files changed

+553
-287
lines changed

10 files changed

+553
-287
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "DynamicPPL"
22
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
3-
version = "0.29.1"
3+
version = "0.29.2"
44

55
[deps]
66
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

docs/src/api.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ Return values of the model function for a collection of samples can be obtained
124124
generated_quantities
125125
```
126126

127-
For a chain of samples, one can compute the pointwise log-likelihoods of each observed random variable with [`pointwise_loglikelihoods`](@ref).
127+
For a chain of samples, one can compute the pointwise log-likelihoods of each observed random variable with [`pointwise_loglikelihoods`](@ref). Similarly, the log-densities of the priors using
128+
[`pointwise_prior_logdensities`](@ref) or both, i.e. all variables, using
129+
[`pointwise_logdensities`](@ref).
128130

129131
```@docs
132+
pointwise_logdensities
130133
pointwise_loglikelihoods
134+
pointwise_prior_logdensities
131135
```
132136

133137
For converting a chain into a format that can more easily be fed into a `Model` again, for example using `condition`, you can use [`value_iterator_from_chain`](@ref).

src/DynamicPPL.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export AbstractVarInfo,
115115
# Convenience functions
116116
logprior,
117117
logjoint,
118+
pointwise_prior_logdensities,
119+
pointwise_logdensities,
118120
pointwise_loglikelihoods,
119121
condition,
120122
decondition,
@@ -181,7 +183,7 @@ include("varinfo.jl")
181183
include("simple_varinfo.jl")
182184
include("context_implementations.jl")
183185
include("compiler.jl")
184-
include("loglikelihoods.jl")
186+
include("pointwise_logdensities.jl")
185187
include("submodel_macro.jl")
186188
include("test_utils.jl")
187189
include("transforming.jl")

src/loglikelihoods.jl

Lines changed: 0 additions & 257 deletions
This file was deleted.

0 commit comments

Comments
 (0)