Logistic function: Difference between revisions
(11 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
<math>x \mapsto \frac{e^x}{e^x + 1}</math> | <math>x \mapsto \frac{e^x}{e^x + 1}</math> | ||
Yet another form that is sometimes used, because it makes some aspects of the symmetry more evident, is: | |||
<math>x \mapsto \frac{e^{x/2}}{e^{x/2} + e^{-x/2}}</math> | |||
For this page, we will denote the function by the letter <math>g</math>. | For this page, we will denote the function by the letter <math>g</math>. | ||
Line 14: | Line 18: | ||
===Probabilistic interpretation=== | ===Probabilistic interpretation=== | ||
The logistic function transforms the logarithm of the odds to the actual probability. Explicitly, given a probability <math>p</math> (strictly between 0 and 1)of an event occurring, the odds in favor of <math>p</math> are given as: | The logistic function transforms the logarithm of the odds to the actual probability. Explicitly, given a probability <math>p</math> (strictly between 0 and 1) of an event occurring, the odds in favor of <math>p</math> are given as: | ||
<math>\frac{p}{1 - p}</math> | <math>\frac{p}{1 - p}</math> | ||
Line 25: | Line 29: | ||
If <math>x</math> equals the above expression, then the function describing <math>p</math> in terms of <math>x</math> is the logistic function. | If <math>x</math> equals the above expression, then the function describing <math>p</math> in terms of <math>x</math> is the logistic function. | ||
==Key data== | |||
{| class="sortable" border="1" | |||
! Item !! Value | |||
|- | |||
| default [[domain]] || all of <math>\R</math>, i.e., all reals | |||
|- | |||
| [[range]] || the [[open interval]] <math>(0,1)</math>, i.e., the set <math>\{ x \mid 0 \le x \le 1 \}</math> | |||
|- | |||
| [[derivative]] || the derivative is <math>\frac{e^{-x}}{(1 + e^{-x})^2}</math>.<br>If we denote the logistic function by the letter <math>g</math>, then we can also write the derivative as <math>g'(x) = g(x)g(-x) = g(x)(1 - g(x))</math> | |||
|- | |||
| [[second derivative]] || If we denote the logistic function by the letter <math>g</math>, then we can also write the derivative as <math>g''(x) = g'(x)(1 - 2g(x)) = g(x)(1 - g(x))(1 - 2g(x)) = g(x)g(-x)(1 - 2g(x)) = g(x)g(-x)(g(-x) - g(x))</math> | |||
|- | |||
| [[logarithmic derivative]] || the logarithmic derivative is <math>\frac{e^{-x}}{1 + e^{-x}}</math><br>If we denote the logistic function by <math>g</math>, the logarithmic derivative is <math>g(-x)</math> | |||
|- | |||
| [[antiderivative]] || the function <math>x \mapsto \ln(e^x + 1) + C = -\ln(g(-x)) + C</math> | |||
|- | |||
| [[critical point]]s || none | |||
|- | |||
| [[critical points]] for the derivative (correspond to points of inflection for the function) || <math>x = 0</math>; the corresponding point on the graph of the function is <math>(0,1/2)</math>. | |||
|- | |||
| [[local maximal value]]s and points of attainment || none | |||
|- | |||
| [[local minimum value]]s and points of attainment || none | |||
|- | |||
| intervals of interest || increasing and concave up on <math>(-\infty,0)</math><br>increasing and concave down on <math>(0,\infty)</math> | |||
|- | |||
| [[horizontal asymptote]]s || asymptote at <math>y = 0</math> corresponding to the limit for <math>x \to -\infty</math><br>asymptote at <math>y = 1</math> corresponding to the limit for <math>x \to \infty</math> | |||
|- | |||
| [[inverse function]] || [[inverse logistic function]] or [[log-odds function]] given by <math>x \mapsto \ln \left(\frac{x}{1 - x} \right)</math> | |||
|} | |||
==Differentiation== | ==Differentiation== | ||
Line 43: | Line 80: | ||
We can write this in an alternate way that is sometimes more useful. We split the expression as a product: | We can write this in an alternate way that is sometimes more useful. We split the expression as a product: | ||
<math>g'(x) = \frac{1}{1 + e^{-x}} \frac{e^{-x}}{1 + e^{-x}}</math> | <math>g'(x) = \left( \frac{1}{1 + e^{-x}} \right) \left(\frac{e^{-x}}{1 + e^{-x}}\right)</math> | ||
The first factor on the right is <math>g(x)</math>, and the second factor is <math>1 - g(x)</math>, so this simplifies to: | The first factor on the right is <math>g(x)</math>, and the second factor is <math>1 - g(x)</math>, so this simplifies to: | ||
<math>g'(x) = g(x)(1 - g(x))</math> | <math>g'(x) = g(x)(1 - g(x))</math> | ||
===Second derivative=== | |||
====Using the expression <math>g(x)(1 - g(x))</math> for <math>g'</math>==== | |||
From the above, we have: | |||
<math>g'(x) = g(x) - (g(x))^2</math> | |||
Differentiating both sides, we obtain: | |||
<math>g''(x) = g'(x) - 2g(x)g'(x)</math> | |||
This simplifies to: | |||
<math>g''(x) = g'(x)(1 - 2g(x))</math> | |||
We can now re-use the expression for <math>g'</math> and obtain: | |||
<math>g''(x) = g(x)(1 - g(x))(1 - 2g(x))</math> | |||
====Using the expression <math>g(x)g(-x)</math> for <math>g'</math>==== | |||
We have: | |||
<math>g'(x) = g(x)g(-x)</math> | |||
Using the [[product rule for differentiation]] and the [[chain rule for differentiation]], we get: | |||
<math>g''(x) = g'(x)g(-x) + (-g(x)g'(-x))</math> | |||
Note from the expression that <math>g'</math> shows that <math>g'</math> is even, so we can rewrite <math>g'(-x)</math> as <math>g'(x)</math>, and we get: | |||
<math>g''(x) = g'(x)g(-x) - g'(x)g(x) = g'(x)(g(-x) - g(x))</math> | |||
We can re-use the expression <math>g'(x) = g(x)g(-x)</math> and obtain: | |||
<math>g''(x) = g(x)g(-x)(g(-x) - g(x))</math> | |||
==Functional equations== | ==Functional equations== | ||
Line 77: | Line 152: | ||
The general solution to that equation is the function <math>y = g(x + C)</math> where <math>C \in \R</math>. The initial condition <math>y = 1/2</math> at <math>x = 0</math> pinpoints the logistic function uniquely. | The general solution to that equation is the function <math>y = g(x + C)</math> where <math>C \in \R</math>. The initial condition <math>y = 1/2</math> at <math>x = 0</math> pinpoints the logistic function uniquely. | ||
== | ==Points and intervals of interest== | ||
===Critical points=== | |||
The function has no critical points. To see this, note that the derivative is: | |||
<math>g'(x) = g(x)(1 - g(x)) = \frac{e^{-x}}{(1 + e^{-x})^2}</math> | |||
Note that the numerator is never zero, nor is the denominator. Therefore, the function is always defined and nonzero. | |||
===Intervals of increase and decrease=== | |||
The derivative: | |||
<math>g'(x) = g(x)(1 - g(x)) = \frac{e^{-x}}{(1 + e^{-x})^2}</math> | |||
is always positive. So the function is increasing on all of <math>\R</math>. | |||
The asymptotic values are: | |||
<math>\lim_{x \to \infty} \frac{1}{1 + e^{-x}} = \frac{1}{1} = 1</math> | |||
and: | |||
<math>\lim_{x \to -\infty} \frac{1}{1 + e^{-x}} = \frac{1}{\to \infty} = 0</math> | |||
In other words, the range of the function is the open interval <math>(0,1)</math>, and it increases throughout its domain. | |||
===Points of inflection=== | |||
The second derivative is: | |||
<math>g''(x) = g(x)(1 - g(x))(1 - 2g(x)) = g'(x)(1 - 2g(x))</math> | |||
We already noted that <math>g'(x)</math> is always defined and nonzero, so the only way for <math>g''(x)</math> to be zero is if <math>1 - 2g(x) = 0</math>< or <math>g(x) = 1/2</math>. This solves to: | |||
<math>\frac{1}{1 + e^{-x}} = \frac{1}{2}</math> | |||
This solves to <math>e^{-x} = 1</math>, or <math>x = 0</math>. | |||
Thus, the second derivative is 0 at the point <math>(0,1/2)</math>, i.e., with <math>x = 0</math> and <math>g(x) = 1/2</math>. | |||
===Intervals of concave up and down=== | |||
As above, we have: | |||
<math>g''(x) = g'(x)(1 - 2g(x))</math> | |||
We also noted that <math>g'(x) > 0</math> for all <math>x</math>. Therefore, <math>g''(x) > 0</math> for <math>x < 0</math> and <math>g''(x) < 0</math> for <math>x > 0</math>. Therefore, <math>g</math> is: | |||
* concave up for <math>x < 0</math>, i.e., <math>x \in (-\infty, 0)</math> | |||
* concave down for <math>x > 0</math>, i.e., <math>x \in (0, \infty)</math> | |||
==Symmetry== | |||
We discussed above a functional equation satisfied by <math>g</math>: | |||
<math>g(-x) = 1 - g(x)</math> | |||
From this, the following can be deduced: | |||
* The graph of <math>g</math> has half-turn symmetry about the point <math>(0, 1/2)</math>. | |||
* <math>g'</math> is an even function. Note that this can also be seen from the actual expression: <math>g'(x) = g(x)g(-x)</math>. But we don't need the actual expression to deduce that it is even -- the functional equation above gives evenness. | |||
* <math>g''</math> is an odd function. This can be directly deduced from <math>g'</math> being even, but can also be verified from the actual expression: <math>g''(x) = g'(x)(1 - 2g(x)) = g'(x)(g(-x) - g(x))</math>. | |||
==Integration== | |||
===First antiderivative=== | |||
====Direct computation==== | |||
We have: | |||
<math>\int g(x) \, dx = \int \frac{1 \, dx}{1 + e^{-x}} = \int \frac{e^x \, dx}{e^x + 1} = \ln(e^x + 1) + C</math> | |||
====Computation in terms of functional equations for the logistic function==== | |||
We have: | |||
<math>g'(x) = g(x)(1 - g(x))</math> | |||
We also have that <math>1 - g(x) = g(-x)</math>, so we get: | |||
<math>g'(x) = g(x)g(-x)</math> | |||
This can be rewritten as: | |||
<math>\frac{d}{dx}(\ln(g(x)) = g(-x)</math> | |||
By the [[chain rule for differentiation]], we get: | |||
<math>\frac{d}{dx}(\ln(g(-x)) = -g(x)</math> | |||
Thus: | |||
<math>\int g(x) \, dx = -\ln(g(-x)) + C</math> | |||
This can be simplified and verified to be the same as the answer obtained by direct computation. | |||
Latest revision as of 14:42, 6 July 2019
Definition
The logistic function is a function with domain and range the open interval , defined as:
Equivalently, it can be written as:
Yet another form that is sometimes used, because it makes some aspects of the symmetry more evident, is:
For this page, we will denote the function by the letter .
We may extend the logistic function to a function , where and .
Probabilistic interpretation
The logistic function transforms the logarithm of the odds to the actual probability. Explicitly, given a probability (strictly between 0 and 1) of an event occurring, the odds in favor of are given as:
This could take any value in
The logarithm of odds is the expression:
If equals the above expression, then the function describing in terms of is the logistic function.
Key data
Item | Value |
---|---|
default domain | all of , i.e., all reals |
range | the open interval , i.e., the set |
derivative | the derivative is . If we denote the logistic function by the letter , then we can also write the derivative as |
second derivative | If we denote the logistic function by the letter , then we can also write the derivative as |
logarithmic derivative | the logarithmic derivative is If we denote the logistic function by , the logarithmic derivative is |
antiderivative | the function |
critical points | none |
critical points for the derivative (correspond to points of inflection for the function) | ; the corresponding point on the graph of the function is . |
local maximal values and points of attainment | none |
local minimum values and points of attainment | none |
intervals of interest | increasing and concave up on increasing and concave down on |
horizontal asymptotes | asymptote at corresponding to the limit for asymptote at corresponding to the limit for |
inverse function | inverse logistic function or log-odds function given by |
Differentiation
First derivative
Consider the expression for :
We can differentiate this using the chain rule for differentiation (the inner function being and the outer function being the reciprocal function . We get:
Simplifying, we get:
We can write this in an alternate way that is sometimes more useful. We split the expression as a product:
The first factor on the right is , and the second factor is , so this simplifies to:
Second derivative
Using the expression for
From the above, we have:
Differentiating both sides, we obtain:
This simplifies to:
We can now re-use the expression for and obtain:
Using the expression for
We have:
Using the product rule for differentiation and the chain rule for differentiation, we get:
Note from the expression that shows that is even, so we can rewrite as , and we get:
We can re-use the expression and obtain:
Functional equations
Symmetry equation
The logistic function has the property that its graph has symmetry about the point . Explicitly, it satisfies the functional equation:
We can see this algebraically:
Multiply numerator and denominator by , and get:
Differential equation
As discussed in the #First derivative section, the logistic function satisfies the condition:
Therefore, is a solution to the autonomous differential equation:
The general solution to that equation is the function where . The initial condition at pinpoints the logistic function uniquely.
Points and intervals of interest
Critical points
The function has no critical points. To see this, note that the derivative is:
Note that the numerator is never zero, nor is the denominator. Therefore, the function is always defined and nonzero.
Intervals of increase and decrease
The derivative:
is always positive. So the function is increasing on all of .
The asymptotic values are:
and:
In other words, the range of the function is the open interval , and it increases throughout its domain.
Points of inflection
The second derivative is:
We already noted that is always defined and nonzero, so the only way for to be zero is if < or . This solves to:
This solves to , or .
Thus, the second derivative is 0 at the point , i.e., with and .
Intervals of concave up and down
As above, we have:
We also noted that for all . Therefore, for and for . Therefore, is:
- concave up for , i.e.,
- concave down for , i.e.,
Symmetry
We discussed above a functional equation satisfied by :
From this, the following can be deduced:
- The graph of has half-turn symmetry about the point .
- is an even function. Note that this can also be seen from the actual expression: . But we don't need the actual expression to deduce that it is even -- the functional equation above gives evenness.
- is an odd function. This can be directly deduced from being even, but can also be verified from the actual expression: .
Integration
First antiderivative
Direct computation
We have:
Computation in terms of functional equations for the logistic function
We have:
We also have that , so we get:
This can be rewritten as:
By the chain rule for differentiation, we get:
Thus:
This can be simplified and verified to be the same as the answer obtained by direct computation.