bilby.gw.prior.UniformComovingVolume
- class bilby.gw.prior.UniformComovingVolume(minimum, maximum, cosmology=None, name=None, latex_label=None, unit=None, boundary=None)[source]
Bases:
Cosmological
Prior that is uniform in the comoving volume.
Note that this does not account for time dilation in the source frame use bilby.gw.prior.UniformSourceFrame to include that effect.
\[p(z) \propto \frac{d V_{c}}{dz}\]- __init__(minimum, maximum, cosmology=None, name=None, latex_label=None, unit=None, boundary=None)[source]
- Parameters:
- minimum: float
The minimum value for the distribution.
- maximum: float
The maximum value for the distribution.
- cosmology: Union[None, str, dict, astropy.cosmology.FLRW]
The cosmology to use, see bilby.gw.cosmology.set_cosmology for more details. If
None
, the default cosmology will be used.- name: str
The name of the parameter, should be one of
[luminosity_distance, comoving_distance, redshift]
.- latex_label: str
Latex string to use in plotting, if
None
, this will be set automatically using the name.- unit: Union[str, astropy.units.Unit]
The unit of the maximum and minimum values,
default=Mpc
.- boundary: str
The boundary condition to apply to the prior when sampling.
- __call__()[source]
Overrides the __call__ special method. Calls the sample method.
- Returns:
- float: The return value of the sample method.
Methods
__init__
(minimum, maximum[, cosmology, ...])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_corresponding_prior
([name, unit])Utility method to convert between equivalent redshift, comoving distance, and luminosity distance priors.
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 the unit line element to the 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
Return maximum of the prior distribution.
Return minimum of the prior distribution.
unit
width
Return p(xx) values of the interpolated prior function.
- get_corresponding_prior(name=None, unit=None)[source]
Utility method to convert between equivalent redshift, comoving distance, and luminosity distance priors.
- Parameters:
- name: str
The name of the new prior, this should be one of
[luminosity_distance, comoving_distance, redshift]
.- unit: Union[str, astropy.units.Unit]
The unit of the output prior.
- Returns:
- The corresponding prior.
- 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
- property maximum
Return maximum of the prior distribution.
Updates the prior distribution if maximum is set to a different value.
Yields an error if value is set above instantiated x-array maximum.
- Returns:
- float: Maximum of the prior distribution
- property minimum
Return minimum of the prior distribution.
Updates the prior distribution if minimum is set to a different value.
Yields an error if value is set below instantiated x-array minimum.
- Returns:
- float: Minimum of the prior distribution
- prob(val)[source]
Return the prior probability of val.
- Parameters:
- val: Union[float, int, array_like]
- Returns:
- Union[float, array_like]: Prior probability of val
- rescale(val)[source]
‘Rescale’ a sample from the unit line element to the prior.
This maps to the inverse CDF. This is done using interpolation.
- 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
- property yy
Return p(xx) values of the interpolated prior function.
Updates the prior distribution if it is changed
- Returns:
- array_like: p(xx) values