I need to have a formula for calculating the mean and variance for logistic distribution to fit some data I have to it. I know that the mean is $\int_{-\infty}^\infty xf(x).dx $ where f(x) is the pdf for the distribution which is $$f(x)=\frac{e^{-\frac{x-\mu}{\sigma}}}{{(1+e^{-\frac{x-\mu}{\sigma}})}^2} $$ Is there an existing solution for this integral? Or is there an easier method for calculating the mean? I found a proof for the variance to be $\pi^2\over3$ for a normalized distribution, but I couldn't do the trick for my problem.
I normalized the pdf and substituted as: $$mean =\int_{-\infty}^\infty x\frac{e^{-x}}{({1+e^{-x}})^2} $$ Split the integral: $$ =\int_{-\infty}^0 x\frac{e^{-x}}{({1+e^{-x}})^2}+\int_0^\infty x\frac{e^{-x}}{({1+e^{-x}})^2} $$ For the second integral, I saw something similar, but I don't really understand it quite well: $$\int_0^\infty x\frac{e^{-x}}{({1+e^{-x}})^2}=\int_0^\infty x\sum_{n=1}^\infty n(-1)^{n-1}e^{-nx}.dx=\sum_{n=1}^\infty n(-1)^{n-1}\int_0^\infty xe^{-nx}.dx $$ Solving the integration by parts: $$=\sum_{n=1}^\infty n(-1)^{n-1}\int_0^\infty xe^{-nx}.dx= \sum_{n=1}^\infty n(-1)^{n-1}\frac{n+1}{n^2} $$ However, I can't proceed from here.
So, my questions are:
How is this possible? $\int_0^\infty\frac{e^{-x}}{(1+e^{-x})^2}=\sum_{n=1}^\infty n(-1)^{n-1}e^{-nx}$
How to proceed with evaluating the series and what to do with the first integral? Or is there an already answer/easier way for finding the mean for logistic distribution?
In this, I assume a normalized data. So, I didn't use the form $f(x)=\frac{e^{-\frac{x-\mu}{\sigma}}}{{(1+e^{-\frac{x-\mu}{\sigma}})}^2} $ because I thought maybe it's easier to normalize my data and work on them. But is there another method to work directly on the raw data?
I can find the mean and variance for the dataset I have using MATLAB, but I'm interested in calculating them myself