From 3aee5a1b0058b08e8f8a4efa38fa701c87696e4f Mon Sep 17 00:00:00 2001 From: Kyurae Kim Date: Wed, 29 May 2024 02:18:35 -0400 Subject: [PATCH] add warning about Turing's support transformation --- docs/src/gibbs_polar.md | 3 +-- src/gibbspolar.jl | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/src/gibbs_polar.md b/docs/src/gibbs_polar.md index b133b0e..2c9a4d8 100644 --- a/docs/src/gibbs_polar.md +++ b/docs/src/gibbs_polar.md @@ -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 diff --git a/src/gibbspolar.jl b/src/gibbspolar.jl index b70f953..6dac69b 100644 --- a/src/gibbspolar.jl +++ b/src/gibbspolar.jl @@ -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)