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
Parameterdescribes how one physical quantity is drawn: aPriorto sample from, a characteristic physicalscale, and an optionaltransformthat 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
scaleand \(T\) istransform(the identity by default). This is what lets, e.g., a strictly-positive, many-orders-of-magnitude parameter be sampled from a well-behavedNormalPriorviatransform="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
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
sizephysical-unit samples of this parameter.sample_latent_variable([size, rng])Draw
sizesamples of the latent variable \(z\).set_prior(prior)Set the prior distribution for this parameter.
Convert a latent value \(z\) back to the physical value \(x = T^{-1}(z) \cdot x_0\).
Convert a physical value \(x\) to the latent variable \(z = T(x / x_0)\).
unfix()Release a fixed parameter, restoring sampling from
prior.Attributes
The prior distribution for the latent variable \(z\).
The characteristic scale \(x_0\) for this parameter.
The transform \(T\) mapping the scaled variable to the latent variable.
The inverse \(T^{-1}\) of
transform.A short, human-readable description of the parameter.
A LaTeX symbol for the parameter, for use in plot labels.
A constant physical value this parameter is pinned to.
Whether this parameter is pinned to a constant value (see
fix()).