class

AbsTransform

extendsTransform
AbsTransform()
source

Element-wise absolute value y=xy = |x| (folded, not bijective).

Maps R[0,)\mathbb{R} \to [0, \infty) element-wise by folding the sign. Useful when composing with symmetric base distributions (e.g. a Normal) to produce a half-Normal or folded-Normal pushforward. bijective = False and sign = +1.

Because both xx and x-x map to the same yy, the transform is non-invertible. The pseudo-inverse used here is the identity, under the convention that the preimage is assumed to lie on the non-negative half-line.

Notes

Forward: y=xy = |x|.

Pseudo-inverse: x=yx = y (assumes x0x \geq 0).

Log Jacobian determinant:

log ⁣yx=0\log\!\left|\frac{\partial y}{\partial x}\right| = 0

everywhere off the measure-zero set {x=0}\{x = 0\} where the map is non-differentiable.

Folding the sign halves the density: composing with a Normal(0,1) base gives the half-Normal density p(y)=2ϕ(y)p(y) = 2 \phi(y) for y0y \geq 0, which requires special handling outside the standard change-of-variable formula. Lucid's TransformedDistribution does not currently correct for this folding factor — apply the +log2+\log 2 constant manually when needed.

Examples

>>> import lucid
>>> from lucid.distributions.transforms import AbsTransform
>>> T = AbsTransform()
>>> T(lucid.tensor(-3.0))
Tensor(3.0)

Methods (1)

fn

log_abs_det_jacobian

Tensor
log_abs_det_jacobian(x: Tensor, y: Tensor)
source

Zero everywhere — dy/dx=1|dy/dx| = 1 outside the kink at zero.