Skip to content

Transformation

This module exposes numpyro's transformations module to the user, and defines and adds additional custom transformations

ScaledLogitTransform

ScaledLogitTransform(x_max: float) -> ComposeTransform

Scaled logistic transformation from the interval (0, X_max) to the interval (-infinity, +infinity).

Parameters:

Name Type Description Default
x_max float

Maximum value of the untransformed scale (will be transformed to +infinity).

required

Returns:

Type Description
ComposeTransform

A composition of the following transformations: - numpyro.distributions.transforms.AffineTransform(0.0, 1.0/x_max) - numpyro.distributions.transforms.SigmoidTransform().inv

Source code in pyrenew/transformation/builtin.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def ScaledLogitTransform(
    x_max: float,
) -> nt.ComposeTransform:
    """
    Scaled logistic transformation from the
    interval (0, X_max) to the interval
    (-infinity, +infinity).

    Parameters
    ----------
    x_max
        Maximum value of the untransformed scale (will be transformed to
        +infinity).

    Returns
    -------
    nt.ComposeTransform
        A composition of the following transformations:
        - numpyro.distributions.transforms.AffineTransform(0.0, 1.0/x_max)
        - numpyro.distributions.transforms.SigmoidTransform().inv
    """
    return nt.ComposeTransform(
        [
            nt.AffineTransform(
                0.0, 1.0 / x_max, domain=constraints.interval(0.0, 1.0 * x_max)
            ),
            nt.SigmoidTransform().inv,
        ]
    )