Finding that I am writing a lot of repetitive code, I am trying to rethink the way I work with posterior distributions (eg from MCMC).

I can typically reduce most operations on posteriors to *transformations*, which operate on a particular draw from the posterior, and *elementwise* operations, eg calculating means and quantiles for various, potentially nested containers, eg an upper-triangular matrix

For transformations, the best container type is an `AbstractVector{T}`

or similar, where `T`

can be a `struct`

or a `NamedTuple`

of various scalars, arrays, etc; transforming to something similar (or a `Tuple`

) one draw at a time. This is easy to program and iterate. Typical examples would be posterior predictive checks, transformed parameters, and summary statistics (eg RMSE and equivalents).

On the other hand, elementwise operations typically work best on something `AbstractMatrix`

-like, where one can map columns using `eachcol`

or `mapslices`

.

One typically wants to convert from one representation to another multiple times.

I am curious how other Julia users approach this, and what existing libraries would be recommended. Packages with somewhat similar (but not identical) goals that I am aware of include