Skip to content

Commit

Permalink
add warning about Turing's support transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Portal committed May 29, 2024
1 parent e3066be commit 3aee5a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions docs/src/gibbs_polar.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ The only tunable parameter of the algorithm is the size of the search interval (
By the nature of polar coordinates, GPSS only works reliably for targets with dimension at least $$d \geq 2$$.

!!! warning
When initializing the chain (*e.g.* the `initial_params` keyword arguments in `AbstractMCMC.sample`), it is necessary to inialize from a point $$x_0$$ that has a sensible norm $$\lVert x_0 \rVert > 0$$, otherwise, the chain will start from a pathologic point in polar coordinates. This might even result in the sampler getting stuck in an infinite loop. (This can be prevented by setting `max_proposals`.) If $$\lVert x_0 \rVert \leq 10^{-5}$$, the current implementation will display a warning.

When initializing the chain (*e.g.* the `initial_params` keyword arguments in `AbstractMCMC.sample`), it is necessary to inialize from a point $$x_0$$ that has a sensible norm $$\lVert x_0 \rVert > 0$$, otherwise, the chain will start from a pathologic point in polar coordinates. This might even result in the sampler getting stuck in an infinite loop. (This can be prevented by setting `max_proposals`.) If $$\lVert x_0 \rVert \leq 10^{-5}$$, the current implementation will display a warning. Note that, `Turing` often changes `initial_params` to match the support constraints. This might lead to $$\lVert x_0 \rVert$$ being small, even though the vector you passed to`initial_params` has a sufficiently large norm.

```@docs
GibbsPolarSlice
Expand Down
2 changes: 1 addition & 1 deletion src/gibbspolar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function AbstractMCMC.step(rng ::Random.AbstractRNG,
@assert d 2 "Gibbsian polar slice sampling works reliably only in dimension ≥2"
r = norm(x)
if r < 1e-5
@warn "The norm of initial_params is smaller than 1e-5, which might be result in unstable behavior and the sampler might even get stuck indefinitely."
@warn "The norm of initial_params is smaller than 1e-5, which might be result in unstable behavior and the sampler might even get stuck indefinitely. If you are using Turing, this might be due to change of support through Bijectors."
end
θ = x / r
ℓp = LogDensityProblems.logdensity(logdensitymodel, x)
Expand Down

0 comments on commit 3aee5a1

Please sign in to comment.