Docs / jax4j-core / com.nablatensor.jax4j.ops

final class

Smooth

Smoothed indicators: differentiable stand-ins for the discontinuous STEP / GT / 1{a<x<b} that path-dependent expressions need for thresholds and interval membership.

Each takes a width in the same units as its argument. The functions are built entirely from the engine's primitive ops, so their adjoint is the exact derivative of the smoothed form (no special-cased reverse rule) and they run unchanged on every backend. As width -> 0 the smoothed value converges to the discontinuous limit; its derivative concentrates into a spike, representing the derivative of the smooth approximation.

Rule of thumb: width a fraction of a percent of the monitored quantity's scale (e.g. 0.01 * scale). Too small re-introduces the variance a discontinuity brings; too large biases the value.

Methods

static SDouble step(AadRecorder rec, SDouble x, double width)

Logistic step: ~1 for x >> 0, ~0 for x << 0, 0.5 at 0.

static SDouble gt(AadRecorder rec, SDouble a, SDouble b, double width)

Smoothed 1{a > b}.

static SDouble gt(AadRecorder rec, SDouble a, double level, double width)

Smoothed 1{a > level}.

static SDouble lt(AadRecorder rec, SDouble a, double level, double width)

Smoothed 1{a < level}.

static SDouble lt(AadRecorder rec, SDouble a, SDouble b, double width)

Smoothed 1{a < b}.

static SDouble between(AadRecorder rec, SDouble x, double lo, double hi, double width)

Smoothed band indicator 1{lo < x < hi}.

static SDouble ramp(AadRecorder rec, SDouble x, double width)

Numerically stable softplus: a smoothed max(x, 0). width -> 0 recovers the hockey-stick; useful for a smoothed option expression when the whole function must stay differentiable.