pycbc.inference.jump package

Submodules

pycbc.inference.jump.angular module

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

class pycbc.inference.jump.angular.EpsieATAdaptiveAngular(parameters, adaptation_duration, componentwise=False, start_step=1, target_rate=None, jump_interval=1)[source]

Bases: ATAdaptiveAngular

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_proposal
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.AdaptiveAngularProposal

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

Bases: 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, jump_interval=1, jump_interval_duration=None)[source]

Bases: 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.EpsieATAdaptiveBoundedNormal(parameters, boundaries, adaptation_duration, componentwise=False, start_step=1, target_rate=None, jump_interval=1)[source]

Bases: ATAdaptiveBoundedNormal

Adds from_config method to epsie’s adaptive bounded 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.AdaptiveBoundedProposal. See that function for details on options that can be read.

Example:

[jump_proposal-q]
name = adaptive_bounded_proposal
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 bounded proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveBoundedProposal

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

Bases: 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, jump_interval=1, jump_interval_duration=None)[source]

Bases: 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, jump_interval=1, **kwargs)[source]

Bases: 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, jump_interval=1, **kwargs)[source]

Bases: 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, jump_interval=1, jump_interval_duration=None)[source]

Bases: 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, jump_interval=1, jump_interval_duration=None)[source]

Bases: 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.EpsieATAdaptiveNormal(parameters, adaptation_duration, diagonal=False, componentwise=False, start_step=1, target_rate=None, jump_interval=1)[source]

Bases: ATAdaptiveNormal

Adds from_config method to epsie’s ATAdaptiveProposal.

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.AdaptiveProposal and with_boundaries set to False. See that function for details on options that can be read.

Example:

[jump_proposal-mchrip+q]
name = adaptive_proposal
diagonal =
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 proposal for use with epsie samplers.

Return type:

epsie.proposals.AdaptiveProposal

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

Bases: 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, jump_interval=1, jump_interval_duration=None)[source]

Bases: 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:

  • namestr

    Required. Must match the name of the proposal.

  • adaptation-durationint

    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-decayint

    Optional. Sets the adaptation_decay. If not provided, will use the class’s default.

  • start-iterationint

    Optional. Sets the start_iteration.If not provided, will use the class’s default.

  • target-ratefloat

    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_at_adaptive_from_config(cls, cp, section, tag, with_boundaries=False)[source]

Generic function for loading AT Adaptive Normal 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:

  • namestr

    Required. Must match the name of the proposal.

  • adaptation-durationint

    Sets the adaptation_duration. If not provided will use the class’s default.

  • diagonalbool, optional

    Determines whether only to adapt the variance. If True will only train the diagonal elements.

  • componentwisebool, optional

    Whether to include a componentwise scaling of the parameters. By default set to False. Componentwise scaling ndim times more expensive than global scaling.

  • 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.

  • start-iterationint

    Optional. Sets the start_iteration. If not provided, will use the class’s default.

  • target-ratefloat

    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.

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:

  • namestr

    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, name=None)[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.

  • name (str (optional)) – Proposal name

Returns:

Dictionary of argument name -> values.

Return type:

dict

pycbc.inference.jump.normal.get_epsie_discrete_successive_settings(params, opts)[source]

Get settings for Epsie successive discrete proposal successive jumps from a config file.

If successive is not defined for a parameter then assumes successive jumps are not allowed (i.e. jumps from an integer to the same integer). Arguments will be popped from the given dictionary.

Example::

[jump_proposal-k+n] name = discrete successive-k =

This example sets successive jumps for k but does not do so for n.

Parameters:
  • params (list of str) – List of parameter names to get the successive option for.

  • opts (dict) – Dictionary of option -> value that was loaded from a config file section.

Returns:

Dictionary of parameter names -> bools

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