Skip to main content
Luxara Academy

Archive — one question answered

Sigmoid: what is p when z = 0?

Why is spam probability at z = 0 equal to 0.5, not 0?

Sigmoid maps a linear score zz to a probability p∈(0,1)p \in (0, 1):

p=σ(z)=11+e−zp = \sigma(z) = \frac{1}{1 + e^{-z}}

At z=0z = 0: e0=1e^{0} = 1, so p=0.5p = 0.5. The neuron is maximally undecided — neither spam nor normal. Beginners often think z=0z = 0 means “definitely not spam”; it is the midpoint.

Numeric examples: z=2.0⇒p≈0.88z = 2.0 \Rightarrow p \approx 0.88; z=−2.0⇒p≈0.12z = -2.0 \Rightarrow p \approx 0.12. The curve saturates: large ∣z∣|z| pushes pp near 0 or 1 but never hits the boundary — useful for training gradients.

python
import math
def sigmoid(z):
    return 1 / (1 + math.exp(-z))
assert abs(sigmoid(0) - 0.5) < 1e-9

When filtering mail you compare pp to a threshold (say 0.50.5). Knowing z=0⇒p=0.5z = 0 \Rightarrow p = 0.5 explains the quiz without memorizing answers. If you raise the threshold to 0.70.7, you label spam only when zz is large enough for sigmoid to pass 0.7 — a business choice, not a property of the curve. Lesson two in the course reuses the same formula on the toy inbox vectors, so the quiz question about z=0z=0 is tied to real feature counts, not a trick number.