Activation Functions
# sigmoid function
packages/math/src/activation.ts:33sigmoid(z: number): numberSigmoid (logistic) activation function: σ(z) = 1 / (1 + e⁻ᶻ).
Maps any real-valued input to the open interval (0, 1), making it
suitable for modelling probabilities. The function is smooth and
differentiable everywhere, which is why it is used in gradient-based
optimisation (e.g. logistic regression, neural networks).
Key properties:
σ(0) = 0.5σ(z) → 1asz → +∞σ(z) → 0asz → −∞σ'(z) = σ(z) · (1 − σ(z))(gradient used in back-propagation)
Usage in @statili/stats — the logistic regression implementation
applies sigmoid to the linear predictor b₀ + b₁x₁ + … + bₖxₖ to
obtain the estimated class probability P(y=1 | x).
Insights derivable by @statili/forge — the logit (inverse sigmoid)
of a predicted probability reveals the log-odds: positive logit means the
model favours class 1; negative means class 0.
Parameters
| Name | Type | Description |
|---|---|---|
| z | number | Any real number (the linear predictor / logit). |
Returns
numberA probability in the open interval
(0, 1).Example
sigmoid(0) // 0.5
sigmoid(2) // ≈ 0.8808
sigmoid(-2) // ≈ 0.1192
sigmoid(100) // ≈ 1 (numerically saturates to 1)