autofit.GaussianPrior#
- class GaussianPrior[source]#
Bases:
PriorA 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:
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
Return a dictionary representation of this GaussianPrior instance, including mean and sigma.
for_class_and_attribute_nameCreate a prior from the configuration for a given class and attribute.
from_dictReturns a prior from a JSON representation.
gaussian_prior_model_for_argumentsLook up this prior in an arguments dict and return the mapped value.
hasDoes this instance have an attribute which is of type cls?
instance_for_argumentsLook up this prior's value in an arguments dictionary.
make_indexesname_of_classA string name for the class, with the prior suffix removed.
newReturns a copy of this prior with a new id assigned making it distinct
next_idprojectProject this prior given samples and log weights from a search.
randomA random value sampled from this prior
replacing_for_pathCreate a new model replacing the value for a given path with a new value
Flatten this prior into a JAX-compatible PyTree representation.
tree_unflattenCreate a prior from a flattened PyTree
unit_value_forCompute the unit value between 0 and 1 for the physical value.
Map a unit value in [0, 1] to a physical value drawn from this Gaussian prior.
Create a new gaussian prior centred between two limits with sigma distance between this limits.
with_messageReturn a copy of this prior with a different message (distribution).
Attributes
component_numberfactorA callable PDF used as a factor in factor graphs
identifierlabellimitsThe (lower, upper) bounds of this prior.
namendimHow many dimensions does this variable have?
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:
- 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.
- 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/pyautolens/envs/latest/lib/python3.12/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 (
numpyorjax.numpy). Defaultnumpy. The NumPy path delegates to the message stack (erfinvvia scipy); the JAX path uses the same closed-form viajax.scipy.special.erfinv.