bilby.core.prior.conditional.DirichletElement

class bilby.core.prior.conditional.DirichletElement(order, n_dimensions, label)[source]

Bases: ConditionalBeta

Single element in a dirichlet distribution

The probability scales as

\[p(x_n) \propto (x_\max - x_n)^{(N - n - 2)}\]

for \(x_n < x_\max\), where \(x_\max\) is the sum of \(x_i\) for \(i < n\)

Parameters:
order: int

Order of this element of the dirichlet distribution.

n_dimensions: int

Total number of elements of the dirichlet distribution

label: str

Label for the dirichlet distribution. This should be the same for all elements.

Examples

n_dimensions = 1:

\[p(x_0) \propto 1 ; 0 < x_0 < 1\]
n_dimensions = 2:
\[p(x_0) &\propto (1 - x_0) ; 0 < x_0 < 1 p(x_1) &\propto 1 ; 0 < x_1 < 1\]
__init__(order, n_dimensions, label)[source]
__call__()[source]

Overrides the __call__ special method. Calls the sample method.

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

Methods

__init__(order, n_dimensions, label)

cdf(val, **required_variables)

Return the cdf of val.

dirichlet_condition(reference_parms, **kwargs)

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, **required_variables)

Return the natural log prior probability of val.

prob(val, **required_variables)

Return the prior probability of val.

rescale(val, **required_variables)

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

reset_to_reference_parameters()

Reset the object attributes to match the original reference parameters

sample([size])

Draw a sample from the prior

to_json()

update_conditions(**required_variables)

This method updates the conditional parameters (depending on the parent class this could be e.g. minimum, maximum, mu, sigma, etc.) of this prior class depending on the required variables it depends on.

Attributes

boundary

condition_func

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

reference_params

Initial values for attributes such as minimum, maximum.

required_variables

The required variables to pass into the condition function.

unit

width

cdf(val, **required_variables)[source]

Return the cdf of val.

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

See superclass

required_variables:

Any required variables that this prior depends on

Returns:
float: CDF of val
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, **required_variables)[source]

Return the natural log prior probability of val.

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

See superclass

required_variables:

Any required variables that this prior depends on

Returns:
float: Natural log prior probability of val
prob(val, **required_variables)[source]

Return the prior probability of val.

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

See superclass

required_variables:

Any required variables that this prior depends on

Returns:
float: Prior probability of val
property reference_params

Initial values for attributes such as minimum, maximum. This depends on the prior_class, for example for the Gaussian prior this is mu and sigma. This is read-only.

property required_variables

The required variables to pass into the condition function.

rescale(val, **required_variables)[source]

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

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

See superclass

required_variables:

Any required variables that this prior depends on

reset_to_reference_parameters()[source]

Reset the object attributes to match the original reference parameters

sample(size=None, **required_variables)[source]

Draw a sample from the prior

Parameters:
size: int or tuple of ints, optional

See superclass

required_variables:

Any required variables that this prior depends on

Returns:
float: See superclass
update_conditions(**required_variables)[source]

This method updates the conditional parameters (depending on the parent class this could be e.g. minimum, maximum, mu, sigma, etc.) of this prior class depending on the required variables it depends on.

If no variables are given, the most recently used conditional parameters are kept

Parameters:
required_variables:

Any required variables that this prior depends on. If none are given, self.reference_params will be used.