bilby.gw.prior.HealPixPrior

class bilby.gw.prior.HealPixPrior(dist, name=None, latex_label=None, unit=None)[source]

Bases: JointPrior

A prior distribution that follows a user-provided HealPix map for one parameter.

See bilby.gw.prior.HealPixMapPriorDist for more details of how to instantiate the prior.

__init__(dist, name=None, latex_label=None, unit=None)[source]
Parameters:
dist: bilby.gw.prior.HealPixMapPriorDist

The base joint probability.

name: str

The name of the parameter, it should be contained in the map. One of [“ra”, “dec”, “luminosity_distance”].

latex_label: str

Latex label used for plotting, will be read from default values if not provided.

unit: str

The unit of the parameter.

__call__()[source]

Overrides the __call__ special method. Calls the sample method.

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

Methods

__init__(dist[, name, latex_label, unit])

Parameters:

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 natural logarithm of the prior probability.

prob(val)

Return the prior probability of val

rescale(val, **kwargs)

Scale a unit hypercube sample 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 natural logarithm of the prior probability. Note that this will not be correctly normalised if there are bounds on the distribution.

Parameters:
val: array_like

value to evaluate the prior log-prob at

Returns
=======
float:

the logp value for the prior at given sample

prob(val)[source]

Return the prior probability of val

Parameters:
val: array_like

value to evaluate the prior prob at

Returns:
float:

the p value for the prior at given sample

rescale(val, **kwargs)[source]

Scale a unit hypercube sample to the prior.

Parameters:
val: array_like

value drawn from unit hypercube to be rescaled onto the prior

kwargs: dict

all kwargs passed to the dist.rescale method

Returns
=======
float:

A sample from the prior parameter.

sample(size=1, **kwargs)[source]

Draw a sample from the prior.

Parameters:
size: int, float (defaults to 1)

number of samples to draw

kwargs: dict

kwargs passed to the dist.sample method

Returns
=======
float:

A sample from the prior parameter.