liveBook · Manning

Sigmoid

As explained in Grokking Statistics

An S-curve is a sigmoid-shaped relationship in which growth is initially rapid, then slows toward a plateau.

A sigmoid is a smooth S-shaped curve that turns an ordinary input into a value between 0 and 1. It is useful when the outcome is binary—yes or no, true or false—but the question is really “how likely?” Rather than draw an awkward straight line through 0s and 1s, the curve rises from near 0, climbs fastest around its middle, and then levels off near 1. section 8.2 section 8.3

A meltdown probability curve

Suppose x is hours since a toddler’s nap and y is the probability of a meltdown. Early on, the probability is low. As time without a nap grows, it rises; around an inflection point, the curve changes from speeding up to leveling off. At a chosen threshold, often 0.5, a probability can become a yes/no prediction—but a prediction is still not guaranteed to be right. section 8.2

The logistic function is one common sigmoid: 1 / (1 + e^−(β₀ + β₁x)). Here, x is the input, e is approximately 2.71828, and β₀ and β₁ are intercept and slope values. Those coefficients control where the curve sits and how it changes. Fitting logistic regression means finding coefficients for a curve likely to produce the observed binary data, rather than using least squares. section 8.3

import numpy as np
import matplotlib.pyplot as plt

def logistic(x, b0, b1):  #1
    return 1.0 / (1.0 + np.exp(-(b0 + b1*x)))  #1

b0 = -7.0587  #2
b1 = 2.2047  #2
x = np.linspace(0,7,num=1000)  #3
y = logistic(x, b0, b1)  #4

plt.plot(x, y, color='blue')  #5
plt.show()  #5

This short function makes the curve concrete: change β₀, β₁, or the range of x values, then plot the resulting probabilities. section 8.3

An S-curve can also describe progress, not just probabilities. Adding data, labor, and computing may bring large early gains in a model’s capability, followed by an inflection point and diminishing returns. A tightly defined operating domain can help the curve approach the desired coverage; an overly broad one may level off far below it. section 9.10

How Grokking Statistics covers it

How deep it goes
Defines the curve, interprets its inflection point, gives its formula, and defers the mathematics of maximum-likelihood fitting.
Examples
Uses toddler meltdowns versus hours without a nap, Python plots, and capability coverage that plateaus with increasing expense.
What it assumes
Introduces Euler’s number and coefficient roles before using the logistic-function expression.
What you can do after
Apply it via scikit-learn or the formula to predict a binary outcome’s probability from an input.
How it connects
Connects logistic regression with binary classification, probability thresholds, maximum likelihood estimation, and data coverage.

Also explained in

Compare how 16 books explain sigmoid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Statistics. The section links point to the parts of the book it draws on.