Transforms#

Parameter space transforms.

class everwillow.parameters.transforms.TransformBase[source]#

Bases: ABC

Abstract base for parameter transformations.

Subclasses implement unwrap (bounded → unconstrained) and wrap (unconstrained → bounded) using JAX-compatible array ops.

abstractmethod unwrap(value)[source]#

Transform a value from its constrained space to the real line.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

abstractmethod wrap(value)[source]#

Transform a value from the real line back to its constrained space.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

class everwillow.parameters.transforms.MinuitTransform(lower, upper)[source]#

Bases: TransformBase

Minuit-style transform for parameters with finite lower and upper bounds.

unwrap converts a bounded value into an unconstrained internal representation, while wrap inverts the mapping. Both bounds must be finite and lower < upper. .. rubric:: Example

>>> transform = MinuitTransform(lower=0.0, upper=1.0)
>>> jnp.isclose(transform.wrap(transform.unwrap(0.3)), 0.3)
Array(True, dtype=bool)

Reference: https://root.cern.ch/download/minuit.pdf (Sec. 1.2.1).

unwrap(value)[source]#

Convert a bounded value into an unconstrained representation.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

wrap(value)[source]#

Convert an unconstrained value back into the bounded interval.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

class everwillow.parameters.transforms.SigmoidTransform(lower, upper)[source]#

Bases: TransformBase

Logit/sigmoid pair for parameters with finite lower and upper bounds.

unwrap applies the logit of the affine-scaled value, wrap applies the sigmoid. Bounds must be finite with lower < upper.

Example

>>> transform = SigmoidTransform(lower=-2.0, upper=3.0)
>>> value = -1.1
>>> jnp.isclose(transform.wrap(transform.unwrap(value)), value)
Array(True, dtype=bool)
unwrap(value)[source]#

Convert a bounded value into an unconstrained representation.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

wrap(value)[source]#

Convert an unconstrained value back into the bounded interval.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

class everwillow.parameters.transforms.OneSidedLogTransform(bound, direction)[source]#

Bases: TransformBase

Log transform for parameters with exactly one finite bound.

Direction "lower" enforces value > bound (via log(value - bound)), while direction "upper" enforces value < bound (via log(bound - value)).

Example

>>> transform = OneSidedLogTransform(bound=0.0, direction="lower")
>>> jnp.isclose(transform.wrap(transform.unwrap(2.0)), 2.0)
Array(True, dtype=bool)
unwrap(value)[source]#

Convert a single-sided bounded value into an unconstrained representation.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

wrap(value)[source]#

Convert an unconstrained value back into the one-sided bounded space.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

class everwillow.parameters.transforms.SoftPlusTransform[source]#

Bases: TransformBase

Applies the softplus transformation to parameters, projecting them from real space (R) to positive space (R+). This transformation is useful for enforcing the positivity of parameters and does not require lower or upper boundaries.

unwrap computes the inverse softplus (with validation), while wrap applies jax.nn.softplus.

Example

>>> transform = SoftPlusTransform()
>>> jnp.isclose(transform.wrap(transform.unwrap(0.8)), 0.8)
Array(True, dtype=bool)
unwrap(value)[source]#

Apply the inverse softplus, validating positivity and finiteness.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray

wrap(value)[source]#

Apply the softplus function.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | TypedNdArray