MCMCChains.jl icon indicating copy to clipboard operation
MCMCChains.jl copied to clipboard

Changing Internal Representation to `StructArray` or `TupleVector`?

Open ParadaCarleton opened this issue 3 years ago • 3 comments

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.

ParadaCarleton avatar Nov 19 '21 16:11 ParadaCarleton

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.

devmotion avatar Nov 19 '21 17:11 devmotion

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?

ParadaCarleton avatar Nov 19 '21 19:11 ParadaCarleton

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.

devmotion avatar Nov 19 '21 20:11 devmotion