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

Transforming samples requires application to dicts #248

Closed
odunbar opened this issue Jan 26, 2023 · 0 comments · Fixed by #249
Closed

Transforming samples requires application to dicts #248

odunbar opened this issue Jan 26, 2023 · 0 comments · Fixed by #249
Assignees

Comments

@odunbar
Copy link
Collaborator

odunbar commented Jan 26, 2023

Issue

We should add the functionality to transform parameter dicts, not just arrays. This should be straightforward as we must use the prior to perform the transform, and the prior also contains the parameter names.

Example setting:
Currently, to transform samples from a Samples distribution, we must convert it into an array first with the correct ordering

# S, Samples distribution (e.g. a posterior), 
# P, distribution (e.g. a prior with same parameter names)
samples_dict = get_distribution(S)
param_names = get_name(S)
samples_arr = zeros(sum([size(samples_dict[n],1) for n in param_names]), size(samples_dict[param_names[1]],2))
for (i,k) in enumerate(param_names)
        samples_arr[i,:] = samples_dict[k]
end
constrained_samples = transform_unconstrained_to_constrained(priors, samples_arr)

Suggested solution

This is what we would want to transform samples from a Samples distribution

# S, Samples distribution (e.g. a posterior), 
# P, distribution (e.g. a prior with same parameter names)
samples_dict = get_distribution(S) #a Dict(param_name => samples_for_name)
constrained_samples_dict = transform_unconstrained_to_constrained(samples_dict)

Which can be done by adding the code snippet into functions transform_constrained_to_unconstrained(pd::ParameterDistribution, d::Dict), transform_unconstrained_to_constrained(pd::ParameterDistribution, d::Dict) into ParameterDistributions.jl

@odunbar odunbar self-assigned this Jan 26, 2023
@bors bors bot closed this as completed in 26306e5 Feb 3, 2023
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

Successfully merging a pull request may close this issue.

1 participant