ScalarAffine

class pmrf.stats.ScalarAffine(shift: Array, scale: Array | None = None, log_scale: Array | None = None)

Bases: AbstractScalarAffine

An affine bijector that acts elementwise.

The bijector is defined as follows:

  • Forward: \(y = \text{scale} \cdot x + \text{shift}\)

  • Forward Jacobian determinant: \(\log|\det J(x)| = \log|\text{scale}|\)

  • Inverse: \(x = (y - \text{shift}) / \text{scale}\)

  • Inverse Jacobian determinant: \(\log|\det J(y)| = -\log|\text{scale}|\)

where scale and shift are the bijector’s parameters.

Initializes a ScalarAffine bijector.

Arguments:

  • shift: the bijector’s shift parameter.

  • scale: the bijector’s scale parameter. NOTE: scale must be non-zero,

    otherwise the bijector is not invertible. It is the user’s responsibility to make sure scale is non-zero; the class will make no attempt to verify this.

  • log_scale: the log of the scale parameter. If specified, the

    bijector’s scale is set equal to exp(log_scale). Unlike scale, log_scale is an unconstrained parameter. NOTE: either scale or log_scale can be specified, but not both. If neither is specified, the bijector’s scale will default to 1.

Raises:

  • ValueError: if both scale and log_scale are not None.

same_as(other: AbstractBijector) → bool

Returns True if this bijector is guaranteed to be the same as other.

inv_scale: Array
log_scale: Array
scale: Array
shift: Array