autofit.LogGaussianPrior#

class LogGaussianPrior[source]#

Bases: Prior

A prior for a variable whose logarithm is gaussian distributed. Work in natural log.

The conversion of an input unit value, u, to a physical value, p, via the prior is as follows:

\[p = \mu + (\sigma * sqrt(2) * erfcinv(2.0 * (1.0 - u))\]

For example for prior = LogGaussianPrior(mean=1.0, sigma=2.0), an input prior.value_for(unit=0.5) is equal to 1.0.

[Rich describe how this is done via message]

Parameters:
  • mean (float) – The natural log of the distribution’s mean.

  • sigma (float) – The spread of this distribution in natural log space, e.g. sigma=1.0 means P(ln x) has a standard deviation of 1.

Examples

prior = af.LogGaussianPrior(mean=1.0, sigma=2.0)

physical_value = prior.value_for(unit=0.5)

Methods

dict

A dictionary representation of this prior

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.

log_prior_from_value

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

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

Return a physical value for a value between 0 and 1 with the transformation described by this 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

A human-readable string summarizing this prior's parameters.

tree_flatten()[source]#
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

value_for(unit)[source]#

Return a physical value for a value between 0 and 1 with the transformation described by this prior.

Parameters:

unit (float) – A unit value between 0 and 1.

Return type:

A physical value, mapped from the unit value accoridng to the prior.

property parameter_string: str#

A human-readable string summarizing this prior’s parameters.

Subclasses must implement this to return a description such as "mean = 0.0, sigma = 1.0" or "lower_limit = 0.0, upper_limit = 1.0".

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