bilby.gw.prior.UniformInComponentsMassRatio

class bilby.gw.prior.UniformInComponentsMassRatio(minimum, maximum, name='mass_ratio', latex_label='$q$', unit=None, boundary=None, equal_mass=False)[source]

Bases: Prior

Prior distribution for chirp mass which is uniform in component masses.

This is useful when chirp mass and mass ratio are sampled while the prior is uniform in component masses.

\[p(q) \propto \frac{(1 + q)^{2/5}}{q^{6/5}}\]

Notes

This prior is intended to be used in conjunction with the corresponding bilby.gw.prior.UniformInComponentsChirpMass.

__init__(minimum, maximum, name='mass_ratio', latex_label='$q$', unit=None, boundary=None, equal_mass=False)[source]
Parameters:
minimumfloat

The minimum of mass ratio

maximumfloat

The maximum of mass ratio

name: see superclass
latex_label: see superclass
unit: see superclass
boundary: see superclass
equal_mass: bool

Whether the likelihood being considered is expected to peak at equal masses. If True, the mapping described in Appendix A of arXiv:2111.13619 is used in the rescale method. default=False

__call__()[source]

Overrides the __call__ special method. Calls the sample method.

Returns:
float: The return value of the sample method.

Methods

__init__(minimum, maximum[, name, ...])

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 prior ln probability of val, this should be overwritten

prob(val)

Return the prior probability of val, this should be overwritten

rescale(val)

'Rescale' a sample from the unit line element to the prior.

sample([size])

Draw a sample from the prior

to_json()

Attributes

boundary

is_fixed

Returns True if the prior is fixed and should not be used in the sampler.

latex_label

Latex label that can be used for plots.

latex_label_with_unit

If a unit is specified, returns a string of the latex label and unit

maximum

minimum

unit

width

cdf(val)[source]

Generic method to calculate CDF, can be overwritten in subclass

classmethod from_repr(string)[source]

Generate the prior from its __repr__

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, this should be overwritten

Parameters:
val: Union[float, int, array_like]
Returns:
np.nan
rescale(val)[source]

‘Rescale’ a sample from the unit line element to the prior.

This should be overwritten by each subclass.

Parameters:
val: Union[float, int, array_like]

A random number between 0 and 1

Returns:
None
sample(size=None)[source]

Draw a sample from the prior

Parameters:
size: int or tuple of ints, optional

See numpy.random.uniform docs

Returns:
float: A random number between 0 and 1, rescaled to match the distribution of this Prior