Skip to main content

Module logistic

Module logistic 

Source
Expand description

Logistic transforms — squash and stretch for probability <-> log-odds.

stretch(p) maps 12-bit probability [1, 4095] to log-odds (scaled integer). squash(d) maps log-odds back to 12-bit probability [1, 4095].

Both use lookup tables computed at compile time.

Formula pair: squash(d) = 2048 + d * 2047 / (K + |d|) stretch(p) = c * K / (2047 - |c|) where c = p - 2048

These are analytical inverses of each other. K=64 gives a steep sigmoid covering nearly all of [1, 4095].

Functions§

squash
Convert log-odds to 12-bit probability. Input: d as scaled integer (any range, clamped internally). Output: probability in [1, 4095].
stretch
Convert 12-bit probability to log-odds. Input: p in [1, 4095]. Output: log-odds as scaled integer.