class
StickBreakingTransform
extends
TransformStickBreakingTransform()Logistic stick-breaking bijection .
A true bijection between unconstrained -vectors and
the -simplex (i.e. one extra dimension is broken off as the
residual stick). Unlike SoftmaxTransform it has the
correct dimensionality and a tractable log-Jacobian determinant,
making it the preferred choice for normalising flows over
probability vectors and for unconstrained reparameterisations of
lucid.distributions.Dirichlet priors. event_dim = 1.
Notes
Forward "stick breaking" (with ):
The last component is the residual stick remaining after the first breaks. Each and by construction.
Inverse (back-solve the stick lengths):
Log Jacobian determinant:
where the shifts ensure the uniform Dirichlet corresponds to .
Examples
>>> import lucid
>>> from lucid.distributions.transforms import StickBreakingTransform
>>> T = StickBreakingTransform()
>>> y = T(lucid.tensor([0.0, 0.0])) # maps to a Dirichlet(1,1,1) sample
>>> y.sum()
Tensor(1.0)Methods (1)
fn
log_abs_det_jacobian
→Tensorlog_abs_det_jacobian(x: Tensor, y: Tensor)Standard simplex-to- log-Jacobian.
.