Add sample.posterior.resimulate flag for posterior predictive checks#72
Open
oleg-savchenko wants to merge 1 commit into
Open
Add sample.posterior.resimulate flag for posterior predictive checks#72oleg-savchenko wants to merge 1 commit into
oleg-savchenko wants to merge 1 commit into
Conversation
After sample_posterior(), only latent (estimator) node values are saved by default. When resimulate: true, this commit runs each posterior sample through the forward model and saves all node values together, enabling posterior predictive checks without a separate script. New DeployedGraph.resimulate_posterior() method encapsulates the pattern already used inline in the adaptive training loop. Called from both sample_mode() (falcon sample posterior) and launch_mode() (end-of-training posterior sampling). _save_samples() default key selection extended to cover all nodes when resimulate=True. Default behaviour (resimulate: false) is unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
|
I suspect this is now obsolete give that you can use 'sample ppd'. The advantage of not mixing posterior and ppd sample paths is that often one might want to have many more (cheap) posterior samples than (expensive) ppd samples. Thoughts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After sample_posterior(), only latent (estimator) node values are saved by default. When resimulate: true, this commit runs each posterior sample through the forward model and saves all node values together, enabling posterior predictive checks without a separate script.
New DeployedGraph.resimulate_posterior() method encapsulates the pattern already used inline in the adaptive training loop. Called from both sample_mode() (falcon sample posterior) and launch_mode() (end-of-training posterior sampling). _save_samples() default key selection extended to cover all nodes when resimulate=True.
Default behaviour (resimulate: false) is unchanged.
Motivation
falcon sample posteriorcurrently saves only the latent inference nodes(e.g.
delta_ic). To do a posterior predictive check — drawtheta ~ posterior, then simulatex_pred ~ p(x | theta)and compareto the observation — users currently have to write their own forward-pass
script outside of falcon.
This PR adds
sample.posterior.resimulate: true(defaultfalse, nobehaviour change), which after drawing posterior samples automatically
runs them through the forward model and saves all node values together.
How it works
The pattern mirrors what the adaptive training loop already does internally
(draw proposal → forward-simulate for buffer). The logic is extracted into
a new
DeployedGraph.resimulate_posterior()method so it can be reused fromboth
sample_modeandlaunch_mode.Changes
falcon/core/deployed_graph.py: newresimulate_posterior()methodfalcon/cli.py: call it insample_mode()andlaunch_mode()whensample.posterior.resimulate=true; update_save_samples()to includeall node keys when resimulating
docs/configuration.md: documentresimulate,exclude_keys,add_keysUsage