Parameter#

class uvex_transients.models.core.parameters.Parameter(prior: Prior, scale: ScalarPhysicalValue, transform: str | Callable[[FloatArray], FloatArray] | None = None, inverse_transform: Callable[[FloatArray], FloatArray] | None = None, description: str | None = None, latex: str | None = None, fixed_value: ScalarPhysicalValue | None = None)[source]#

A single physical parameter of a model.

A Parameter describes how one physical quantity is drawn: a Prior to sample from, a characteristic physical scale, and an optional transform that lets the prior be defined on a more convenient variable than the physical value itself.

Internally, sampling proceeds through a latent variable \(z\), related to the physical value \(x\) by

\[z = T(x / x_0), \qquad x = T^{-1}(z) \cdot x_0,\]

where \(x_0\) is scale and \(T\) is transform (the identity by default). This is what lets, e.g., a strictly-positive, many-orders-of-magnitude parameter be sampled from a well-behaved NormalPrior via transform="log", without every prior implementation needing to separately handle scale and shape.

Examples

rise_time = Parameter(
    prior=NormalPrior(mean=0.0, sigma=1.0),
    scale=1.0 * u.day,
    transform="log",
    description="Rise timescale",
    latex=r"\tau_{\rm rise}",
)
rise_time.sample(size=1000, rng=0)

# Pin it to a constant for a diagnostic run, then release it again.
rise_time.fix(2.5 * u.day)
rise_time.is_fixed  # True
rise_time.unfix()

Methods

available_transforms()

Tuple of str: Names of the built-in string transforms accepted by transform.

fix(value)

Pin this parameter to a constant physical value, bypassing prior.

sample([size, rng])

Draw size physical-unit samples of this parameter.

sample_latent_variable([size, rng])

Draw size samples of the latent variable \(z\).

set_prior(prior)

Set the prior distribution for this parameter.

transform_latent_to_physical(z)

Convert a latent value \(z\) back to the physical value \(x = T^{-1}(z) \cdot x_0\).

transform_physical_to_latent(x)

Convert a physical value \(x\) to the latent variable \(z = T(x / x_0)\).

unfix()

Release a fixed parameter, restoring sampling from prior.

Attributes

prior

The prior distribution for the latent variable \(z\).

scale

The characteristic scale \(x_0\) for this parameter.

transform

The transform \(T\) mapping the scaled variable to the latent variable.

inverse_transform

The inverse \(T^{-1}\) of transform.

description

A short, human-readable description of the parameter.

latex

A LaTeX symbol for the parameter, for use in plot labels.

fixed_value

A constant physical value this parameter is pinned to.

is_fixed

Whether this parameter is pinned to a constant value (see fix()).