MCMCChains.jl
MCMCChains.jl copied to clipboard
Changing Internal Representation to `StructArray` or `TupleVector`?
Separately from #336, which would solve our AxisArray-related issues, there's the question of what data structure we want to use internally to deal with the issues caused by using regular arrays, most notably enforcing Float64 as the datatype for everything and having to deal with grouped parameters manually.
Ideally we would allow to use matrices/3d arrays (current setup) as well as StructArrays (as discussed in some of the issues or PRs IIRC). Both have their advantages and disadvantages for different use cases.
Ideally we would allow to use matrices/3d arrays (current setup) as well as StructArrays (as discussed in some of the issues or PRs IIRC). Both have their advantages and disadvantages for different use cases.
What advantages does a regular 3d array have?
Among other things, it is simple, memory-efficient, supported by base and does not require any external packages, easy to manipulate, easy to save, supported by many other (Bayesian) analysis tools, and additionally sufficient for many applications (e.g., often all types are (or at least can be converted to) Float64 and there are no missing draws, and variables are scalar or can be flattened in a straightforward way). Nevertheless, 3d arrays have their limitations and disadvantages, e.g., they require a common element type (annoying e.g. when working with discrete data), can't deal with non-array variates, and it is a bit annoying to reconstruct the original data from the flattened version.