bilby.core.prior.analytical.Triangular
- class bilby.core.prior.analytical.Triangular(mode, minimum, maximum, name=None, latex_label=None, unit=None)[source]
Bases:
Prior
Define a new prior class which draws from a triangular distribution.
For distribution details see: wikipedia.org/wiki/Triangular_distribution
Here, minimum <= mode <= maximum, where the mode has the highest pdf value.
- __init__(mode, minimum, maximum, name=None, latex_label=None, unit=None)[source]
Implements a Prior object
- Parameters:
- name: str, optional
Name associated with prior.
- latex_label: str, optional
Latex label associated with prior, used for plotting.
- unit: str, optional
If given, a Latex string describing the units of the parameter.
- minimum: float, optional
Minimum of the domain, default=-np.inf
- maximum: float, optional
Maximum of the domain, default=np.inf
- check_range_nonzero: boolean, optional
If True, checks that the prior range is non-zero
- boundary: str, optional
The boundary condition of the prior, can be ‘periodic’, ‘reflective’ Currently implemented in cpnest, dynesty and pymultinest.
- __call__()[source]
Overrides the __call__ special method. Calls the sample method.
- Returns:
- float: The return value of the sample method.
Methods
__init__
(mode, minimum, maximum[, name, ...])Implements a Prior object
cdf
(val)Return the prior cumulative probability at 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)Return the prior ln probability of val, this should be overwritten
prob
(val)Return the prior probability of val
rescale
(val)'Rescale' a sample from standard uniform to a triangular distribution.
sample
([size])Draw a sample from the prior
to_json
()Attributes
boundary
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
unit
width
- cdf(val)[source]
Return the prior cumulative probability at val
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- float: prior cumulative probability at 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)[source]
Return the prior ln probability of val, this should be overwritten
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- np.nan
- prob(val)[source]
Return the prior probability of val
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- float: Prior probability of val