Mean and Variance of Continuous Random Variable

I have a problem on my homework about the continuous random variable $$y$$ where the cdf is $$F(y)=\frac{1}{(1+e^{-y})}$$.

Part a is asking for the pdf which I found to be $$\frac{e^y}{(e^y+1)^2}$$.

Part b asks for the mean and variance of $$y$$ but when I tried to find the $$E(y)$$, I got zero with the integral from $$-\infty$$ to $$\infty$$ of $$\frac{ye^y}{(e^y+1)^2}$$. I'm not sure where I'm going wrong with this problem?

This distribution is the standard logistic distribution, and its moments and information are examined in deCani and Stine (1986). The distribution function can be written equivalently in either of the following two forms:

$$F_Y(y) = \frac{1}{1+e^{-y}} = \frac{e^y}{1+e^y} .$$

The density function can be written in either of the following two forms:

$$f_Y(y) = \frac{e^{-y}}{(1+e^{-y})^2} = \frac{e^{y}}{(1+e^{y})^2}.$$

Since $$f_Y(y) = f_Y(-y)$$ for all $$y \in \mathbb{R}$$ the density is symmetric around zero, so it is trivial to show that $$\mathbb{E}(Y)=0$$. Deriving the variance is more difficult, but it can be done by a number of different methods. This simplest method is to derive the moment-generating function of the distribution and use this to get the variance. Another method is to derive the variance is by direct application of the variance formula, using integration by parts in conjunction with the symmetry of the density function. (This leads to an integral involving the dilogarithm function, which then requires you to take limits of this function using an asymptotic form. The mathematics for this derivation gets pretty long.)

Since this is homework, I will not show you how to do either of these derivations, but I might come back to this question later and add them, once enough time has elapsed so that your homework has been submitted. I recommend attempting the derivation of the variance by first finding the moment-generating function. If you have trouble you could consult the cited paper to review their method.

• Thanks for name of distribution, which was eluding me. (+1) – BruceET Apr 10 at 0:29

What makes you think you did something wrong?

\begin{align} & \Pr(Y\le y) = F(y) = \frac 1 {1+e^{-y}} \\[10pt] \text{and } & \Pr(Y\ge -y) = 1-F(-y) = 1- \frac 1 {1+e^y} \\[8pt] = {} & \frac{e^y}{1+e^y} = \frac{e^y\cdot e^{-y}}{(1+e^y)\cdot e^{-y}} = \frac 1 {e^{-y}+1}, \end{align} and therefore $$\Pr(Y\le y) = \Pr(Y \ge -y).$$ So this distribution is symmetric about $$0.$$

Therefore, if the expected value exists, it is $$0.$$

You can also show that the density function is an even function: \begin{align} f(y) & = \frac{e^y}{(1+e^y)^2}. \\[12pt] f(-y) & = \frac{e^{-y}}{(1+e^{-y})^2} = \frac{e^{-y}\cdot\left( e^y \right)^2}{\Big((1+e^{-y}) \cdot e^y \Big)^2} = \frac{e^y}{(e^y+1)^2} = f(y). \end{align} Since the density is an even function, the expected value must be $$0$$ if it exists.

The expected value $$\operatorname E(Y)$$ exists if $$\operatorname E(|Y|) < +\infty.$$

Comment:

Setting what I take to be your CDF equal to $$U \sim \mathsf{Unif}(0,1),$$ and solving for the quantile function (inverse CDF) in terms of $$U,$$ I simulate a sample of ten million observations as shown below. [Thanks to @Noah for recent clarification of notation in Problem.]

Then, when I plot your PDF through the histogram of the large sample, that density function seems to fit pretty well.

set.seed(1019)     # for reproducibility
u = runif(10^7);  x = -log(1/u - 1)
mean(x);  sd(x);  sqrt(pi^2/3);  2*sd(x)/sqrt(10^7)
[1] -0.000594651   # aprx E(X) = 0
[1] 1.81335        # aprx SD(X) = 1.813799
[1] 1.813799       # exact SD(X) per Wikipedia on 'logistic distn'
[1] 0.003626701    # aprx 95% margin of simulation error for E(X)

hist(x, prob=T, br=100, col="skyblue2")
curve(exp(x)/(exp(x)+1)^2, -10, 10, add=T, lwd=2, col="red")


I don't pretend that this is a 'worked answer' to your problem, but I hope it may give you enough clues to improve the version of the problem you posted and to finish the problem on your own.