bilby.core.prior.conditional.ConditionalSymmetricLogUniform
- class bilby.core.prior.conditional.ConditionalSymmetricLogUniform(condition_func, name=None, latex_label=None, unit=None, boundary=None, **reference_params)[source]
Bases:
ConditionalPrior
- __init__(condition_func, name=None, latex_label=None, unit=None, boundary=None, **reference_params)[source]
- Parameters:
- condition_func: func
Functional form of the condition for this prior. The first function argument has to be a dictionary for the reference_params (see below). The following arguments are the required variables that are required before we can draw this prior. It needs to return a dictionary with the modified values for the reference_params that are being used in the next draw. For example if we have a Uniform prior for x depending on a different variable y p(x|y) with the boundaries linearly depending on y, then this could have the following form:
def condition_func(reference_params, y): return dict( minimum=reference_params['minimum'] + y, maximum=reference_params['maximum'] + y )
- name: str, optional
See superclass
- latex_label: str, optional
See superclass
- unit: str, optional
See superclass
- boundary: str, optional
See superclass
- reference_params:
Initial values for attributes such as minimum, maximum. This differs on the prior_class, for example for the Gaussian prior this is mu and sigma.
- __call__()[source]
Overrides the __call__ special method. Calls the sample method.
- Returns:
- float: The return value of the sample method.
Methods
__init__
(condition_func[, name, ...])cdf
(val, **required_variables)Return the cdf of val.
from_json
(dct)from_repr
(string)Generate the prior from its __repr__
get_instantiation_dict
()is_in_prior_range
(val)Returns True if val is in the prior boundaries, zero otherwise
ln_prob
(val, **required_variables)Return the natural log prior probability of val.
prob
(val, **required_variables)Return the prior probability of val.
rescale
(val, **required_variables)'Rescale' a sample from the unit line element to the prior.
Reset the object attributes to match the original reference parameters
sample
([size])Draw a sample from the prior
to_json
()update_conditions
(**required_variables)This method updates the conditional parameters (depending on the parent class this could be e.g. minimum, maximum, mu, sigma, etc.) of this prior class depending on the required variables it depends on.
Attributes
boundary
condition_func
Returns True if the prior is fixed and should not be used in the sampler.
Latex label that can be used for plots.
If a unit is specified, returns a string of the latex label and unit
maximum
minimum
Initial values for attributes such as minimum, maximum.
The required variables to pass into the condition function.
unit
width
- cdf(val, **required_variables)[source]
Return the cdf of val.
- Parameters:
- val: Union[float, int, array_like]
See superclass
- required_variables:
Any required variables that this prior depends on
- Returns:
- float: CDF of val
- property is_fixed
Returns True if the prior is fixed and should not be used in the sampler. Does this by checking if this instance is an instance of DeltaFunction.
- Returns:
- bool: Whether it’s fixed or not!
- is_in_prior_range(val)[source]
Returns True if val is in the prior boundaries, zero otherwise
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- np.nan
- property latex_label
Latex label that can be used for plots.
Draws from a set of default labels if no label is given
- Returns:
- str: A latex representation for this prior
- property latex_label_with_unit
If a unit is specified, returns a string of the latex label and unit
- ln_prob(val, **required_variables)[source]
Return the natural log prior probability of val.
- Parameters:
- val: Union[float, int, array_like]
See superclass
- required_variables:
Any required variables that this prior depends on
- Returns:
- float: Natural log prior probability of val
- prob(val, **required_variables)[source]
Return the prior probability of val.
- Parameters:
- val: Union[float, int, array_like]
See superclass
- required_variables:
Any required variables that this prior depends on
- Returns:
- float: Prior probability of val
- property reference_params
Initial values for attributes such as minimum, maximum. This depends on the prior_class, for example for the Gaussian prior this is mu and sigma. This is read-only.
- property required_variables
The required variables to pass into the condition function.
- rescale(val, **required_variables)[source]
‘Rescale’ a sample from the unit line element to the prior.
- Parameters:
- val: Union[float, int, array_like]
See superclass
- required_variables:
Any required variables that this prior depends on
- reset_to_reference_parameters()[source]
Reset the object attributes to match the original reference parameters
- sample(size=None, **required_variables)[source]
Draw a sample from the prior
- Parameters:
- size: int or tuple of ints, optional
See superclass
- required_variables:
Any required variables that this prior depends on
- Returns:
- float: See superclass
- update_conditions(**required_variables)[source]
This method updates the conditional parameters (depending on the parent class this could be e.g. minimum, maximum, mu, sigma, etc.) of this prior class depending on the required variables it depends on.
If no variables are given, the most recently used conditional parameters are kept
- Parameters:
- required_variables:
Any required variables that this prior depends on. If none are given, self.reference_params will be used.