Skip to content

Instantly share code, notes, and snippets.

@xukai92
Last active June 26, 2020 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xukai92/528dd7bd828e1a7437af6d62110664ab to your computer and use it in GitHub Desktop.
Save xukai92/528dd7bd828e1a7437af6d62110664ab to your computer and use it in GitHub Desktop.
Generated quantiles with Turing.jl
# Modifed from https://github.com/cambridge-mlg/Covid19/blob/master/src/utils.jl#L79
function generated_quantities(m::Turing.Model, c::MCMCChains.Chains)
# If `c` is multiple chains, we convert them into a single chain
chain = length(chains(c)) == 1 ? c : MCMCChains.pool_chain(c)
vi = Turing.DynamicPPL.VarInfo(m)
return map(1:length(chain)) do i
Turing.DynamicPPL._setval!(vi, chain[i])
m(vi)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment