I made a probabilistic model that attempts to infer the center coordinates (h, k) and radius (R) of a circle given a number of points that were sampled from the circle, but when I try to query probabilities, I always get 1.0. Here’s a MWE:
@model function circle(xs, ys)
R ~ truncated(Normal(5, 0.1), 0, Inf)
h ~ Normal(0, 1)
k ~ Normal(0, 1)
σ = 0.01
for i in eachindex(xs)
θ = atan(ys[i] - k, xs[i] - h)
xs[i] ~ Normal(h + R * cos(θ), σ)
ys[i] ~ Normal(k + R * sin(θ), σ)
end
end
# Generate some data from a circle
R, h, k = 5., 0.1, 0.
n_samples = 30
xs = Vector(undef, n_samples)
ys = Vector(undef, n_samples)
for i in eachindex(xs)
θ = rand(Uniform(-π, +π))
xs[i] = h + R * cos(θ)
ys[i] = k + R * sin(θ)
end
model = circle(xs, ys)
println(prob"R = 4 | model = model, xs = xs, ys = ys, h = h, k = k") # out: 1.0
println(prob"R = 5 | model = model, xs = xs, ys = ys, h = h, k = k") # out: 1.0
println(prob"R = 6 | model = model, xs = xs, ys = ys, h = h, k = k") # out: 1.0
Have I set up my model improperly or something? Does anyone know how to get around this? Thanks.