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

Add MCMC module for 1DLA parameter search #10

Merged
merged 16 commits into from Dec 31, 2022
Merged

Add MCMC module for 1DLA parameter search #10

merged 16 commits into from Dec 31, 2022

Conversation

jibanCat
Copy link
Owner

@jibanCat jibanCat commented Aug 18, 2020

Additions:

  1. add _pdf function in the dla_samples.py
  2. add run_mcmc function in dla_gp; still very ugly written.
  3. add a file log_posterior_mcmc.py with the likelihood functions completely separated from the class, which is required by the parallelization in the mcmc chains.

Todo

  • make a test on finding parameters in comparison with MAP values.
  • try to write it cleaner.

@jibanCat
Copy link
Owner Author

jibanCat commented Oct 7, 2020

Current Usage:

For example, you want to do mcmc on this example in the paper Ho-Bird-Garnett 2020:

example1

from tests.test_model import prepare_dla_model
from examples.plot_mcmc import plot_corner, plot_sample_this_mu

# prepare a DLA model conditioned on a given spectrum
dla_gp = prepare_dla_model(plate=5309, mjd=55929, fiber_id=362, z_qso=3.166)

# number of samples you would like to sample in MCMC chains
nsamples = 10000
# number of burn-in samples you would like to discard in your MCMC chains
discard = 2000

# sampling DLA parameters using Markov Chain Monte Carlo
# nwalkers is the number of chains you would like to have. details refer to emcee website.
# kth_dla now only supports 1
sampler = dla_gp.run_mcmc(nwalkers=32, kth_dla=1, nsamples=nsamples)

# plot the sampling results from your MCMC chain. You can set the desired zDLA range
# using min_z and max_z
plot_corner(sampler, discard=discard, min_z=2.6, max_z=5.0)

Screenshot from 2020-10-07 19-53-21
Screenshot from 2020-10-07 19-55-26

plot_corner(sampler, discard=discard, min_z=2.0, max_z=2.6)

Screenshot from 2020-10-07 19-53-29

# plot the dla model with multiple MCMC samples, showing the probabilistic detection of DLAs
plot_sample_this_mu(dla_gp, sampler, discard=discard)

Screenshot from 2020-10-07 19-55-49

@jibanCat
Copy link
Owner Author

jibanCat commented Dec 31, 2022

Merge for now.

Added features:

  1. MCMC for 1 DLA
  2. MCMC for 1 CIV

Not implement:

  • QMC for CIV. (there's no need to implement now. Wait for Reza's paper being published)

So CIV module only supports using MCMC. Details see in the notebook.

@jibanCat jibanCat merged commit 8409552 into master Dec 31, 2022
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.

None yet

1 participant