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:
epsie.proposals.angular.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()
withcls
set toepsie.proposals.AdaptiveBoundedNormal
andwith_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: Returns: An adaptive angular proposal for use with
epsie
samplers.Return type: epsie.proposals.AdaptiveAngularProposal
-
classmethod
-
class
pycbc.inference.jump.angular.
EpsieAdaptiveAngular
(parameters, adaptation_duration, jump_interval=1, start_step=1, **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()
withcls
set toepsie.proposals.AdaptiveBoundedNormal
andwith_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: Returns: An adaptive angular proposal for use with
epsie
samplers.Return type: epsie.proposals.AdaptiveAngular
-
classmethod
-
class
pycbc.inference.jump.angular.
EpsieAngular
(parameters, cov=None, jump_interval=1, jump_interval_duration=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()
withcls
set toepsie.proposals.Angular
andwith_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: Returns: An angular proposal for use with
epsie
samplers.Return type: epsie.proposals.Angular
-
classmethod
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:
epsie.proposals.bounded_normal.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()
withcls
set 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
epsie
samplers.Return type: epsie.proposals.AdaptiveBoundedProposal
-
classmethod
-
class
pycbc.inference.jump.bounded_normal.
EpsieAdaptiveBoundedNormal
(parameters, boundaries, adaptation_duration, start_step=1, jump_interval=1, **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()
withcls
set 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
epsie
samplers.Return type: epsie.proposals.AdaptiveBoundedNormal
-
classmethod
-
class
pycbc.inference.jump.bounded_normal.
EpsieBoundedNormal
(parameters, boundaries, cov=None, jump_interval=1, jump_interval_duration=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()
withcls
set toepsie.proposals.BoundedNormal
andwith_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: Returns: A bounded normal proposal for use with
epsie
samplers.Return type: epsie.proposals.BoundedNormal
-
classmethod
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:
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()
withcls
set 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
epsie
samplers.Return type: epsie.proposals.AdaptiveBoundedDiscrete
-
classmethod
-
class
pycbc.inference.jump.discrete.
EpsieAdaptiveNormalDiscrete
(parameters, prior_widths, adaptation_duration, successive=None, jump_interval=1, **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()
withcls
set 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
epsie
samplers.Return type: epsie.proposals.AdaptiveBoundedDiscrete
-
classmethod
-
class
pycbc.inference.jump.discrete.
EpsieBoundedDiscrete
(parameters, boundaries, cov=None, successive=None, jump_interval=1, jump_interval_duration=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()
withcls
set toepsie.proposals.BoundedDiscrete
andwith_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: Returns: A bounded discrete proposal for use with
epsie
samplers.Return type: epsie.proposals.BoundedDiscrete
-
classmethod
-
class
pycbc.inference.jump.discrete.
EpsieNormalDiscrete
(parameters, cov=None, successive=None, jump_interval=1, jump_interval_duration=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()
withcls
set toepsie.proposals.NormalDiscrete
andwith_boundaries
set 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
epsie
samplers.Return type: epsie.proposals.BoundedDiscrete
-
classmethod
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:
epsie.proposals.normal.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()
withcls
set toepsie.proposals.AdaptiveProposal
andwith_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: Returns: An adaptive proposal for use with
epsie
samplers.Return type: epsie.proposals.AdaptiveProposal
-
classmethod
-
class
pycbc.inference.jump.normal.
EpsieAdaptiveNormal
(parameters, prior_widths, adaptation_duration, start_step=1, jump_interval=1, **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()
withcls
set 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
epsie
samplers.Return type: epsie.proposals.AdaptiveNormal
-
classmethod
-
class
pycbc.inference.jump.normal.
EpsieNormal
(parameters, cov=None, jump_interval=1, jump_interval_duration=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()
withcls
set toepsie.proposals.Normal
andwith_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: Returns: A normal proposal for use with
epsie
samplers.Return type: epsie.proposals.Normal
-
classmethod
-
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_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 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_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
- Sets the
adaptation_duration
. If not provided will use the class’s default.
- diagonal : bool, optional
- Determines whether only to adapt the variance. If True will only train the diagonal elements.
- componentwise : bool, 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-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.
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_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. Ifwith_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 foradaptation_decay
,start_iteration
, andtarget_rate
, but these are optional. Arguments will be popped from the given dictionary.Parameters: Returns: Dictionary of argument name -> values.
Return type:
-
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 forn
.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:
-
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
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:
-
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 givenopts
dictionary. If not found,default
will 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
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: