TruncatedGaussian#
- class hybrid_aif.TruncatedGaussian[source]#
Bases:
DistributionA diagonal Gaussian
N(loc, diag(scale²))restricted to[low, high](see module).Every leaf is
(..., dim);low < highelementwise.- property batch_shape: tuple[int, ...]#
Leading (batch) axes: leaf shape minus the family’s fixed trailing structure.
- mean()[source]#
The mean; a narrow box’s is
mid + half·h·M₁/M₀about its midpoint. Clamped into the box as a guard.
- variance()[source]#
Per-dimension variance,
(..., dim)(the covariance is diagonal); a narrow box’s ishalf²·(M₂/M₀ − h²(M₁/M₀)²),w²/12in the uniform limit. Clamped into(0, w²/4]as a guard.
- sample(key, sample_shape=())[source]#
Reparameterised draws through the inverse CDF:
u ~ U(0, 1)per dimension andx = loc + scale·Φ⁻¹(Φ(α) + u·Z), withΦ(α) + u·Zformed in log space and a box in the upper tail drawn from its reflection. Draws are clipped into the box against rounding. A box narrower than_TILT_HALF_WIDTHstandard deviations, where the inverse CDF runs out of float32 resolution andt²/2is below it, is drawn from its exponential tilt about the lower bound.
- entropy()[source]#
The differential entropy, summed over dimensions; a box beyond
_TAILstandard deviations takes the tail form (_tail_moments()).
- kl_to(other)[source]#
KL(self ‖ other)for two members on the same box, in closed form:−H[self] − E_self[log other], the cross term read off the closed first two moments.Members on different boxes raise (eagerly, or under a trace by
equinox.error_if): outside a shared box the KL is infinite or undefined.