-
Notifications
You must be signed in to change notification settings - Fork 228
Closed
Labels
Description
Minimal working example
using DynamicPPL
# Create the model function.
function gdemo2(model, varinfo, context, x)
# Assume s² has an InverseGamma distribution.
s², varinfo = DynamicPPL.tilde_assume!!(
context, InverseGamma(2, 3), @varname(s²), varinfo
)
# Assume m has a Normal distribution.
m, varinfo = DynamicPPL.tilde_assume!!(
context, Normal(0, sqrt(s²)), @varname(m), varinfo
)
# Observe each value of x[i] according to a Normal distribution.
for i in eachindex(x)
_retval, varinfo = DynamicPPL.tilde_observe!!(
context, Normal(m, sqrt(s²)), x[i], @varname(x[i]), varinfo
)
end
# The final return statement should comprise both the original return
# value and the updated varinfo.
return nothing, varinfo
end
gdemo2(x) = DynamicPPL.Model(gdemo2, (; x))
# Instantiate a Model object with our data variables.
model2 = gdemo2([1.5, 2.0])
# Errors
chain = sample(model2, NUTS(), 1000; progress=false)
Description
Hey there, just trying to execute the code provided in https://turinglang.org/docs/developers/compiler/model-manual/ errors.
As a side note, it would be nice to
- Briefly explain what
model
is - Why do we need to provide a named tuple to
DynamicPPL.Model
, sincegdemo2
is defined with positional arguments?
Julia version info
versioninfo()
(Paste here)
Manifest
]st --manifest
(Paste here)