Skip to content

Commit

Permalink
add DynamicPPL.@addlogprob! to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdfish committed Feb 21, 2024
1 parent 764af10 commit bc4bec3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/src/input-turing.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ Both real and integer-valued random variables are supported.
For a [`TuringLogPotential`](@ref), the [`default_explorer()`](@ref) is the [`SliceSampler`](@ref) and the [`default_reference()`](@ref) is the
prior distribution encoded in the Turing model.

### Using DynamicPPL.@addlogprob!

The macro `DynamicPPL.@addlogprob!` is sometimes used when additional flexibility is needed while incrementing the log probability. To do so with Pigeons.jl, you will need to enclose the call to `DynamicPPL.@addlogprob!` within an if statement as shown below. Failing to do so will lead to invalid results.

```julia
DynamicPPL.@model function my_turing_model(my_data)
# code here
if DynamicPPL.leafcontext(__context__) !== DynamicPPL.PriorContext()
DynamicPPL.@addlogprob! logpdf(MyDist(parms), my_data)
end
end
```

## Manipulating the output

Expand Down

0 comments on commit bc4bec3

Please sign in to comment.