Sigmoid function



A sigmoid function is any mathematical function whose graph has a characteristic S-shaped or sigmoid curve.

A common example of a sigmoid function is the logistic function shown in the first figure and defined by the formula:
 * $$\sigma(x) = \frac{1}{1 + e^{-x}} = \frac{e^x}{1 + e^x}=1-\sigma(-x).$$

Other standard sigmoid functions are given in the Examples section. In some fields, most notably in the context of artificial neural networks, the term "sigmoid function" is used as an alias for the logistic function.

Special cases of the sigmoid function include the Gompertz curve (used in modeling systems that saturate at large values of x) and the ogee curve (used in the spillway of some dams). Sigmoid functions have domain of all real numbers, with return (response) value commonly monotonically increasing but could be decreasing. Sigmoid functions most often show a return value (y axis) in the range 0 to 1. Another commonly used range is from −1 to 1.

A wide variety of sigmoid functions including the logistic and hyperbolic tangent functions have been used as the activation function of artificial neurons. Sigmoid curves are also common in statistics as cumulative distribution functions (which go from 0 to 1), such as the integrals of the logistic density, the normal density, and Student's t probability density functions. The logistic sigmoid function is invertible, and its inverse is the logit function.

Definition
A sigmoid function is a bounded, differentiable, real function that is defined for all real input values and has a non-negative derivative at each point and exactly one inflection point.

Properties
In general, a sigmoid function is monotonic, and has a first derivative which is bell shaped. Conversely, the integral of any continuous, non-negative, bell-shaped function (with one local maximum and no local minimum, unless degenerate) will be sigmoidal. Thus the cumulative distribution functions for many common probability distributions are sigmoidal. One such example is the error function, which is related to the cumulative distribution function of a normal distribution; another is the arctan function, which is related to the cumulative distribution function of a Cauchy distribution.

A sigmoid function is constrained by a pair of horizontal asymptotes as $$x \rightarrow \pm \infty$$.

A sigmoid function is convex for values less than a particular point, and it is concave for values greater than that point: in many of the examples here, that point is 0.

Examples


{\displaystyle \left( \int_0^1 \left(1 - u^2\right)^N du \right)^{-1} \int_0^x \left( 1 - u^2 \right)^N \ du}, & |x| \le 1 \\ \\ \sgn(x) & |x| \ge 1 \\ \end{cases} \quad N \in \mathbb{Z} \ge 1 $$
 * Logistic function $$ f(x) = \frac{1}{1 + e^{-x}} $$
 * Hyperbolic tangent (shifted and scaled version of the logistic function, above) $$ f(x) = \tanh x = \frac{e^x-e^{-x}}{e^x+e^{-x}} $$
 * Arctangent function $$ f(x) = \arctan x $$
 * Gudermannian function $$ f(x) = \operatorname{gd}(x) = \int_0^x \frac{dt}{\cosh t} = 2\arctan\left(\tanh\left(\frac{x}{2}\right)\right) $$
 * Error function $$ f(x) = \operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} \, dt $$
 * Generalised logistic function $$ f(x) = \left(1 + e^{-x} \right)^{-\alpha}, \quad \alpha > 0 $$
 * Smoothstep function $$ f(x) = \begin{cases}
 * Some algebraic functions, for example $$ f(x) = \frac{x}{\sqrt{1+x^2}} $$
 * and in a more general form $$ f(x) = \frac{x}{\left(1 + |x|^{k}\right)^{1/k}} $$
 * Up to shifts and scaling, many sigmoids are special cases of $$ f(x) = \varphi(\varphi(x, \beta), \alpha), $$ where $$ \varphi(x, \lambda) = \begin{cases} (1 - \lambda x)^{1/\lambda} & \lambda \ne 0 \\e^{-x} & \lambda = 0 \\ \end{cases} $$ is the inverse of the negative Box–Cox transformation, and $$\alpha < 1$$ and $$\beta < 1$$ are shape parameters.
 * Smooth transition function normalized to (-1,1):

$$\begin{align}f(x) &= \begin{cases} {\displaystyle \frac{2}{1+e^{-2m\frac{x}{1-x^2}}} - 1}, & |x| < 1 \\ \\ \sgn(x) & |x| \ge 1 \\ \end{cases} \\ &= \begin{cases} {\displaystyle \tanh\left(m\frac{x}{1-x^2}\right)}, & |x| < 1 \\ \\ \sgn(x) & |x| \ge 1 \\ \end{cases}\end{align}$$ using the hyperbolic tangent mentioned above. Here, $$m$$ is a free parameter encoding the slope at $$x=0$$, which must be greater than or equal to $$\sqrt{3}$$ because any smaller value will result in a function with multiple inflection points, which is therefore not a true sigmoid. This function is unusual because it actually attains the limiting values of -1 and 1 within a finite range, meaning that its value is constant at -1 for all $$x \leq -1$$ and at 1 for all $$x \geq 1$$. Nonetheless, it is smooth (infinitely differentiable, $$C^\infty$$) everywhere, including at $$x = \pm 1$$.

Applications


Many natural processes, such as those of complex system learning curves, exhibit a progression from small beginnings that accelerates and approaches a climax over time. When a specific mathematical model is lacking, a sigmoid function is often used.

The van Genuchten–Gupta model is based on an inverted S-curve and applied to the response of crop yield to soil salinity.

Examples of the application of the logistic S-curve to the response of crop yield (wheat) to both the soil salinity and depth to water table in the soil are shown in modeling crop response in agriculture.

In artificial neural networks, sometimes non-smooth functions are used instead for efficiency; these are known as hard sigmoids.

In audio signal processing, sigmoid functions are used as waveshaper transfer functions to emulate the sound of analog circuitry clipping.

In biochemistry and pharmacology, the Hill and Hill–Langmuir equations are sigmoid functions.

In computer graphics and real-time rendering, some of the sigmoid functions are used to blend colors or geometry between two values, smoothly and without visible seams or discontinuities.

Titration curves between strong acids and strong bases have a sigmoid shape due to the logarithmic nature of the pH scale.

The logistic function can be calculated efficiently by utilizing type III Unums.