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.
Add Bayesian Linear Regression Example via Nested Sampling with BlackJax
Description:
This PR introduces a new script (
scripts/line.py
) that demonstrates Bayesian parameter estimation for a simple linear model using BlackJax’s adaptive nested sampling routine. The example includes:Synthetic Data Generation:
Creates synthetic data using a linear model with parameters for slope, intercept, and noise level.
Likelihood & Prior Definitions:
Implements a likelihood function based on a multivariate normal distribution and defines uniform priors for the model parameters.
Nested Sampling Setup:
Initializes live points from the prior and configures the nested sampling algorithm with customizable parameters (e.g., number of live points, deletion steps, and MCMC steps).
Visualization & Post-Processing:
Plots the generated data against the true model and processes the sampling results using the Anesthetic package. A CSV file (
scripts/line.csv
) is also output for further inspection.Installation Instructions:
Detailed instructions are provided as inline comments for setting up a virtual environment and installing the necessary dependencies (BlackJax, Anesthetic, tqdm, etc.).
This minimal, self-contained example serves as a practical introduction for users looking to integrate BlackJax nested sampling into their Bayesian inference workflows. Future improvements could include parameter tuning and extending the example to more complex models.
Please review and let me know if there are any improvements or additional details needed.