Skip to content

Commit 4530247

Browse files
mhauruAoife
authored andcommitted
Fix use of addlogprob for log prior
1 parent e7519c9 commit 4530247

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

usage/modifying-logprob/index.qmd

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,10 @@ using LinearAlgebra
4747
end
4848
```
4949

50-
Note that `@addlogprob!` always increases the accumulated log probability, regardless of the provided
51-
sampling context.
52-
For instance, if you do not want to apply `@addlogprob!` when evaluating the prior of your model but only when computing the log likelihood and the log joint probability, then you should [check the type of the internal variable `__context_`](https://github.com/TuringLang/DynamicPPL.jl/issues/154), as in the following example:
50+
Note that `@addlogprob!` increases the accumulated log likelihood.
51+
If instead you want to add to the log prior, you can use
5352

5453
```{julia}
5554
#| eval: false
56-
if DynamicPPL.leafcontext(__context__) !== Turing.PriorContext()
57-
@addlogprob! myloglikelihood(x, μ)
58-
end
55+
@addlogprob! (; logprior=value_goes_here)
5956
```

0 commit comments

Comments
 (0)