This function computes the logistic (also known as sigmoid) transformation of the input.
The logistic function maps real-valued numbers to the open interval (0, 1), and is widely
used in machine learning, statistical modeling (e.g., logistic regression), and neural networks
as an activation function or link function.
Usage
logit(x)
Value
A numeric object of the same dimension as x, where each element is the
logistic transformation of the corresponding input:
If x = 0, returns 0.5
As x -> Inf, output approaches 1
As x -> -Inf, output approaches 0
NA values remain NA
Arguments
x
A numeric vector, matrix, or array. Accepts any real number, including Inf
and -Inf. Missing values (NA) are preserved.
Details
The logistic function is defined as:
$$ \mathrm{logit}^{-1}(x) = \frac{1}{1 + e^{-x}} $$
Note: Despite the name "logit", this function actually computes the inverse logit (i.e., the
logistic function). The true logit function is the inverse: \(\log(p / (1 - p))\).
However, in many applied contexts—especially in software—the term "logit" is sometimes
informally used to refer to the sigmoid. For clarity, this implementation follows the
conventional definition of the logistic/sigmoid function.