Skip to content

Commit

Permalink
Pointpriors (#663)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update src/pointwise_logdensities.jl remove commented code

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* Update test/pointwise_logdensities.jl rename m to model

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* Update test/pointwise_logdensities.jl remove unused code

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* Update test/pointwise_logdensities.jl rename m to model

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* Update test/pointwise_logdensities.jl rename m to model

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* Update src/test_utils.jl remove old code

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* rename m to model

* JuliaFormatter

* Update test/runtests.jl remove interactive code

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* 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 <[email protected]>

* Apply suggestions from code review: change test of applying to chains on already used model

Co-authored-by: Tor Erlend Fjelde <[email protected]>

* 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 <[email protected]>
Co-authored-by: Tor Erlend Fjelde <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2024
1 parent 067ac4c commit 8c3aa44
Show file tree
Hide file tree
Showing 10 changed files with 553 additions and 287 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DynamicPPL"
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
version = "0.29.1"
version = "0.29.2"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
6 changes: 5 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ Return values of the model function for a collection of samples can be obtained
generated_quantities
```

For a chain of samples, one can compute the pointwise log-likelihoods of each observed random variable with [`pointwise_loglikelihoods`](@ref).
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
[`pointwise_prior_logdensities`](@ref) or both, i.e. all variables, using
[`pointwise_logdensities`](@ref).

```@docs
pointwise_logdensities
pointwise_loglikelihoods
pointwise_prior_logdensities
```

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).
Expand Down
4 changes: 3 additions & 1 deletion src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export AbstractVarInfo,
# Convenience functions
logprior,
logjoint,
pointwise_prior_logdensities,
pointwise_logdensities,
pointwise_loglikelihoods,
condition,
decondition,
Expand Down Expand Up @@ -181,7 +183,7 @@ include("varinfo.jl")
include("simple_varinfo.jl")
include("context_implementations.jl")
include("compiler.jl")
include("loglikelihoods.jl")
include("pointwise_logdensities.jl")
include("submodel_macro.jl")
include("test_utils.jl")
include("transforming.jl")
Expand Down
257 changes: 0 additions & 257 deletions src/loglikelihoods.jl

This file was deleted.

Loading

0 comments on commit 8c3aa44

Please sign in to comment.