How would I solve this?
Let $X\sim \exp (\lambda )$ be a random variable. Furthermore, let $Y=g(X)$, with$$g(X)=\left \{\begin{matrix}a & \text{if} & X<a, \\ X & \text{if} & X>a.\end{matrix}\right .$$
What is $\mathbb{E}(Y)$?
The correct answer is $\mathbb{E}(Y)=a+\dfrac{1}{\lambda}e^{-\lambda a}$.
I tried many times, but I could never get to the correct answer. Any help is appreciated!
By definition:
$$E[g(x)]=\int_0^\infty g(x)f_X(x)~dx$$
where $f_X(x)=\lambda e^{-\lambda x}$, so we have:
$$E[g(x)]=\int_0^a af_X(x)~dx+\int_a^\infty xf_X(x)~dx$$
$$E[g(x)]=\int_0^a a\lambda e^{-\lambda x}~dx+\int_a^\infty x\lambda e^{-\lambda x}~dx$$
You can procced from here to compute these two integrals, and you will get that answer.