fn
xlog1py
→Tensorxlog1py(x: Tensor, y: Tensor)Safe product with limit-convention zero handling.
Computes element-wise but enforces the
convention , and more generally
propagates the zero whenever regardless of y.
Mirrors lucid.xlogy but uses instead of
, which is the right primitive for log-densities of
distributions expressed in terms of small offsets (Negative Binomial
log-likelihood, Beta survival functions, etc.).
Parameters
xTensorMultiplier tensor.
yTensorArgument of
log1p; broadcast-compatible with x.Returns
Tensor element-wise, broadcast to the common
shape of x and y.
Notes
Mathematical definition with the limit convention:
Using avoids precision loss for small y
where 1 + y would round to 1.0.
Examples
>>> import lucid
>>> from lucid.special import xlog1py
>>> x = lucid.tensor([0.0, 1.0, 2.0])
>>> y = lucid.tensor([0.0, 1.0, 3.0])
>>> xlog1py(x, y)
Tensor([0.0000, 0.6931, 2.7726])