gravelamps.prior.discrete

Discrete prior class implementations

class gravelamps.prior.discrete.DiscretePowerLaw(ncategories, alpha=1, name='num_images', latex_label='$n_{\\mathrm{signals}}$', unit=None)

Bases: Prior

Discrete power law prior for handling the number of millisignals.

Attributes:
ncategories: int

Number of millisignals (including primary).

alpha: float, default=1

Exponent of the power law.

name: str, default=’num_images’

Name of the parameter used.

latex_label: str, default=’$n_{mathrm{signals}}$’

The latex compatible output to be used on plots.

unit: str, default=None

Unit of the prior.

Methods

__call__()

Overrides the __call__ special method.

cdf(val)

Calculate the CDF for sample values.

from_repr(string)

Generate the prior from its __repr__

is_in_prior_range(val)

Returns True if val is in the prior boundaries, zero otherwise

ln_prob(val)

Calculate the log of the probability of the sample values.

prob(val)

Calculate the probability of sample values.

rescale(val)

Rescales a sample from the unit line element to the categories according to the power law prior.

sample([size])

Draw a sample from the prior

from_json

get_instantiation_dict

to_json

cdf(val)

Calculate the CDF for sample values.

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

Sample values.

Returns:
Union[float, ArrayLike]
ln_prob(val)

Calculate the log of the probability of the sample values.

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

Sample values.

Returns:
Union[float, ArrayLike]
prob(val)

Calculate the probability of sample values.

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

Sample values.

Returns:
Union[float, ArrayLike]
rescale(val)

Rescales a sample from the unit line element to the categories according to the power law prior.

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

Uniform probability between 0 and 1.

Returns:
Union[float, ArrayLike]
class gravelamps.prior.discrete.DiscreteUniform(ncategories, name='num_images', latex_label='$n_{\\mathrm{signals}}$', unit=None)

Bases: Categorical

Discrete uniform prior for handling the number of millisignals. This modifies the parent class such that the minimum must be 1 instead of 0.

Attributes:
ncategories: int

Number of millisignals (including primary).

name: str, default=’num_images’

Name of the parameter used.

latex_label: str, default=’$n_{mathrm{signals}}$’

The latex compatible output to be used on plots.

unit: str, default=None

Unit of the parameter

Methods

__call__()

Overrides the __call__ special method.

cdf(val)

Calculates the CDF for sample values.

from_repr(string)

Generate the prior from its __repr__

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)

Rescales a sample from the unit line element to one of the categories.

sample([size])

Draw a sample from the prior

from_json

get_instantiation_dict

to_json

cdf(val)

Calculates the CDF for sample values.

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

Sample values.

Returns:
Union[float, ArrayLike]
rescale(val)

Rescales a sample from the unit line element to one of the categories.

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

Uniform probability between 0 and 1

Returns:
Union[float, ArrayLike]
class gravelamps.prior.discrete.UniformMorseIndex(name='morse_index', latex_label='$n$', unit=None)

Bases: Categorical

Discrete uniform prior over the possible values of the Morse index.

This is a restricted subset of the Categorical prior to the cases of 0, 0.5, and 1. These are the allowed values of the Morse index.

Attributes:
name: str, default=’morse_index’

Name of the parameter used.

latex_label: str, default=’$n$’

The latex compatible output to be used on plots, etc.

unit: str, default=None

Unit of the parameter

Methods

__call__()

Overrides the __call__ special method.

cdf(val)

Calculate the CDF for sample values.

from_repr(string)

Generate the prior from its __repr__

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)

Rescales a sample from the unit line element to one of the categories.

sample([size])

Draw a sample from the prior

from_json

get_instantiation_dict

to_json

cdf(val)

Calculate the CDF for sample values.

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

Sample values.

Returns:
Union[float, ArrayLike]
rescale(val)

Rescales a sample from the unit line element to one of the categories.

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

Uniform probability between 0 and 1

Returns:
Union[float, ArrayLike]