-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Description
In this issue, I propose the creation of a new macro @logprob to query Turing models as well as the sampled posterior. Let's take the following model as an example using the syntax of #965:
@model demo(x, y) = begin
a ~ Normal()
b ~ Gamma()
y .~ Normal.(a .* x, b)
end
model = demo(rand(100), rand(100))
chain = sample(model, NUTS(10, 0.65), 10000)I propose the following syntax:
@logprob a = 1.0, b = 2.0 | model = model-> returns log the prior@logprob a = 1.0, b = 2.0, x = rand(100), y = rand(100) | model = model-> returns log the joint probability@logprob 0.2 <= a <= 0.3, 1.0 <= b <= 1.1 | model = model, chain = chain-> returns log the ratio of the number of samples inchainwith0.2 <= a <= 0.3, 1.0 <= b <= 1.1. For discrete distributions, we can also usea = 2ora == 2for example. Passingmodelhere can be optional.@logprob x = rand(10), y = rand(10) | model = model, chain = chainreturns the log likelihood ofx = rand(10), y = rand(10)for each sample inchain@logprob x = rand(10), y = rand(10) | model = model, a = 1.0, b = 2.0returns the log likelihood ofx = rand(10), y = rand(10)usinga = 1.0, b = 2.0.
Let me know if you have comments on the syntax or if I missed any use case.
Metadata
Metadata
Assignees
Labels
No labels