pycbc.inference.sampler package¶

pycbc.inference.sampler.base module¶

Defines the base sampler class to be inherited by all samplers.

class pycbc.inference.sampler.base.BaseSampler(model)[source]

Bases: object

Abstract base class for all inference samplers.

All sampler classes must inherit from this class and implement its abstract methods.

Parameters: model (Model) – An instance of a model from pycbc.inference.models.
checkpoint()[source]

The sampler must have a checkpoint method for dumping raw samples and stats to the file type defined by io.

finalize()[source]

Do any finalization to the samples file before exiting.

from_config(cp, model, nprocesses=1, use_mpi=False)[source]

This should initialize the sampler given a config file.

io

A class that inherits from BaseInferenceFile to handle IO with an hdf file.

This should be a class, not an instance of class, so that the sampler can initialize it when needed.

model_stats

A dict mapping model’s metadata fields to arrays of values for each sample in raw_samples.

The arrays may have any shape, and may or may not be thinned.

name = None
run()[source]

This function should run the sampler.

Any checkpointing should be done internally in this function.

samples

A dict mapping variable_params to arrays of samples currently in memory. The dictionary may also contain sampling_params.

The sample arrays may have any shape, and may or may not be thinned.

sampling_params

Returns the sampling params used by the model.

set_initial_conditions(initial_distribution=None, samples_file=None)[source]

Sets up the starting point for the sampler.

Should also set the sampler’s random state.

setup_output(output_file, force=False, injection_file=None)[source]

Sets up the sampler’s checkpoint and output files.

The checkpoint file has the same name as the output file, but with .checkpoint appended to the name. A backup file will also be created.

If the output file already exists, an OSError will be raised. This can be overridden by setting force to True.

Parameters: sampler (sampler instance) – Sampler output_file (str) – Name of the output file. force (bool, optional) – If the output file already exists, overwrite it. injection_file (str, optional) – If an injection was added to the data, write its information.
static_params

Returns the model’s fixed parameters.

variable_params

Returns the parameters varied in the model.

pycbc.inference.sampler.base.create_new_output_file(sampler, filename, injection_file=None, **kwargs)[source]

Creates a new output file.

If the output file already exists, an OSError will be raised. This can be overridden by setting force to True.

Parameters: sampler (sampler instance) – Sampler filename (str) – Name of the file to create. force (bool, optional) – Create the file even if it already exists. Default is False. injection_file (str, optional) – If an injection was added to the data, write its information. **kwargs – All other keyword arguments are passed through to the file’s write_metadata function.
pycbc.inference.sampler.base.initial_dist_from_config(cp, variable_params)[source]

Loads a distribution for the sampler start from the given config file.

A distribution will only be loaded if the config file has a [initial-*] section(s).

Parameters: cp (Config parser) – The config parser to try to load from. variable_params (list of str) – The variable parameters for the distribution. The initial distribution. If no [initial-*] section found in the config file, will just return None.

pycbc.inference.sampler.base_mcmc module¶

Provides constructor classes and convenience functions for MCMC samplers.

class pycbc.inference.sampler.base_mcmc.BaseMCMC[source]

Bases: object

Abstract base class that provides methods common to MCMCs.

This is not a sampler class itself. Sampler classes can inherit from this along with BaseSampler.

This class provides set_initial_conditions, run, and checkpoint methods, which are some of the abstract methods required by BaseSampler.

This class introduces the following abstract properties and methods:

• base_shape
[property] Should give the shape of the samples arrays used by the sampler, excluding the iteraitons dimension. Needed for writing results.
• run_mcmc(niterations)
Should run the sampler for the given number of iterations. Called by run.
• clear_samples()
Should clear samples from memory. Called by run.
• set_state_from_file(filename)
Should set the random state of the sampler using the given filename. Called by set_initial_conditions.
• write_results(filename)
Writes results to the given filename. Called by checkpoint.
• compute_acf(filename, **kwargs)
[classmethod] Should compute the autocorrelation function using the given filename. Also allows for other keyword arguments.
• compute_acl(filename, **kwargs)
[classmethod] Should compute the autocorrelation length using the given filename. Also allows for other keyword arguments.
p0
pos
nwalkers
niterations
checkpoint_interval
checkpoint_signal
target_niterations
target_eff_nsamples
thin_interval
max_samples_per_chain
thin_safety_factor
burn_in
effective_nsamples
acls
acts
acls

The autocorrelation lengths of each parameter’s thinned chain.

acts

The autocorrelation times of each parameter.

The autocorrelation time is defined as the ACL times the thin_interval. It gives the number of iterations between independent samples.

base_shape

What shape the sampler’s samples arrays are in, excluding the iterations dimension.

For example, if a sampler uses 20 walkers and 3 temperatures, this would be (3, 20). If a sampler only uses a single walker and no temperatures this would be ().

burn_in

The class for doing burn-in tests (if specified).

checkpoint()[source]

Dumps current samples to the checkpoint file.

static checkpoint_from_config(cp, section)[source]

Gets the checkpoint interval from the given config file.

This looks for ‘checkpoint-interval’ in the section.

Parameters: cp (ConfigParser) – Open config parser to retrieve the argument from. section (str) – Name of the section to retrieve from. The checkpoint interval, if it is in the section. Otherw int or None
checkpoint_interval

The number of iterations to do between checkpoints.

checkpoint_signal

The signal to use when checkpointing.

static ckpt_signal_from_config(cp, section)[source]

Gets the checkpoint signal from the given config file.

This looks for ‘checkpoint-signal’ in the section.

Parameters: cp (ConfigParser) – Open config parser to retrieve the argument from. section (str) – Name of the section to retrieve from. The checkpoint interval, if it is in the section. Otherw int or None
clear_samples()[source]

A method to clear samples from memory.

compute_acf(filename, **kwargs)[source]

A method to compute the autocorrelation function of samples in the given file.

compute_acl(filename, **kwargs)[source]

A method to compute the autocorrelation length of samples in the given file.

effective_nsamples

The effective number of samples post burn-in that the sampler has acquired so far.

get_thin_interval()[source]

Gets the thin interval to use.

If max_samples_per_chain is set, this will figure out what thin interval is needed to satisfy that criteria. In that case, the thin interval used must be a multiple of the currently used thin interval.

max_samples_per_chain

The maximum number of samplers per chain that is written to disk.

niterations

The current number of iterations.

nwalkers

The number of walkers used.

p0

A dictionary of the initial position of the walkers.

This is set by using set_p0. If not set yet, a ValueError is raised when the attribute is accessed.

pos

A dictionary of the current walker positions.

If the sampler hasn’t been run yet, returns p0.

run()[source]

Runs the sampler.

run_mcmc(niterations)[source]

Run the MCMC for the given number of iterations.

set_burn_in(burn_in)[source]

Sets the object to use for doing burn-in tests.

set_burn_in_from_config(cp)[source]

Sets the burn in class from the given config file.

If no burn-in section exists in the file, then this just set the burn-in class to None.

set_initial_conditions(initial_distribution=None, samples_file=None)[source]

Sets the initial starting point for the MCMC.

If a starting samples file is provided, will also load the random state from it.

set_p0(samples_file=None, prior=None)[source]

Sets the initial position of the walkers.

Parameters: samples_file (InferenceFile, optional) – If provided, use the last iteration in the given file for the starting positions. prior (JointDistribution, optional) – Use the given prior to set the initial positions rather than model’s prior. p0 – A dictionary maping sampling params to the starting positions. dict
set_state_from_file(filename)[source]

Sets the state of the sampler to the instance saved in a file.

set_target(niterations=None, eff_nsamples=None)[source]

Sets the target niterations/nsamples for the sampler.

One or the other must be provided, not both.

set_target_from_config(cp, section)[source]

Sets the target using the given config file.

This looks for niterations to set the target_niterations, and effective-nsamples to set the target_eff_nsamples.

Parameters: cp (ConfigParser) – Open config parser to retrieve the argument from. section (str) – Name of the section to retrieve from.
set_thin_interval_from_config(cp, section)[source]

Sets thinning options from the given config file.

target_eff_nsamples

The target number of effective samples the sampler should get.

target_niterations

The number of iterations the sampler should run for.

thin_interval

Returns the thin interval being used.

thin_safety_factor

The minimum value that max_samples_per_chain may be set to.

write_results(filename)[source]

Should write all samples currently in memory to the given file.

class pycbc.inference.sampler.base_mcmc.MCMCAutocorrSupport[source]

Bases: object

Provides class methods for calculating ensemble ACFs/ACLs.

classmethod compute_acf(filename, start_index=None, end_index=None, per_walker=False, walkers=None, parameters=None)[source]

Computes the autocorrleation function of the model params in the given file.

By default, parameter values are averaged over all walkers at each iteration. The ACF is then calculated over the averaged chain. An ACF per-walker will be returned instead if per_walker=True.

Parameters: filename (str) – Name of a samples file to compute ACFs for. start_index ({None, int}) – The start index to compute the acl from. If None, will try to use the number of burn-in iterations in the file; otherwise, will start at the first sample. end_index ({None, int}) – The end index to compute the acl to. If None, will go to the end of the current iteration. per_walker (optional, bool) – Return the ACF for each walker separately. Default is False. walkers (optional, int or array) – Calculate the ACF using only the given walkers. If None (the default) all walkers will be used. parameters (optional, str or array) – Calculate the ACF for only the given parameters. If None (the default) will calculate the ACF for all of the model params. Dictionary of arrays giving the ACFs for each parameter. If per-walker is True, the arrays will have shape nwalkers x niterations. dict
classmethod compute_acl(filename, start_index=None, end_index=None, min_nsamples=10)[source]

Computes the autocorrleation length for all model params in the given file.

Parameter values are averaged over all walkers at each iteration. The ACL is then calculated over the averaged chain. If an ACL cannot be calculated because there are not enough samples, it will be set to inf.

Parameters: filename (str) – Name of a samples file to compute ACLs for. start_index (int, optional) – The start index to compute the acl from. If None, will try to use the number of burn-in iterations in the file; otherwise, will start at the first sample. end_index (int, optional) – The end index to compute the acl to. If None, will go to the end of the current iteration. min_nsamples (int, optional) – Require a minimum number of samples to compute an ACL. If the number of samples per walker is less than this, will just set to inf. Default is 10. A dictionary giving the ACL for each parameter. dict
pycbc.inference.sampler.base_mcmc.blob_data_to_dict(stat_names, blobs)[source]

Converts list of “blobs” to a dictionary of model stats.

Samplers like emcee store the extra tuple returned by CallModel to a list called blobs. This is a list of lists of tuples with shape niterations x nwalkers x nstats, where nstats is the number of stats returned by the model’s default_stats. This converts that list to a dictionary of arrays keyed by the stat names.

Parameters: stat_names (list of str) – The list of the stat names. blobs (list of list of tuples) – The data to convert. A dictionary mapping the model’s default_stats to arrays of values. Each array will have shape nwalkers x niterations. dict
pycbc.inference.sampler.base_mcmc.get_optional_arg_from_config(cp, section, arg, dtype=<class 'str'>)[source]

Convenience function to retrieve an optional argument from a config file.

Parameters: cp (ConfigParser) – Open config parser to retrieve the argument from. section (str) – Name of the section to retrieve from. arg (str) – Name of the argument to retrieve. dtype (datatype, optional) – Cast the retrieved value (if it exists) to the given datatype. Default is str. val – If the argument is present, the value. Otherwise, None. None or str
pycbc.inference.sampler.base_mcmc.raw_samples_to_dict(sampler, raw_samples)[source]

Convenience function for converting ND array to a dict of samples.

The samples are assumed to have dimension [sampler.base_shape x] niterations x len(sampler.sampling_params).

Parameters: sampler (sampler instance) – An instance of an MCMC sampler. raw_samples (array) – The array of samples to convert. A dictionary mapping the raw samples to the variable params. If the sampling params are not the same as the variable params, they will also be included. Each array will have shape [sampler.base_shape x] niterations. dict

pycbc.inference.sampler.base_multitemper module¶

Provides constructor classes provide support for parallel tempered MCMC samplers.

class pycbc.inference.sampler.base_multitemper.MultiTemperedAutocorrSupport[source]

Bases: object

Provides class methods for calculating multi-tempered ACFs/ACLs.

classmethod compute_acf(filename, start_index=None, end_index=None, per_walker=False, walkers=None, parameters=None, temps=None)[source]

Computes the autocorrleation function of the model params in the given file.

By default, parameter values are averaged over all walkers at each iteration. The ACF is then calculated over the averaged chain for each temperature. An ACF per-walker will be returned instead if per_walker=True.

Parameters: filename (str) – Name of a samples file to compute ACFs for. start_index ({None, int}) – The start index to compute the acl from. If None, will try to use the number of burn-in iterations in the file; otherwise, will start at the first sample. end_index ({None, int}) – The end index to compute the acl to. If None, will go to the end of the current iteration. per_walker (optional, bool) – Return the ACF for each walker separately. Default is False. walkers (optional, int or array) – Calculate the ACF using only the given walkers. If None (the default) all walkers will be used. parameters (optional, str or array) – Calculate the ACF for only the given parameters. If None (the default) will calculate the ACF for all of the model params. temps (optional, (list of) int or 'all') – The temperature index (or list of indices) to retrieve. If None (the default), the ACF will only be computed for the coldest (= 0) temperature chain. To compute an ACF for all temperates pass ‘all’, or a list of all of the temperatures. Dictionary of arrays giving the ACFs for each parameter. If per-walker is True, the arrays will have shape ntemps x nwalkers x niterations. Otherwise, the returned array will have shape ntemps x niterations. dict
classmethod compute_acl(filename, start_index=None, end_index=None, min_nsamples=10)[source]

Computes the autocorrleation length for all model params and temperatures in the given file.

Parameter values are averaged over all walkers at each iteration and temperature. The ACL is then calculated over the averaged chain.

Parameters: filename (str) – Name of a samples file to compute ACLs for. start_index ({None, int}) – The start index to compute the acl from. If None, will try to use the number of burn-in iterations in the file; otherwise, will start at the first sample. end_index ({None, int}) – The end index to compute the acl to. If None, will go to the end of the current iteration. min_nsamples (int, optional) – Require a minimum number of samples to compute an ACL. If the number of samples per walker is less than this, will just set to inf. Default is 10. A dictionary of ntemps-long arrays of the ACLs of each parameter. dict
class pycbc.inference.sampler.base_multitemper.MultiTemperedSupport[source]

Bases: object

Provides methods for supporting multi-tempered samplers.

ntemps

The number of temeratures that are set.

pycbc.inference.sampler.dynesty module¶

This modules provides classes and functions for using the dynesty sampler packages for parameter estimation.

class pycbc.inference.sampler.dynesty.DynestyModel(model, loglikelihood_function=None)[source]

Bases: object

Class for making PyCBC Inference ‘model class’ :param model: A model instance from pycbc. :type model: inference.BaseModel instance

log_likelihood(cube)[source]

returns log likelihood function

prior_transform(cube)[source]

prior transform function for dynesty sampler It takes unit cube as input parameter and apply prior transforms

class pycbc.inference.sampler.dynesty.DynestySampler(model, nlive, dlogz, nprocesses=1, loglikelihood_function=None, use_mpi=False, **kwargs)[source]

This class is used to construct an Dynesty sampler from the dynesty package.

Parameters: model (model) – A model from pycbc.inference.models. nlive (int) – Number of live points to use in sampler. dlogz (float) – Tolerance limit to the value of logz (also a convergence criteria) pool (function with map, Optional) – A provider of a map function that allows a function call to be run over multiple sets of arguments and possibly maps them to cores/nodes/etc.
checkpoint()[source]

The sampler must have a checkpoint method for dumping raw samples and stats to the file type defined by io.

finalize()[source]

Do any finalization to the samples file before exiting.

classmethod from_config(cp, model, nprocesses=1, loglikelihood_function=None, use_mpi=False)[source]

Loads the sampler from the given config file.

io

A class that inherits from BaseInferenceFile to handle IO with an hdf file.

This should be a class, not an instance of class, so that the sampler can initialize it when needed.

logz

return bayesian evidence estimated by dynesty sampler

logz_err

return error in bayesian evidence estimated by dynesty sampler

model_stats

A dict mapping model’s metadata fields to arrays of values for each sample in raw_samples.

The arrays may have any shape, and may or may not be thinned.

name = 'dynesty'
niterations
posterior_samples

Returns posterior samples from nested samples and weights given by dynsety sampler

run()[source]

This function should run the sampler.

Any checkpointing should be done internally in this function.

samples

A dict mapping variable_params to arrays of samples currently in memory. The dictionary may also contain sampling_params.

The sample arrays may have any shape, and may or may not be thinned.

set_initial_conditions(initial_distribution=None, samples_file=None)[source]

Sets up the starting point for the sampler.

Should also set the sampler’s random state.

write_results(filename)[source]

Writes samples, model stats, acceptance fraction, and random state to the given file.

Parameters: filename (str) – The file to write to. The file is opened using the io class in an an append state.

pycbc.inference.sampler.emcee module¶

This modules provides classes and functions for using the emcee sampler packages for parameter estimation.

class pycbc.inference.sampler.emcee.EmceeEnsembleSampler(model, nwalkers, checkpoint_interval=None, checkpoint_signal=None, logpost_function=None, nprocesses=1, use_mpi=False)[source]

This class is used to construct an MCMC sampler from the emcee package’s EnsembleSampler.

Parameters: model (model) – A model from pycbc.inference.models. nwalkers (int) – Number of walkers to use in sampler. pool (function with map, Optional) – A provider of a map function that allows a function call to be run over multiple sets of arguments and possibly maps them to cores/nodes/etc.
base_shape

What shape the sampler’s samples arrays are in, excluding the iterations dimension.

For example, if a sampler uses 20 walkers and 3 temperatures, this would be (3, 20). If a sampler only uses a single walker and no temperatures this would be ().

burn_in_class
clear_samples()[source]

Clears the samples and stats from memory.

finalize()[source]

All data is written by the last checkpoint in the run method, so this just passes.

classmethod from_config(cp, model, nprocesses=1, use_mpi=False)[source]

Loads the sampler from the given config file.

io

A class that inherits from BaseInferenceFile to handle IO with an hdf file.

This should be a class, not an instance of class, so that the sampler can initialize it when needed.

model_stats

A dict mapping the model’s default_stats to arrays of values.

The returned array has shape nwalkers x niterations.

name = 'emcee'
run_mcmc(niterations)[source]

Advance the ensemble for a number of samples.

Parameters: niterations (int) – Number of iterations to run the sampler for.
samples

A dict mapping variable_params to arrays of samples currently in memory.

The arrays have shape nwalkers x niterations.

set_state_from_file(filename)[source]

Sets the state of the sampler back to the instance saved in a file.

write_results(filename)[source]

Writes samples, model stats, acceptance fraction, and random state to the given file.

Parameters: filename (str) – The file to write to. The file is opened using the io class in an an append state.

pycbc.inference.sampler.emcee_pt module¶

This modules provides classes and functions for using the emcee_pt sampler packages for parameter estimation.

class pycbc.inference.sampler.emcee_pt.EmceePTSampler(model, ntemps, nwalkers, betas=None, checkpoint_interval=None, checkpoint_signal=None, loglikelihood_function=None, nprocesses=1, use_mpi=False)[source]

This class is used to construct a parallel-tempered MCMC sampler from the emcee package’s PTSampler.

Parameters: model (model) – A model from pycbc.inference.models. ntemps (int) – Number of temeratures to use in the sampler. nwalkers (int) – Number of walkers to use in sampler. betas (array) – An array of inverse temperature values to be used in emcee_pt’s temperature ladder. If not provided, emcee_pt will use the number of temperatures and the number of dimensions of the parameter space to construct the ladder with geometrically spaced temperatures. pool (function with map, Optional) – A provider of a map function that allows a function call to be run over multiple sets of arguments and possibly maps them to cores/nodes/etc.
base_shape

What shape the sampler’s samples arrays are in, excluding the iterations dimension.

For example, if a sampler uses 20 walkers and 3 temperatures, this would be (3, 20). If a sampler only uses a single walker and no temperatures this would be ().

betas
burn_in_class
classmethod calculate_logevidence(filename, thin_start=None, thin_end=None, thin_interval=None)[source]

Calculates the log evidence from the given file using emcee_pt’s thermodynamic integration.

Parameters: filename (str) – Name of the file to read the samples from. Should be an EmceePTFile. thin_start (int) – Index of the sample to begin returning stats. Default is to read stats after burn in. To start from the beginning set thin_start to 0. thin_interval (int) – Interval to accept every i-th sample. Default is to use the fp.acl. If fp.acl is not set, then use all stats (set thin_interval to 1). thin_end (int) – Index of the last sample to read. If not given then fp.niterations is used. lnZ (float) – The estimate of log of the evidence. dlnZ (float) – The error on the estimate.
clear_samples()[source]

Clears the chain and blobs from memory.

finalize()[source]

Calculates the log evidence and writes to the checkpoint file.

The thin start/interval/end for calculating the log evidence are retrieved from the checkpoint file’s thinning attributes.

classmethod from_config(cp, model, nprocesses=1, use_mpi=False)[source]

Loads the sampler from the given config file.

For generating the temperature ladder to be used by emcee_pt, either the number of temperatures (provided by the option ‘ntemps’), or the path to a file storing inverse temperature values (provided under a subsection inverse-temperatures-file) can be loaded from the config file. If the latter, the file should be of hdf format, having an attribute named ‘betas’ storing the list of inverse temperature values to be provided to emcee_pt. If the former, emcee_pt will construct the ladder with “ntemps” geometrically spaced temperatures.

io

A class that inherits from BaseInferenceFile to handle IO with an hdf file.

This should be a class, not an instance of class, so that the sampler can initialize it when needed.

model_stats

Returns the log likelihood ratio and log prior as a dict of arrays.

The returned array has shape ntemps x nwalkers x niterations.

Unfortunately, because emcee_pt does not have blob support, this will only return the loglikelihood and logprior (with the logjacobian set to zero) regardless of what stats the model can return.

Warning

Since the logjacobian is not saved by emcee_pt, the logprior returned here is the log of the prior pdf in the sampling coordinate frame rather than the variable params frame. This differs from the variable params frame by the log of the Jacobian of the transform from one frame to the other. If no sampling transforms were used, then the logprior is the same.

name = 'emcee_pt'
run_mcmc(niterations)[source]

Advance the ensemble for a number of samples.

Parameters: niterations (int) – Number of samples to get from sampler.
samples

A dict mapping variable_params to arrays of samples currently in memory.

The arrays have shape ntemps x nwalkers x niterations.

set_state_from_file(filename)[source]

Sets the state of the sampler back to the instance saved in a file.

write_results(filename)[source]

Writes samples, model stats, acceptance fraction, and random state to the given file.

Parameters: filename (str) – The file to write to. The file is opened using the io class in an an append state.

pycbc.inference.sampler.multinest module¶

This modules provides classes and functions for using the Multinest sampler packages for parameter estimation.

class pycbc.inference.sampler.multinest.MultinestSampler(model, nlivepoints, checkpoint_interval=1000, importance_nested_sampling=False, evidence_tolerance=0.1, sampling_efficiency=0.01, constraints=None)[source]

This class is used to construct a nested sampler from the Multinest package.

Parameters: model (model) – A model from pycbc.inference.models. nlivepoints (int) – Number of live points to use in sampler.
check_if_finished()[source]

Estimate remaining evidence to see if desired evidence-tolerance stopping criterion has been reached.

checkpoint()[source]

Dumps current samples to the checkpoint file.

checkpoint_interval

Get the number of iterations between checkpoints.

dlogz

Get the current error estimate of the log evidence.

finalize()[source]

All data is written by the last checkpoint in the run method, so this just passes.

classmethod from_config(cp, model, nprocesses=1, use_mpi=False)[source]

Loads the sampler from the given config file.

get_posterior_samples()[source]

Read posterior samples from ASCII output file created by multinest.

importance_dlogz

Get the current error estimate of the importance weighted log evidence.

importance_logz

Get the current importance weighted estimate of the log evidence.

io

A class that inherits from BaseInferenceFile to handle IO with an hdf file.

This should be a class, not an instance of class, so that the sampler can initialize it when needed.

loglikelihood(cube, *extra_args)[source]

Log likelihood evaluator that gets passed to multinest.

logz

Get the current estimate of the log evidence.

model_stats

A dict mapping the model’s default_stats to arrays of values.

name = 'multinest'
niterations

Get the current number of iterations.

nlivepoints

Get the number of live points used in sampling.

run()[source]

Runs the sampler until the specified evidence tolerance is reached.

samples

A dict mapping variable_params to arrays of samples currently in memory.

set_initial_conditions(initial_distribution=None, samples_file=None)[source]

Sets the initial starting point for the sampler.

If a starting samples file is provided, will also load the random state from it.

set_state_from_file(filename)[source]

Sets the state of the sampler back to the instance saved in a file.

transform_prior(cube, *extra_args)[source]

Transforms the unit hypercube that multinest makes its draws from, into the prior space defined in the config file.

write_results(filename)[source]

Writes samples, model stats, acceptance fraction, and random state to the given file.

Parameters: filename (str) – The file to write to. The file is opened using the io class in an an append state.

Module contents¶

This modules provides a list of implemented samplers for parameter estimation.

pycbc.inference.sampler.load_from_config(cp, model, **kwargs)[source]

Loads a sampler from the given config file.

This looks for a name in the section [sampler] to determine which sampler class to load. That sampler’s from_config is then called.

Parameters: cp (WorkflowConfigParser) – Config parser to read from. model (pycbc.inference.model) – Which model to pass to the sampler. **kwargs – All other keyword arguments are passed directly to the sampler’s from_config file. The initialized sampler. sampler