Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51,425 changes: 50,809 additions & 616 deletions tutorial/inference_0_Overview.ipynb

Large diffs are not rendered by default.

346 changes: 170 additions & 176 deletions tutorial/inference_1_ModelsAndPEByHand.ipynb

Large diffs are not rendered by default.

158 changes: 85 additions & 73 deletions tutorial/inference_2-CodeRoadmap/2d-normal-example.ipynb

Large diffs are not rendered by default.

373 changes: 52 additions & 321 deletions tutorial/inference_3-AnalyticExample/IntroToPyCBCInference1.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions tutorial/inference_4_bbh_example/IntroToPyCBCInference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introduction to PyCBC Inference 2: Analyzing a gravitational wave\n",
"# Introduction to PyCBC Inference: Analyzing a gravitational wave\n",
"### Collin Capano and Alex Nitz"
]
},
Expand All @@ -31,7 +31,7 @@
"outputs": [],
"source": [
"import sys\n",
"!{sys.executable} -m pip install pycbc ligo-common emcee==2.2.1 --no-cache-dir\n",
"!{sys.executable} -m pip install pycbc ligo-common \"emcee>3.0\" ptemcee --no-cache-dir\n",
"\n",
"# This is needed to access the executables on sciserver. On a personal machine this should be ignore.\n",
"path = %env PATH\n",
Expand All @@ -57,7 +57,7 @@
"\n",
"To analyze a gravitational wave, we need to provide a prior, a model, and data settings in our configuration file. These settings can all be put into a single file, or split up into multiple files, all of which are provided via the `--config-file` option. In this example, we split the configuration up into 3 files:\n",
" * [gw150914_like.ini](gw150914_like.ini): specifies the model we will use, and the parameters that will be varied and their priors. This is the configuration file you would use to analyze signals like GW150914.\n",
" * [emcee_pt-gw150914_like.ini](emcee_pt-gw150914_like.ini): specifies sampler settings. In this case, we are using the `emcee_pt` sampler.\n",
" * [ptemcee-gw150914_like.ini](ptemcee-gw150914_like.ini): specifies sampler settings. In this case, we are using the `ptemcee` sampler.\n",
" * [data.ini](data.ini): specifies the settings for loading the gravitational-wave data.\n",
"\n",
"In the following sections, we look at the various sections of thes configuration files in detail."
Expand Down Expand Up @@ -145,28 +145,28 @@
"source": [
"## The sampler\n",
"\n",
"The sampler settings are in [emcee_pt-gw150914_like.ini](emcee_pt-gw150914_like.ini). Here we are using the `emcee_pt` sampler. This is a parallel tempered sampler, so it requires a number of temperatures to be set. Note a few other differences from the analytic example here:\n",
"The sampler settings are in [ptemcee-gw150914_like.ini](ptemcee-gw150914_like.ini). Here we are using the `ptemcee` sampler. This is a parallel tempered sampler, so it requires a number of temperatures to be set. Note a few other differences from the analytic example here:\n",
" * The `burn-in-test` is set to `nacl & max_posterior`.\n",
" * Instead of an `niterations` option, we have `effective-nsamples = 1000`.\n",
" * A checkpoint interval is set: `checkpoint-interval = 2000`\n",
" * There is a `max-samples-per-chain` option.\n",
"\n",
"These are all options specific to MCMC samplers like `emcee_pt`. Details:\n",
"These are all options specific to MCMC samplers like `ptemcee`. Details:\n",
"\n",
"#### The burn in option\n",
"Multiple burn in tests may be combined using standard boolean operators like `&` and `|`. In this example, we will consider the sampler to be burned in when it has passed the `nacl` test *and* the `max_posterior` test. This means:\n",
"\n",
" * `nacl`: The second half of the chain must be longer than 5 times the ACL. If so, the samlper is considered burned-in at the halfway point.\n",
" * `max_posterior`: All of the walkers must find a point that has a log posterior greater than `maxP - ndim/2`, where `maxP` is the maximum posterior value found over all the walkers and `ndim` is the number of variable parameters. The first iteration for which all the walkers pass this test is the burn in iteration.\n",
" \n",
"By doing `&`, we take the larger iteration of these two tests. This combination of tests has worked well for `emcee_pt`.\n",
"By doing `&`, we take the larger iteration of these two tests. This combination of tests has worked well for `ptemcee`.\n",
"\n",
"#### Checkpointing\n",
"When a `checkpoint-interval` is set, `pycbc_inference` will dump the results to a checkpoint file after every `checkpoint-interval` iterations. The checkpoint file has the same name as the output, but with `.checkpoint` added on to it. \n",
"\n",
"While ``pycbc_inference`` is running it will create a checkpoint file which\n",
"is named ``{output-file}.checkpoint``, where ``{output-file}`` was the name\n",
"of the file you specified with the ``--output-file`` command. If a `checkpoint-interval` is set, `pycbc_inference` will checkpoint after the given number of iterations. For `emcee_pt`, this means that it will dump the current samples to this file; when finished, the file is\n",
"of the file you specified with the ``--output-file`` command. If a `checkpoint-interval` is set, `pycbc_inference` will checkpoint after the given number of iterations. For `ptemcee`, this means that it will dump the current samples to this file; when finished, the file is\n",
"renamed to ``{output-file}``.\n",
"\n",
"A ``{output-file}.bkup`` is also created, which is a copy of the checkpoint file. This is kept in case the checkpoint file gets corrupted during writing. The ``.bkup`` file is deleted at the end of the run, unless ``--save-backup`` is turned on.\n",
Expand Down Expand Up @@ -390,7 +390,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.13.14"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[sampler]
name = emcee_pt
name = ptemcee
; for GW problems, its usually best to use 200 walkers and 20 temps;
; here, we've reduced that just for a test
nwalkers = 100
Expand Down
2 changes: 1 addition & 1 deletion tutorial/inference_4_bbh_example/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# configuration files
PRIOR_CONFIG=gw150914_like.ini
DATA_CONFIG=data.ini
SAMPLER_CONFIG=emcee_pt-gw150914_like.ini
SAMPLER_CONFIG=ptemcee-gw150914_like.ini

OUTPUT_PATH=bbh_results.hdf

Expand Down
Loading
Loading