Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to get posterior samples from the posterior chains more easily #260

Open
odunbar opened this issue Nov 27, 2023 · 0 comments
Open

Comments

@odunbar
Copy link
Collaborator

odunbar commented Nov 27, 2023

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

# 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

transform_unconstrained_to_constrained(posterior, posterior_samples)

should work? see here

Perhaps we can just wrap the first part up like:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant