Suppose there is a random variable $Y$ and $X$ such that:
For $0 \leq X \leq 3$, $Y=0.2$.
For $X \geq 3$, $Y = 0.2 + 0.08(X-3)$.
If $X$ follows an exponential distribution ($E[X] = \frac{1}{\lambda})$.
What is the $E[Y]$?
I tried to solve this problem by calculating $\int^{3}_{0}0.2xdx + \int^{\infty}_3 x[0.02+0.08(\lambda e^{-\lambda x}-3)]dx$. But this results in an answer of infinity ($\int^{\infty}_3 0.02xdx$), so I must be doing something wrong.
You are trying to use $$\mathsf E Y=\mathsf E_X (\mathsf E Y|X)$$ So $$\mathsf E Y|X=\begin{cases} 0.2, & 0\le x\le3\\ 0.2+0.08(x-3) & x\ge 3\\ \end{cases}$$ Now calculate the expectation with respect to $X$: $$\mathsf EY=\mathsf E_X(\mathsf EY|X)=\int_0^30.2f_X(x)dx+\int_3^{\infty}(0.2+0.08(x-3))f_X(x)dx$$ which further boils down to $$\mathsf EY=(0.2)F_X(3)+(0.2-0.24)(1-F_X(3))+(0.08)\int_3^{\infty} xf_X(x)dx$$ Where $F_X(x)=1-e^{-\lambda x}$ is the exponential cdf. Simplification leads to $$\mathsf EY=0.2-(0.24)e^{-3\lambda}+(0.08)\frac{(3\lambda+1)e^{-3\lambda}}{\lambda}$$