Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5d5bc88
added example_values and posterior_mean_values methods to models in T…
torfjelde Jun 30, 2022
0498336
demo models in TestUtils are now a bit more complex, including constr…
torfjelde Jun 30, 2022
f86f264
added logprior_true_with_logabsdet_jacobian for demo models
torfjelde Jul 1, 2022
0d31137
fixed mistakes in a couple of models in TestUtils
torfjelde Jul 1, 2022
c52630b
moved varnames method which creates iterator of leaf varnames into Te…
torfjelde Jul 1, 2022
fff060c
updated docstring for test_sampler_demo_models
torfjelde Jul 1, 2022
e21958c
renamed varnames to varname_leaves and renamed keys(model) to varname…
torfjelde Jul 1, 2022
9669345
added test_sampler_on_models as a generalization of test_sampler_demo…
torfjelde Jul 1, 2022
7e02735
updated docs
torfjelde Jul 1, 2022
a412029
added docs for TestUtils.DEMO_MODELS
torfjelde Jul 1, 2022
f3818c3
updated some tests
torfjelde Jul 1, 2022
8b799a4
fixed docstrings
torfjelde Jul 1, 2022
93cb298
fixed docstrings
torfjelde Jul 1, 2022
ba5852b
imprvoed docstring
torfjelde Jul 1, 2022
328f713
improved docstrings
torfjelde Jul 1, 2022
8b6b440
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 1, 2022
5843699
fixed tests of pointwise_loglikelihoods
torfjelde Jul 1, 2022
0b20f09
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 1, 2022
2b1893c
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 1, 2022
912d7f8
Apply suggestions from code review
torfjelde Jul 2, 2022
a276e4a
renamed posterior_mean_values to posterior_mean
torfjelde Jul 2, 2022
626eea2
made demo models a bit more complex, now including different observat…
torfjelde Jul 2, 2022
1558924
Update docs/src/api.md
torfjelde Jul 2, 2022
a62c881
reduce number of method definitions by defining some useful type unio…
torfjelde Jul 2, 2022
5cc195a
removed unnecessary method
torfjelde Jul 2, 2022
ea5a7a4
Merge branch 'tor/test-utils-improvements' of github.com:TuringLang/D…
torfjelde Jul 2, 2022
702f2ff
fixed a couple of loglikelihood_true definitions
torfjelde Jul 2, 2022
d8f4970
style
torfjelde Jul 2, 2022
56f30bc
added tests for logprior and loglikelihood computation for SimpleVarInfo
torfjelde Jul 2, 2022
2eaef02
fixed implementation of logpdf_with_trans for NoDist
torfjelde Jul 2, 2022
8063d1e
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 2, 2022
2935bde
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 2, 2022
78f22e1
removed unused variable
torfjelde Jul 3, 2022
025a4d4
added test for transformed values for the logprior_true and loglikeli…
torfjelde Jul 3, 2022
a72e9b8
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 3, 2022
c057080
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 3, 2022
f5c60ae
renamed test_sampler_on_models to test_sampler
torfjelde Jul 3, 2022
7149c02
Merge branch 'tor/link-improvements' into tor/test-utils-improvements
torfjelde Jul 3, 2022
25f05de
updated docs
torfjelde Jul 3, 2022
e05fa29
share implementation of example_values
torfjelde Jul 3, 2022
431664d
Apply suggestions from code review
torfjelde Jul 4, 2022
b3499a3
added marginal_mean_of_samples according to suggestions
torfjelde Jul 12, 2022
2bd5dcd
removed example_values in favour of rand with NamedTuple
torfjelde Jul 13, 2022
61a594c
updated docs
torfjelde Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ NamedDist
DynamicPPL provides several demo models and helpers for testing samplers in the `DynamicPPL.TestUtils` submodule.

```@docs
DynamicPPL.TestUtils.test_sampler_demo_models
DynamicPPL.TestUtils.test_sampler
DynamicPPL.TestUtils.test_sampler_on_demo_models
DynamicPPL.TestUtils.test_sampler_continuous
DynamicPPL.TestUtils.marginal_mean_of_samples
```

```@docs
DynamicPPL.TestUtils.DEMO_MODELS
```

For every demo model, one can define the true log prior, log likelihood, and log joint probabilities.
Expand All @@ -115,6 +121,20 @@ DynamicPPL.TestUtils.loglikelihood_true
DynamicPPL.TestUtils.logjoint_true
```

And in the case where the model includes constrained variables, it can also be useful to define

```@docs
DynamicPPL.TestUtils.logprior_true_with_logabsdet_jacobian
DynamicPPL.TestUtils.logjoint_true_with_logabsdet_jacobian
```

Finally, the following methods can also be of use:

```@docs
DynamicPPL.TestUtils.varnames
DynamicPPL.TestUtils.posterior_mean
```

## Advanced

### Variable names
Expand Down
20 changes: 16 additions & 4 deletions src/distribution_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,21 @@ Distributions.logpdf(d::NoDist{<:Matrixvariate}, ::AbstractMatrix{<:Real}) = 0
Distributions.minimum(d::NoDist) = minimum(d.dist)
Distributions.maximum(d::NoDist) = maximum(d.dist)

Bijectors.logpdf_with_trans(d::NoDist{<:Univariate}, ::Real) = 0
Bijectors.logpdf_with_trans(d::NoDist{<:Multivariate}, ::AbstractVector{<:Real}) = 0
function Bijectors.logpdf_with_trans(d::NoDist{<:Multivariate}, x::AbstractMatrix{<:Real})
Bijectors.logpdf_with_trans(d::NoDist{<:Univariate}, ::Real, ::Bool) = 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that currently on #master anything involving NoDist + linked VarInfo is producing incorrect results (which, AFIAK, we were unaware of) 🙃

function Bijectors.logpdf_with_trans(
d::NoDist{<:Multivariate}, ::AbstractVector{<:Real}, ::Bool
)
return 0
end
function Bijectors.logpdf_with_trans(
d::NoDist{<:Multivariate}, x::AbstractMatrix{<:Real}, ::Bool
)
return zeros(Int, size(x, 2))
end
Bijectors.logpdf_with_trans(d::NoDist{<:Matrixvariate}, ::AbstractMatrix{<:Real}) = 0
function Bijectors.logpdf_with_trans(
d::NoDist{<:Matrixvariate}, ::AbstractMatrix{<:Real}, ::Bool
)
return 0
end

Bijectors.bijector(d::NoDist) = Bijectors.bijector(d.dist)
Loading