PowerT#

class brainstate.nn.PowerT(lmbda=0.5)#

Power (Box-Cox) transformation for stabilizing variance.

This transformation implements the Box-Cox family of power transformations, which are commonly used to stabilize variance and make data more normally distributed.

The transformation is defined by:

\[\begin{split}\text{forward}(x) = \begin{cases} \frac{x^{\lambda} - 1}{\lambda} & \text{if } \lambda \neq 0 \\ \log(x) & \text{if } \lambda = 0 \end{cases}\end{split}\]

The inverse transformation is:

\[\begin{split}\text{inverse}(y) = \begin{cases} (y \cdot \lambda + 1)^{1/\lambda} & \text{if } \lambda \neq 0 \\ e^y & \text{if } \lambda = 0 \end{cases}\end{split}\]
Parameters:

lmbda (float) – Power parameter, by default 0.5. Special cases: - lmbda = 0: log transformation - lmbda = 0.5: square root transformation - lmbda = 1: linear transformation (identity) - lmbda = 2: quadratic transformation

Notes

Input values must be positive for this transformation to be well-defined.

Examples

>>> # Square root transformation
>>> transform = PowerT(lmbda=0.5)
>>> x = jnp.array([1.0, 4.0, 9.0])
>>> y = transform.forward(x)
>>> # y ≈ [0, 2, 4]
forward(x)[source]#

Apply the power transformation.

Return type:

Array

inverse(y)[source]#

Apply the inverse power transformation.

Return type:

Array