Density function with absolute value Let $X$ be a random variable distributed with the following density function:
$$f(x)=\frac{1}{2} \exp(-|x-\theta|) \>.$$
Calculate: $$F(t)=\mathbb P[X\leq t], \mathbb E[X] , \mathrm{Var}[X]$$
I have problems calculating $F(t)$ because of the absolute value. I'm doing it by case statements but it just doesn't get me to the right answer.
So it gets to this:
$$
\int_{-\infty}^\infty\frac{1}{2} \exp(-|x-\theta|)\,\mathrm dx $$

If $x\ge\theta$ then $|x-\theta|=x-\theta$.
If $x<\theta$ then $|x-\theta| = \theta-x$.
So
$$
\int_{-\infty}^\infty x \frac 1 2 \exp(-|x-\theta|)\,dx = \int_{-\infty}^\theta x\frac 1 2 \exp(\theta-x)\;dx + \frac 1 2 \int_\theta^\infty x \exp(\theta-x)\;dx.
$$
By symmetry, the expected value should be $\theta$ if there is an expected value at all.  And, as it happens, there is.  The only thing that would prevent that is if one of the integrals were $+\infty$ and the other $-\infty$.
If you use the substitution
$$
u = x-\theta, \qquad du = dx,
$$
then what you have above becomes
$$
\frac 1 2 \int_{-\infty}^0 (u+\theta) \exp(u)\;du + \frac 1 2\int_0^\infty (u+\theta)\exp(-u)\;du
$$
This is
$$
\begin{align}
& \frac 1 2 \int_{-\infty}^0 u \exp(u)\;du + \frac 1 2 \int_0^\infty u\exp(-u)\;du + \frac 1 2 \int_{-\infty}^0 \theta \exp(u)\;du + \frac 1 2 \int_0^\infty \theta\exp(-u)\;du \\  \\
& = \frac 1 2 \int_{-\infty}^\infty u \exp(-|u|)\;du + \theta\int_{-\infty}^\infty \frac 1 2 \exp(-|u|)\;du
\end{align}
$$
The first integral on the last line is $0$ because you're integrating an odd function over the whole line.  The second is $1$ because you're integrating a probability density function over the whole line.
So you're left with $\theta$.
