Skip to content

Instantly share code, notes, and snippets.

@xukai92
Last active June 26, 2020 23:30
Show Gist options
  • 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