autofit.GaussianPrior#

class GaussianPrior[source]#

Bases: Prior

A Gaussian prior defined by a normal distribution.

The prior transforms a unit interval input u in [0, 1] into a physical parameter p via the inverse error function (erfcinv) based on the Gaussian CDF:

\[p = \mu + \sigma \sqrt{2} \, \mathrm{erfcinv}(2 \times (1 - u))\]

where \(\mu\) is the mean and \(\sigma\) the standard deviation.

For example, with mean=1.0 and sigma=2.0, the value at u=0.5 corresponds to the mean, 1.0.

This mapping is implemented using a NormalMessage instance, encapsulating the Gaussian distribution and any specified truncation limits.

Parameters:
  • mean (float) – The mean (center) of the Gaussian prior distribution.

  • sigma (float) – The standard deviation (spread) of the Gaussian prior.

  • id (Optional[int], optional) – Optional identifier for the prior instance.

Examples

Create a GaussianPrior with mean 1.0, sigma 2.0, truncated between 0.0 and 2.0:

>>> prior = GaussianPrior(mean=1.0, sigma=2.0)
>>> physical_value = prior.value_for(unit=0.5)  # Returns ~1.0 (mean)

Methods

dict

Return a dictionary representation of this GaussianPrior instance, including mean and sigma.

for_class_and_attribute_name

Create a prior from the configuration for a given class and attribute.

from_dict

Returns a prior from a JSON representation.

gaussian_prior_model_for_arguments

Look up this prior in an arguments dict and return the mapped value.

has

Does this instance have an attribute which is of type cls?

instance_for_arguments

Look up this prior's value in an arguments dictionary.

make_indexes

name_of_class

A string name for the class, with the prior suffix removed.

new

Returns a copy of this prior with a new id assigned making it distinct

next_id

project

Project this prior given samples and log weights from a search.

random

A random value sampled from this prior

replacing_for_path

Create a new model replacing the value for a given path with a new value

tree_flatten

Flatten this prior into a JAX-compatible PyTree representation.

tree_unflatten

Create a prior from a flattened PyTree

unit_value_for

Compute the unit value between 0 and 1 for the physical value.

value_for

Map a unit value in [0, 1] to a physical value drawn from this Gaussian prior.

with_limits

Create a new gaussian prior centred between two limits with sigma distance between this limits.

with_message

Return a copy of this prior with a different message (distribution).

Attributes

component_number

factor

A callable PDF used as a factor in factor graphs

identifier

label

limits

The (lower, upper) bounds of this prior.

name

ndim

How many dimensions does this variable have?

parameter_string

Return a human-readable string summarizing the GaussianPrior parameters.

tree_flatten()[source]#

Flatten this prior into a JAX-compatible PyTree representation.

Returns:

A (children, aux_data) pair where children are (mean, sigma, id).

Return type:

tuple

classmethod with_limits(lower_limit, upper_limit)[source]#

Create a new gaussian prior centred between two limits with sigma distance between this limits.

Note that these limits are not strict so exceptions will not be raised for values outside of the limits.

This function is typically used in prior passing, where the result of a model-fit are used to create new Gaussian priors centred on the previously estimated median PDF model.

Parameters:
  • lower_limit (float) – The lower limit of the new Gaussian prior.

  • upper_limit (float) – The upper limit of the new Gaussian Prior.

Return type:

A new GaussianPrior

dict()[source]#

Return a dictionary representation of this GaussianPrior instance, including mean and sigma.

Return type:

Dictionary containing prior parameters.

property parameter_string: str#

Return a human-readable string summarizing the GaussianPrior parameters.

value_for(unit, xp=<module 'numpy' from '/home/docs/checkouts/readthedocs.org/user_builds/pyautogalaxy/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>)[source]#

Map a unit value in [0, 1] to a physical value drawn from this Gaussian prior.

Parameters:
  • unit – A unit value between 0 and 1.

  • xp – Array-module to dispatch on (numpy or jax.numpy). Default numpy. The NumPy path delegates to the message stack (erfinv via scipy); the JAX path uses the same closed-form via jax.scipy.special.erfinv.