bilby.core.prior.analytical.Categorical
- class bilby.core.prior.analytical.Categorical(ncategories, name=None, latex_label=None, unit=None, boundary='periodic')[source]
Bases:
Prior
- __init__(ncategories, name=None, latex_label=None, unit=None, boundary='periodic')[source]
An equal-weighted Categorical prior
- Parameters:
- ncategories: int
The number of available categories. The prior mass support is then integers [0, ncategories - 1].
- name: str
See superclass
- latex_label: str
See superclass
- unit: str
See superclass
- __call__()[source]
Overrides the __call__ special method. Calls the sample method.
- Returns:
- float: The return value of the sample method.
Methods
__init__
(ncategories[, name, latex_label, ...])An equal-weighted Categorical prior
cdf
(val)Generic method to calculate CDF, can be overwritten in subclass
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 logarithmic prior probability of val
prob
(val)Return the prior probability of val.
rescale
(val)'Rescale' a sample from the unit line element to the categorical prior.
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
- 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 logarithmic prior probability of val
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- float:
- prob(val)[source]
Return the prior probability of val.
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- float: Prior probability of val