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

Disable sampling of transformed variables from prior_predictive #5076

Closed
ricardoV94 opened this issue Oct 14, 2021 · 5 comments · Fixed by #6309
Closed

Disable sampling of transformed variables from prior_predictive #5076

ricardoV94 opened this issue Oct 14, 2021 · 5 comments · Fixed by #6309

Comments

@ricardoV94
Copy link
Member

This was added to facilitate sampling from the prior as a starting point for SMC, but with the new functions added in #4983 this is no longer needed.

pymc/pymc3/sampling.py

Lines 1983 to 1999 in 6d2aa5d

# Any variables from var_names that are missing must be transformed variables.
# Misspelled variables would have raised a KeyError above.
missing_names = vars_.difference(names)
for name in missing_names:
transformed_value_var = model[name]
rv_var = model.values_to_rvs[transformed_value_var]
transform = transformed_value_var.tag.transform
transformed_rv_var = transform.forward(rv_var, rv_var)
names.append(name)
vars_to_sample.append(transformed_rv_var)
# If the user asked for the transformed variable in var_names, but not the
# original RV, we add it manually here
if rv_var.name not in names:
names.append(rv_var.name)
vars_to_sample.append(rv_var)

@markvrma
Copy link
Contributor

I'd like to take up this issue.

@purna135
Copy link
Member

purna135 commented Mar 2, 2022

Is it okay if I work on this?

@markvrma markvrma removed their assignment Mar 2, 2022
@ricardoV94
Copy link
Member Author

Is it okay if I work on this?

Sure

@purna135
Copy link
Member

I need some assistance in replacing the following code with make_initial_point_fn

pymc/pymc/smc/smc.py

Lines 179 to 184 in e6fc2ec

return sample_prior_predictive(
self.draws,
var_names=[v.name for v in self.model.unobserved_value_vars],
model=self.model,
return_inferencedata=False,
)

def make_initial_point_fn(

@ricardoV94
Copy link
Member Author

You will have to change the parameters of make_initial_point_fn so that it is returning draws from the transformed prior. You can do that by setting the overrides dictionary so that every value variable strategy is "prior", and also switching the default from "moment" to "prior". Then you will need to make sure you call the returned function with a different seed self.draws times.

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