CliMA / CliMA/CalibrateEmulateSample.jl
Add method to get posterior samples from the posterior chains more easily
- Dominant language
- Julia
- Stars
- 90
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
For plotting one often wishes to just have an array, rather than the chains object in the posterior. It would be good to pull this out more conveniently
## Current implementation
```julia
# given: posterior = get_posterior(mcmc, chain)
posterior_samples = vcat([get_distribution(posterior)[name] for name in get_name(posterior)]...) #samples are columns
constrained_posterior_samples =
mapslices(x -> transform_unconstrained_to_constrained(posterior, x), posterior_samples, dims = 1)
```
## Solution:
Firstly, we don't need mapslices as
```julia
transform_unconstrained_to_constrained(posterior, posterior_samples)
```
should work? see [here](https://github.com/CliMA/EnsembleKalmanProcesses.jl/blob/8c360eaded50b56cad7e6ebf1fa954fefd04b2c0/src/ParameterDistributions.jl#L865)
Perhaps we can just wrap the first part up like:
```julia
posterior_samples = get_posterior(mcmc, chain, dist_or_array="array") # add to CES.jl?
# or
posterior_sampels = get_samples_as_array(posterior)
```
PS we should also avoid `vcat(X...)` where possible
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.