# Variance of Logistic Distribution

## Theorem

Let $X$ be a continuous random variable which satisfies the logistic distribution:

$X \sim \map {\operatorname {Logistic} } {\mu, s}$

The variance of $X$ is given by:

$\var X = \dfrac {s^2 \pi^2} 3$

### Lemma 1

$\ds \int_{\to 0}^{\to 1} \map {\ln^2} {1 - u} \rd u = 2$

### Lemma 2

$\ds \int_{\to 0}^{\to 1} \map {\ln^2} u \rd u = 2$

### Lemma 3

$\ds \int_{\to 0}^{\to 1} \map \ln u \map \ln {1 - u} \rd u = 2 - \dfrac {\pi^2} 6$

### Lemma 4

$\ds \int_{\to 0}^{\to 1} \map {\ln^2} {\dfrac {1 - u} u} \rd u = \dfrac {\pi^2} 3$

## Proof 1

From the definition of the logistic distribution, $X$ has probability density function:

$\map {f_X} x = \dfrac {\map \exp {-\dfrac {\paren {x - \mu} } s} } {s \paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^2}$
$\ds \var X = \int_{-\infty}^\infty x^2 \, \map {f_X} x \rd x - \paren {\expect X}^2$

So:

$\ds \var X = \frac 1 s \int_{-\infty}^\infty \dfrac {x^2 \map \exp {-\dfrac {\paren {x - \mu} } s} } {\paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^2} \rd x - \mu^2$

let:

 $\ds u$ $=$ $\ds \paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^{-1}$ Integration by Substitution $\ds \leadsto \ \$ $\ds \frac {\d u} {\d x}$ $=$ $\ds -\paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^{-2} \paren {-\frac 1 s \map \exp {-\dfrac {\paren {x - \mu} } s} }$ Power Rule for Derivatives, Chain Rule for Derivatives and Derivative of Exponential Function: Corollary 1 $\ds \leadsto \ \$ $\ds \dfrac 1 u - 1$ $=$ $\ds \paren {\map \exp {-\dfrac {\paren {x - \mu} } s} }$ $\ds \leadsto \ \$ $\ds \map \ln {\dfrac 1 u - 1}$ $=$ $\ds -\dfrac {\paren {x - \mu} } s$ $\ds \leadsto \ \$ $\ds -s \map \ln {\dfrac {1 - u} u} + \mu$ $=$ $\ds x$ $\ds \leadsto \ \$ $\ds \mu^2 -2 s \mu \map \ln {\dfrac {1 - u} u} + s^2 \map {\ln^2} {\dfrac {1 - u} u}$ $=$ $\ds x^2$

and also:

 $\ds \lim_{x \mathop \to -\infty} \paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^{-1}$ $=$ $\ds 0$ $\ds \lim_{x \mathop \to \infty} \paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^{-1}$ $=$ $\ds 1$

Then:

 $\ds \var X$ $=$ $\ds \int_{\to 0}^{\to 1} \paren {\mu^2 - 2 s \mu \map \ln {\dfrac {1 - u} u} + s^2 \map {\ln^2} {\dfrac {1 - u} u} } \rd u - \mu^2$ $\ds$ $=$ $\ds \mu^2 \int_{\to 0}^{\to 1} \rd u - 2 s \mu \int_{\to 0}^{\to 1} \map \ln {\dfrac {1 - u} u} \rd u + s^2 \int_{\to 0}^{\to 1} \map {\ln^2} {\dfrac {1 - u} u} \rd u - \mu^2$ $\ds$ $=$ $\ds \mu^2 - 2 s \mu \paren {\int_{\to 0}^{\to 1} \map \ln {1 - u} \rd u - \int_{\to 0}^{\to 1} \map \ln u \rd u } + s^2 \paren {\int_{\to 0}^{\to 1} \map {\ln^2} {1 - u} \rd u - 2 \int_{\to 0}^{\to 1} \map \ln {1 - u} \map \ln u \rd u + \int_{\to 0}^{\to 1} \map {\ln^2} u \rd u } - \mu^2$ Definite Integral of Constant and Difference of Logarithms $\ds$ $=$ $\ds \mu^2 - 2 s \mu \paren {\paren {-1} - \paren {-1} } + s^2 \paren {2 - 2 \paren {2 - \dfrac {\pi^2} 6 } + 2 } - \mu^2$ Expectation of Logistic Distribution:Lemma 1, Expectation of Logistic Distribution:Lemma 2, Lemma 1, Lemma 2 and Lemma 3 $\ds$ $=$ $\ds \dfrac {s^2 \pi^2} 3$

$\blacksquare$

## Proof 2

By Moment Generating Function of Logistic Distribution, the moment generating function of $X$ is given by:

$\ds \map {M_X} t = \map \exp {\mu t} \int_{\to 0}^{\to 1} \paren {\dfrac {1 - u} u}^{-s t} \rd u$

for $\size t < \dfrac 1 s$.

$\ds \var X = \expect {X^2} - \paren {\expect X}^2$

From Expectation of Logistic Distribution, we have:

$\expect X = \mu$
$\ds \map { {M_X}''} t = \map \exp {\mu t} \paren {\mu^2 \int_{\to 0}^{\to 1} \paren {\dfrac {1 - u} u}^{-s t} \rd u - 2 s \mu \int_{\to 0}^{\to 1} \map \ln {\dfrac {1 - u} u} \paren {\dfrac {1 - u} u}^{-s t} \rd u + s^2 \int_{\to 0}^{\to 1} \map {\ln^2} {\dfrac {1 - u} u} \paren {\dfrac {1 - u} u}^{-s t} \rd u}$

Hence setting $t = 0$:

 $\ds \map { {M_X}''} 0$ $=$ $\ds \mu^2 \int_{\to 0}^{\to 1} \rd u - 2 s \mu \int_{\to 0}^{\to 1} \map \ln {\dfrac {1 - u} u} \rd u + s^2 \int_{\to 0}^{\to 1} \map {\ln^2} {\dfrac {1 - u} u} \rd u$ $\ds$ $=$ $\ds \mu^2 - 2 s \mu \paren {0 } + s^2 \paren {\dfrac {\pi^2} 3}$ Definite Integral of Constant, Expectation of Logistic Distribution/Lemma 3 and Lemma 4 $\ds$ $=$ $\ds \mu^2 + \dfrac {s^2 \pi^2} 3$

So:

 $\ds \var X$ $=$ $\ds \mu^2 + \dfrac {s^2 \pi^2} 3 - \mu^2$ $\ds$ $=$ $\ds \dfrac {s^2 \pi^2} 3$

$\blacksquare$

## Proof 3

From the definition of the logistic distribution, $X$ has probability density function:

$\map {f_X} x = \dfrac {\map \exp {-\dfrac {\paren {x - \mu} } s} } {s \paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^2}$
$\ds \var X = \int_{-\infty}^\infty x^2 \, \map {f_X} x \rd x - \paren {\expect X}^2$

So:

 $\ds \var X$ $=$ $\ds \frac 1 s \int_{-\infty}^\infty \dfrac {x^2 \map \exp {-\dfrac {\paren {x - \mu} } s} } {\paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^2} \rd x - \mu^2$ $\ds$ $=$ $\ds \frac 1 s \int_{-\infty}^\mu \dfrac {x^2 \map \exp {-\dfrac {\paren {x - \mu} } s} } {\paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^2} \rd x + \frac 1 s \int_\mu^\infty \dfrac {x^2 \map \exp {-\dfrac {\paren {x - \mu} } s} } {\paren {1 + \map \exp {-\dfrac {\paren {x - \mu} } s} }^2} \rd x\ - \mu^2$ Sum of Integrals on Adjacent Intervals for Integrable Functions $\ds$ $=$ $\ds \frac 1 s \int_{-\infty}^0 \dfrac {\paren {sz + \mu}^2 \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \paren {s\rd z } + \frac 1 s \int_0^\infty \dfrac {\paren {sz + \mu}^2 \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \paren {s\rd z } - \mu^2$ $z = \dfrac {\paren {x - \mu} } s$; $s\rd z = \rd x$ $\ds$ $=$ $\ds \int_{-\infty}^0 \dfrac {\paren {s^2z^2 + 2sz\mu} \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \rd z + \int_0^\infty \dfrac {\paren {s^2z^2 + 2sz\mu} \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \rd z$ cleaning up; s and $\mu^2$ cancel $\ds$ $=$ $\ds \int_0^\infty \dfrac {\paren {s^2z^2 - 2sz\mu} \map \exp {z} } {\paren {1 + \map \exp {z} }^2} \rd z + \int_0^\infty \dfrac {\paren {s^2z^2 + 2sz\mu} \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \rd z$ rewriting the first integral $\ds$ $=$ $\ds \int_0^\infty \dfrac {\paren {s^2z^2 - 2sz\mu} \map \exp {z} } {\map \exp {2 z} \paren {1 + \map \exp {-z} }^2} \rd z + \int_0^\infty \dfrac {\paren {s^2z^2 + 2sz\mu} \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \rd z$ extracting $\map \exp {2 z}$ from the denominator of the first integral $\ds$ $=$ $\ds 2s^2 \int_0^\infty \dfrac {z^2 \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2} \rd z$ simplifying

From Sum of Infinite Geometric Sequence, we have:

$\ds \sum_{n \mathop = 0}^\infty \paren {-1}^n \map \exp {-z}^n = \dfrac 1 {1 + \map \exp {-z} }$

Taking the derivative of both sides, we have:

 $\ds \sum_{n \mathop = 0}^\infty \paren {-n} \paren {-1}^n \map \exp {-z}^n$ $=$ $\ds \dfrac { \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2}$ $\ds \sum_{n \mathop = 1}^\infty n \paren {-1}^{n + 1} \map \exp {-z}^n$ $=$ $\ds \dfrac { \map \exp {-z} } {\paren {1 + \map \exp {-z} }^2}$ simplifying

Therefore:

 $\ds \var X$ $=$ $\ds 2 s^2 \paren {\int_0^\infty z^2 \sum_{n \mathop = 1}^\infty n \paren {-1}^{n + 1} \map \exp {-z}^n \rd z}$ substitution from above $\ds$ $=$ $\ds 2 s^2 \paren {\sum_{n \mathop = 1}^\infty n \paren {-1}^{n + 1} \int_0^\infty z^2 \map \exp {-n z} \rd z}$ Fubini's Theorem $\ds$ $=$ $\ds 2 s^2 \paren {\sum_{n \mathop = 1}^\infty n \paren {-1}^{n + 1} \bigintlimits {-\dfrac 1 n \map \exp {-nz} \paren {z^2 + \frac {2 z} n + \frac 2 {n^2} } } 0 \infty }$ Primitive of x squared by Exponential of a x $\ds$ $=$ $\ds 2 s^2 \paren {\sum_{n \mathop = 1}^\infty n \paren {-1}^{n + 1} \paren {0 + \dfrac 1 n \paren {0^2 + \frac 0 n + \frac 2 {n^2} } } }$ $\ds$ $=$ $\ds 4 s^2 \paren {\sum_{n \mathop = 1}^\infty \paren {-1}^{n + 1} \frac 1 {n^2} }$ $\ds$ $=$ $\ds 4 s^2 \paren {\dfrac {\pi^2} {12} }$ Sum of Reciprocals of Squares Alternating in Sign $\ds$ $=$ $\ds \dfrac {s^2 \pi^2} 3$

$\blacksquare$