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:
ATAdaptiveAngularAdds
from_configmethod 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()withclsset toepsie.proposals.AdaptiveBoundedNormalandwith_boundariesset 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:
- Returns:
An adaptive angular proposal for use with
epsiesamplers.- Return type:
epsie.proposals.AdaptiveAngularProposal
- class pycbc.inference.jump.angular.EpsieAdaptiveAngular(parameters, adaptation_duration, jump_interval=1, start_step=1, **kwargs)[source]
Bases:
AdaptiveAngularAdds
from_configmethod 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()withclsset toepsie.proposals.AdaptiveBoundedNormalandwith_boundariesset 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:
- Returns:
An adaptive angular proposal for use with
epsiesamplers.- Return type:
epsie.proposals.AdaptiveAngular
- class pycbc.inference.jump.angular.EpsieAngular(parameters, cov=None, jump_interval=1, jump_interval_duration=None)[source]
Bases:
AngularAdds
from_configmethod to epsie’s angular proposal.- classmethod from_config(cp, section, tag)[source]
Loads a proposal from a config file.
This calls
epsie_from_config()withclsset toepsie.proposals.Angularandwith_boundariesset to False. See that function for details on options that can be read.Example:
[jump_proposal-ra] name = angular var-ra = 0.01
- Parameters:
- Returns:
An angular proposal for use with
epsiesamplers.- 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:
ATAdaptiveBoundedNormalAdds
from_configmethod 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()withclsset toepsie.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:
- Returns:
An adaptive bounded proposal for use with
epsiesamplers.- 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:
AdaptiveBoundedNormalAdds
from_configmethod 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()withclsset toepsie.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:
- Returns:
An adaptive normal proposal for use with
epsiesamplers.- 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:
BoundedNormalAdds
from_configmethod 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()withclsset toepsie.proposals.BoundedNormalandwith_boundariesset 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:
- Returns:
A bounded normal proposal for use with
epsiesamplers.- 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:
AdaptiveBoundedDiscreteAdds
from_configmethod 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()withclsset toepsie.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:
- Returns:
An adaptive normal proposal for use with
epsiesamplers.- Return type:
epsie.proposals.AdaptiveBoundedDiscrete
- class pycbc.inference.jump.discrete.EpsieAdaptiveNormalDiscrete(parameters, prior_widths, adaptation_duration, successive=None, jump_interval=1, **kwargs)[source]
Bases:
AdaptiveNormalDiscreteAdds
from_configmethod 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()withclsset toepsie.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:
- Returns:
An adaptive normal proposal for use with
epsiesamplers.- 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:
BoundedDiscreteAdds
from_configmethod 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()withclsset toepsie.proposals.BoundedDiscreteandwith_boundariesset 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:
- Returns:
A bounded discrete proposal for use with
epsiesamplers.- 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:
NormalDiscreteAdds
from_configmethod 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()withclsset toepsie.proposals.NormalDiscreteandwith_boundariesset to False. See that function for details on options that can be read.Example:
[jump_proposal-index] name = discrete
- Parameters:
- Returns:
A bounded discrete proposal for use with
epsiesamplers.- 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:
ATAdaptiveNormalAdds
from_configmethod to epsie’s ATAdaptiveProposal.- classmethod from_config(cp, section, tag)[source]
Loads a proposal from a config file.
This calls
epsie_from_config()withclsset toepsie.proposals.AdaptiveProposalandwith_boundariesset to False. See that function for details on options that can be read.Example:
[jump_proposal-mchrip+q] name = adaptive_proposal diagonal =
- Parameters:
- Returns:
An adaptive proposal for use with
epsiesamplers.- 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:
AdaptiveNormalAdds
from_configmethod 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()withclsset toepsie.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:
- Returns:
An adaptive normal proposal for use with
epsiesamplers.- Return type:
epsie.proposals.AdaptiveNormal
- class pycbc.inference.jump.normal.EpsieNormal(parameters, cov=None, jump_interval=1, jump_interval_duration=None)[source]
Bases:
NormalAdds
from_configmethod to epsie’s normal proposal.- classmethod from_config(cp, section, tag)[source]
Loads a proposal from a config file.
This calls
epsie_from_config()withclsset toepsie.proposals.Normalandwith_boundariesset 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:
- Returns:
A normal proposal for use with
epsiesamplers.- 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 apycbc.VARARGS_DELIMseparated 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_boundariesis 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.AdaptiveSupportfor 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_DELIMseparated list of parameter names to create proposals for.with_boundaries (bool, optional) – Try to load boundaries from the section and pass a
boundariesargument 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_boundariesis True). Provided because some adaptive proposals that only need the boundary widths call thisprior_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 apycbc.VARARGS_DELIMseparated 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_boundariesis 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_DELIMseparated list of parameter names to create proposals for.with_boundaries (bool, optional) – Try to load boundaries from the section and pass a
boundariesargument 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 apycbc.VARARGS_DELIMseparated 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_boundariesis 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. Ifwith_boundariesis False, will use a default value of 1.
min-{param} : float
- max-{param}float
The bounds on each parameter. Required if
with_boundariesis 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_DELIMseparated list of parameter names to create proposals for.with_boundaries (bool, optional) – Try to load boundaries from the section and pass a
boundariesargument 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_durationis in the given dictionary. It will also look foradaptation_decay,start_iteration, andtarget_rate, but these are optional. Arguments will be popped from the given dictionary.
- 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
successiveis 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
kbut does not do so forn.
- 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 inparams. If the opts are created usingload_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
optsdictionary.
- 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 inparams. If found, the argument is popped from the givenoptsdictionary. If not found,defaultwill be used.- Parameters:
- 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:
- 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