y=lnx1xy = \ln\dfrac{x}{1-x}

Graph of the Logit Function y=lnx1xy = \ln\dfrac{x}{1-x}

y=lnx1xy = \ln\dfrac{x}{1-x} is the logit function, which stretches a probability between 00 and 11 out onto the whole real line. It is the inverse of the logistic function and the standard tool for handling probabilities in statistics and machine learning.

Domain and range

The argument of the logarithm must be positive, so x1x>0\dfrac{x}{1-x} > 0, giving the domain 0<x<10 < x < 1. The function tends to -\infty as x0+x \to 0^{+} and to ++\infty as x1x \to 1^{-}, so the range is all of the real numbers. Stretching an interval of width 11 across the entire real line is exactly what this function is for.

Asymptotes and intercept

The lines x=0x = 0 and x=1x = 1 are vertical asymptotes. Since x1x=1\dfrac{x}{1-x} = 1 when x=12x = \dfrac{1}{2}, the single xx-intercept is (12,0)\left( \dfrac{1}{2}, 0 \right).

Symmetry

We have f(1x)=ln1xx=f(x)f(1-x) = \ln\dfrac{1-x}{x} = -f(x), so the graph has rotational symmetry about the point (12,0)\left( \dfrac{1}{2}, 0 \right). In probabilistic terms, replacing an event by its complement simply flips the sign of the logit.

Monotonicity and concavity

Writing y=lnxln(1x)y = \ln x - \ln(1-x) and differentiating gives the derivative.

y=1x+11x=1x(1x)y' = \frac{1}{x} + \frac{1}{1-x} = \frac{1}{x(1-x)}

It is positive throughout the domain, so the function increases and has no extrema. Since x(1x)x(1-x) is largest at x=12x = \dfrac{1}{2}, where it equals 14\dfrac{1}{4}, the slope is smallest there, namely 44, and grows steeper toward both ends. The second derivative y=1x2+1(1x)2y'' = -\dfrac{1}{x^2} + \dfrac{1}{(1-x)^2} changes sign at x=12x = \dfrac{1}{2}, giving a single inflection point at (12,0)\left( \dfrac{1}{2}, 0 \right), with the curve concave down to its left and concave up to its right.

Inverse function

Solving for xx gives ey=x1xe^{y} = \dfrac{x}{1-x} and hence the following.

x=11+eyx = \frac{1}{1 + e^{-y}}

The inverse is therefore the logistic function, and the two graphs are reflections of each other in the line y=xy = x. Where the logistic squeezes the real line into (0,1)(0, 1), the logit pulls (0,1)(0, 1) back out again.

Relation to the inverse hyperbolic tangent

Substituting t=2x1t = 2x - 1 into artanht=12ln1+t1t\operatorname{artanh} t = \dfrac{1}{2}\ln\dfrac{1+t}{1-t} produces lnx1x\ln\dfrac{x}{1-x}, so the logit equals 2artanh(2x1)2\operatorname{artanh}(2x-1). It is the inverse hyperbolic tangent applied after rescaling (0,1)(0, 1) to (1,1)(-1, 1).

Odds and applications

The quantity x1x\dfrac{x}{1-x} is the odds corresponding to a probability xx, and the logit is its logarithm.

ProbabilityOddsLogit
0.10.119\dfrac{1}{9}2.197-2.197
0.50.51100
0.90.9992.1972.197

In logistic regression one models not the probability itself but its logit as a linear function of the predictors: the probability is constrained to lie between 00 and 11, whereas the logit is unconstrained and can be treated with ordinary linear methods. The pre-activation values in a neural network are called logits for the same reason.