pycbc.inference.jump package

Submodules

pycbc.inference.jump.angular module

Jump proposals that use cyclic boundaries on [0, 2pi).

class pycbc.inference.jump.angular.EpsieAdaptiveAngular(parameters, adaptation_duration, **kwargs)[source]

Bases: epsie.proposals.angular.AdaptiveAngular

Adds from_config method to epsie’s adaptive angular proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_adaptive_from_config() with cls set to epsie.proposals.AdaptiveBoundedNormal and with_boundaries set to False (since the boundaries for the angular proposals are always \([0, 2\pi)\)). See that function for details on options that can be read.

Example:

[jump_proposal-ra]
name = adaptive_angular
adaptation-duration = 1000
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

An adaptive angular proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveAngular

class pycbc.inference.jump.angular.EpsieAngular(parameters, cov=None)[source]

Bases: epsie.proposals.angular.Angular

Adds from_config method to epsie’s angular proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_from_config() with cls set to epsie.proposals.Angular and with_boundaries set to False. See that function for details on options that can be read.

Example:

[jump_proposal-ra]
name = angular
var-ra = 0.01
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

An angular proposal for use with epsie samplers.

Return type:

epsie.proposals.Angular

pycbc.inference.jump.bounded_normal module

Jump proposals that use a bounded normal distribution.

class pycbc.inference.jump.bounded_normal.EpsieAdaptiveBoundedNormal(parameters, boundaries, adaptation_duration, **kwargs)[source]

Bases: epsie.proposals.bounded_normal.AdaptiveBoundedNormal

Adds from_config method to epsie’s adaptive normal proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_adaptive_from_config() with cls set to epsie.proposals.AdaptiveBoundedNormal. See that function for details on options that can be read.

Example:

[jump_proposal-q]
name = adaptive_bounded_normal
adaptation-duration = 1000
min-q = 1
max-q = 8
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

An adaptive normal proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveBoundedNormal

class pycbc.inference.jump.bounded_normal.EpsieBoundedNormal(parameters, boundaries, cov=None)[source]

Bases: epsie.proposals.bounded_normal.BoundedNormal

Adds from_config method to epsie’s bounded normal proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_from_config() with cls set to epsie.proposals.BoundedNormal and with_boundaries set to True. See that function for details on options that can be read.

Example:

[jump_proposal-mchrip+q]
name = bounded_normal
min-q = 1
max-q = 8
min-mchirp = 20
max-mchirp = 80
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

A bounded normal proposal for use with epsie samplers.

Return type:

epsie.proposals.BoundedNormal

pycbc.inference.jump.discrete module

Jump proposals that use a bounded normal distribution.

class pycbc.inference.jump.discrete.EpsieAdaptiveBoundedDiscrete(parameters, boundaries, adaptation_duration, successive=None, **kwargs)[source]

Bases: epsie.proposals.discrete.AdaptiveBoundedDiscrete

Adds from_config method to epsie’s adaptive bounded discrete proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_adaptive_from_config() with cls set to epsie.proposals.AdaptiveBoundedDiscrete. See that function for details on options that can be read.

Example:

[jump_proposal-index]
name = adaptive_bounded_discrete
adaptation-duration = 1000
min-index = 0
max-index = 42
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

An adaptive normal proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveBoundedDiscrete

class pycbc.inference.jump.discrete.EpsieAdaptiveNormalDiscrete(parameters, prior_widths, adaptation_duration, successive=None, **kwargs)[source]

Bases: epsie.proposals.discrete.AdaptiveNormalDiscrete

Adds from_config method to epsie’s adaptive bounded discrete proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_adaptive_from_config() with cls set to epsie.proposals.AdaptiveNormalDiscrete. See that function for details on options that can be read.

Example:

[jump_proposal-index]
name = adaptive_normal_discrete
adaptation-duration = 1000
min-index = 0
max-index = 42
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

An adaptive normal proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveBoundedDiscrete

class pycbc.inference.jump.discrete.EpsieBoundedDiscrete(parameters, boundaries, cov=None, successive=None)[source]

Bases: epsie.proposals.discrete.BoundedDiscrete

Adds from_config method to epsie’s bounded discrete proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_from_config() with cls set to epsie.proposals.BoundedDiscrete and with_boundaries set to True. See that function for details on options that can be read.

Example:

[jump_proposal-index]
name = bounded_discrete
min-index = 0
max-index = 19
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

A bounded discrete proposal for use with epsie samplers.

Return type:

epsie.proposals.BoundedDiscrete

class pycbc.inference.jump.discrete.EpsieNormalDiscrete(parameters, cov=None, successive=None)[source]

Bases: epsie.proposals.discrete.NormalDiscrete

Adds from_config method to epsie’s normal discrete proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_from_config() with cls set to epsie.proposals.NormalDiscrete and with_boundaries set to False. See that function for details on options that can be read.

Example:

[jump_proposal-index]
name = discrete
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

A bounded discrete proposal for use with epsie samplers.

Return type:

epsie.proposals.BoundedDiscrete

pycbc.inference.jump.normal module

Jump proposals that use a normal distribution.

class pycbc.inference.jump.normal.EpsieAdaptiveNormal(parameters, prior_widths, adaptation_duration, **kwargs)[source]

Bases: epsie.proposals.normal.AdaptiveNormal

Adds from_config method to epsie’s adaptive normal proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_adaptive_from_config() with cls set to epsie.proposals.AdaptiveNormal. See that function for details on options that can be read.

Example:

[jump_proposal-mchirp+q]
name = adaptive_normal
adaptation-duration = 1000
min-q = 1
max-q = 8
min-mchirp = 20
max-mchirp = 80
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

An adaptive normal proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveNormal

class pycbc.inference.jump.normal.EpsieNormal(parameters, cov=None)[source]

Bases: epsie.proposals.normal.Normal

Adds from_config method to epsie’s normal proposal.

classmethod from_config(cp, section, tag)[source]

Loads a proposal from a config file.

This calls epsie_from_config() with cls set to epsie.proposals.Normal and with_boundaries set to False. See that function for details on options that can be read.

Example:

[jump_proposal-mchrip+q]
name = normal
var-q = 0.1
Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
Returns:

A normal proposal for use with epsie samplers.

Return type:

epsie.proposals.Normal

pycbc.inference.jump.normal.epsie_adaptive_from_config(cls, cp, section, tag, with_boundaries=True, boundary_arg_name='boundaries')[source]

Generic function for loading adaptive epsie proposals from a config file.

The section that is read should have the format [{section}-{tag}], where {tag} is a pycbc.VARARGS_DELIM separated list of the parameters to create the jump proposal for.

Options that are read:

  • name : str
    Required. Must match the name of the proposal.
  • adaptation-duration : int
    Required. Sets the adaptation_duration.
  • min-{param} : float
  • max-{param} : float
    The bounds on each parameter. Required if with_boundaries is set to True, in which case bounds must be provided for every parameter.
  • var-{param} : float
    Optional. Initial variance to use. If not provided, will use a default based on the bounds (see epsie.proposals.AdaptiveSupport for details).
  • adaptation-decay : int
    Optional. Sets the adaptation_decay. If not provided, will use the class’s default.
  • start-iteration : int
    Optional. Sets the start_iteration.If not provided, will use the class’s default.
  • target-rate : float
    Optional. Sets the target_rate. If not provided, will use the class’s default.
Parameters:
  • cls (epsie.proposals.BaseProposal) – The epsie proposal class to initialize. The class should have epsie.proposals.normal.AdaptiveSupport.
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
  • with_boundaries (bool, optional) – Try to load boundaries from the section and pass a boundaries argument to the class’s initialization. Default is True.
  • boundary_arg_name (str, optional) – The name of the argument for the boundaries (only used if with_boundaries is True). Provided because some adaptive proposals that only need the boundary widths call this prior_widths. Default is 'boundaries'.
Returns:

The class initialized with the options read from the config file.

Return type:

cls

pycbc.inference.jump.normal.epsie_from_config(cls, cp, section, tag, with_boundaries=False)[source]

Generic function for loading epsie proposals from a config file.

This should be used for proposals that are not adaptive.

The section that is read should have the format [{section}-{tag}], where {tag} is a pycbc.VARARGS_DELIM separated list of the parameters to create the jump proposal for.

Options that are read:

  • name : str
    Required. Must match the name of the proposal.
  • var-{param} : float
    Optional. Variance to use for parameter {param}. If with_boundaries is True, then any parameter not specified will use a default variance of \((\Delta p/10)^2\), where \(\Delta p\) is the boundary width for that parameter. If with_boundaries is False, will use a default value of 1.
  • min-{param} : float
  • max-{param} : float
    The bounds on each parameter. Required if with_boundaries is set to True, in which case bounds must be provided for every parameter.
Parameters:
  • cls (epsie.proposals.BaseProposal) – The epsie proposal class to initialize.
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
  • with_boundaries (bool, optional) – Try to load boundaries from the section and pass a boundaries argument to the class’s initialization. This should be set to true for bounded proposals. Default is False.
Returns:

The class initialized with the options read from the config file.

Return type:

cls

pycbc.inference.jump.normal.get_epsie_adaptation_settings(opts)[source]

Get settings for Epsie adaptive proposals from a config file.

This requires that adaptation_duration is in the given dictionary. It will also look for adaptation_decay, start_iteration, and target_rate, but these are optional. Arguments will be popped from the given dictionary.

Parameters:opts (dict) – Dictionary of option -> value that was loaded from a config file section.
Returns:Dictionary of argument name -> values.
Return type:dict
pycbc.inference.jump.normal.get_param_boundaries(params, opts)[source]

Gets parameter boundaries for jump proposals.

The syntax for the options should be (min|max)_{param} = value. Both a minimum and maximum should be provided for every parameter in params. If the opts are created using load_opts, then the options can be formatted as (min|max)-{param}, since that function will turn all - to _ in option names.

Arguments will be popped from the given opts dictionary.

Parameters:
  • params (list of str) – List of parameter names to get boundaries for.
  • opts (dict) – Dictionary of option -> value that was loaded from a config file section.
Returns:

Dictionary of parameter names -> epsie.proposals.Boundaries

Return type:

dict

pycbc.inference.jump.normal.get_variance(params, opts, default=1.0)[source]

Gets variance for jump proposals from the dictionary of options.

This looks for var_{param} for every parameter listed in params. If found, the argument is popped from the given opts dictionary. If not found, default will be used.

Parameters:
  • params (list of str) – List of parameter names to look for.
  • opts (dict) – Dictionary of option -> value that was loaded from a config file section.
  • default (float, optional) – Default value to use for parameters that do not have variances provided. Default is 1.
Returns:

Array of variances to use. Order is the same as the parameter names given in params.

Return type:

numpy.array

pycbc.inference.jump.normal.load_opts(cp, section, tag, skip=None)[source]

Loads config options for jump proposals.

All - in option names are converted to _ before returning.

Parameters:
  • cp (WorkflowConfigParser instance) – Config file to read from.
  • section (str) – The name of the section to look in.
  • tag (str) – pycbc.VARARGS_DELIM separated list of parameter names to create proposals for.
  • skip (list, optional) – List of option names to skip loading.
Returns:

  • params (list) – List of parameter names the jump proposal is for.
  • opts (dict) – Dictionary of option names -> values, where all values are strings.

Module contents

Provides custom jump proposals for samplers.

pycbc.inference.jump.epsie_proposals_from_config(cp, section='jump_proposal')[source]

Loads epsie jump proposals from the given config file.

This loads jump proposals from sub-sections starting with section (default is ‘jump_proposal’). The tag part of the sub-sections’ headers should list the parameters the proposal is to be used for.

Example:

[jump_proposal-mtotal+q]
name = adaptive_normal
adaptation-duration = 1000
min-q = 1
max-q = 8
min-mtotal = 20
max-mtotal = 160

[jump_proposal-spin1_a]
name = normal
Parameters:
  • cp (WorkflowConfigParser instance) – The config file to read.
  • section (str, optional) – The section name to read jump proposals from. Default is 'jump_proposal'.
Returns:

List of the proposal instances.

Return type:

list