Skip to content

Line fitting example #6

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Line fitting example #6

wants to merge 1 commit into from

Conversation

williamjameshandley
Copy link
Contributor

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.

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 this pull request may close these issues.

1 participant