Open sethaxen opened 4 years ago
Yeah, this is really tricky. Long-term, I think most MCMC should be iterable. I don't really understand the ArviZ setup yet (Colin Carroll pointed to them on Twitter), but something like this seems sensible to me:
result = (
samples = ...,
diagnostics = (
per_chain = ...,
per_sample = ...
)
)
Here samples
and per_sample
are iterators, while per_chain
is "global" (not tied to any particular sample). I'm assuming diagnostics will change (maybe a lot) depending on the sampler.
The problem with this is getting other libraries into this form.
Yeah, this is really tricky. Long-term, I think most MCMC should be iterable. Yes I don't currently see much of an issue with this in Julia. One can always wrap an iterator with a method that allocates an array and fills it by taking a fixed number from the iterator.
I don't really understand the ArviZ setup yet (Colin Carroll pointed to them on Twitter), but something like this seems sensible to me:
That looks sensible to me. diagnostics
should probably be something more general. ArviZ uses sample_statistics
which I like for its generality. In most cases though, per_sample
and sample
should be synchronized. How would that work here?
How would warm-up (e.g. for HMC) fit into this scheme? Would samples only be returned after warm-up?
What format would samples
be? Named tuples? Arrays? Or something else?
While reviewing #103, I saw a few things we can improve to standardize
advancedHMC
anddynamicHMC
.I'll demo with the example in
README.md
:Now sample the posteriors with DynamicHMC.jl and AdvancedHMC.jl:
Note the deprecation warning for
StanHMCAdaptor
. Now we examine the returned types:While
dynamicHMC
gives us named tuples but no stats,advancedHMC
gives us a tuple, the first element being an array with no variable names, and the second being the stats.A few proposed changes:
advancedHMC
, we should fix the deprecation.dynamicHMC
(i.e. named tuples).dynamicHMC
could adopt a similar format, returning all available stats in named tuples as well if the user requests it.