Fun Shapes: Ring
An annulus keeps the hole of the Hollow Square but trades its straight edges for a smooth curve, and makes the obstruction radially symmetric so that any bias it induces is easy to spot in the output. As with the rest of the Fun Shapes group, described on the Circle page, there is no data and nothing to estimate. Both coordinates are uniform on the square $[-1, 1]^2$, and two Bernoulli nodes bound the radius from either side. O1 is fixed to 0 with constraint1 = step(x * x + y * y - 1), which requires $x^2 + y^2 < 1$, and O2 is fixed to 1 with constraint2 = step(x * x + y * y - 0.25), which requires $x^2 + y^2 \ge 0.25$. What is left is the ring between radius $0.5$ and radius $1$.
\[\{(x, y) \; : \; 0.25 \le x^2 + y^2 < 1\}\]
The ring is connected, so every part of it is in principle reachable, but it is not simply connected and the route from one side to the other has to go around the central hole rather than through it. Component-wise updating feels the hole directly: for $|x| < 0.5$ the conditional distribution of $y$ splits into two separate intervals, one above the hole and one below, and a single-site update cannot cross from one to the other in a single move. Because the target is radially symmetric, any imbalance between opposite parts of the ring in the output is a sign that the chain has been stuck. The bundled initial values start at $(0.6, 0.6)$, a radius of about $0.85$, inside the ring. The original write-up is on the MultiBUGS Volume III examples page.
The model definition, data, initial values, and published reference results shown here all come from JuliaBUGS.BUGSExamples.VOLUME_3.ring, which ships with the package.
Model
using JuliaBUGS
example = JuliaBUGS.BUGSExamples.VOLUME_3.ring
example.model_defquote
x ~ dunif(-1, 1)
y ~ dunif(-1, 1)
O1 = 0
O1 ~ dbern(constraint1)
constraint1 = _step((x * x + y * y) - 1)
O2 = 1
O2 ~ dbern(constraint2)
constraint2 = _step((x * x + y * y) - 0.25)
endThe program as it appears in the original BUGS distribution:
print(example.original_syntax_program)model
{
x ~ dunif(-1, 1)
y ~ dunif(-1, 1)
O1 <- 0
O1 ~ dbern(constraint1)
constraint1 <- step(x * x + y * y - 1)
O2 <- 1
O2 ~ dbern(constraint2)
constraint2 <- step( x * x + y * y - 0.25)
}Compiling the model
model = JuliaBUGS.compile(example.model_def, example.data, example.inits)BUGSModel (parameters are in transformed (unconstrained) space, with dimension 2):
Model parameters:
y
x
Variable sizes and types:
constraint2: type = Float64
O2: type = Int64
y: type = Float64
O1: type = Int64
constraint1: type = Float64
x: type = Float64
The example's own initial values are passed in here. Several of these models fail from random starting values, so example.inits is not optional in practice; a second set is available as example.inits_alternative.
See Getting Started for the recipe that takes a compiled model to posterior samples.