pymixef.transforms module

Canonical constraints between optimizer and natural parameter scales.

class pymixef.transforms.BoundedTransform(lower=0.0, upper=1.0)[source]

Bases: Transform

Map to the open interval (lower, upper) using a logistic map.

Parameters:
  • lower (float)

  • upper (float)

lower: float
upper: float
name: ClassVar[str] = 'bounded'
forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.CholeskyCovarianceTransform(dimension)[source]

Bases: Transform

Map packed unconstrained Cholesky entries to an SPD covariance matrix.

Parameters:

dimension (int)

dimension: int
name: ClassVar[str] = 'cholesky-covariance'
property unconstrained_size: int
factor(unconstrained)[source]
Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.IdentityTransform[source]

Bases: Transform

No constraint.

name: ClassVar[str] = 'identity'
forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.LogTransform[source]

Bases: Transform

Strictly-positive transform using exp.

name: ClassVar[str] = 'log'
forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.OrderedTransform[source]

Bases: Transform

Map a vector to a strictly increasing vector.

name: ClassVar[str] = 'ordered'
forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.SimplexTransform[source]

Bases: Transform

Additive-log-ratio map from R^(K-1) to a K-simplex.

name: ClassVar[str] = 'simplex'
forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.SoftplusTransform[source]

Bases: Transform

Smooth strictly-positive transform with a near-linear upper tail.

name: ClassVar[str] = 'softplus'
forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

class pymixef.transforms.Transform[source]

Bases: ABC

Abstract optimizer-to-natural-scale transform.

name: ClassVar[str]
abstractmethod forward(unconstrained)[source]

Map an unconstrained value to its natural scale.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

abstractmethod inverse(natural)[source]

Map a natural-scale value to its unconstrained scale.

Parameters:

natural (ArrayLike)

Return type:

NDArray[float64]

abstractmethod log_abs_det_jacobian(unconstrained)[source]

Return the log absolute determinant of the forward Jacobian.

Parameters:

unconstrained (ArrayLike)

Return type:

float

jacobian(unconstrained)[source]

Return a finite-difference Jacobian for general vector transforms.

Parameters:

unconstrained (ArrayLike)

Return type:

NDArray[float64]

pymixef.transforms.get_transform(name, **options)[source]

Construct a canonical transform by stable name.

Parameters:
  • name (str)

  • options (object)

Return type:

Transform