# Let $X$ be uniformly distributed in the interval $[0, 2].$ [closed]

(a) Compute $$E(e^X)$$

(b) Compute $$E(\sin(X))$$

I am confused that how to compute the interval since it did not give the formula

Let $$\phi(x)$$ be the density of $$X$$.

Since $$X \sim U[0,2]$$, it follows that $$\phi(x) = 1/2$$ on the interval $$[0, 2]$$ and $$\phi(x) = 0$$ outside of the interval $$[0, 2]$$.

Therefore, \lower{7.5ex}{\begin{align*} \mathbb{E}[f(X)] &= \int_{-\infty}^{\infty} \phi(x) f(x) dx \\[1ex]&= \int_{-\infty}^{0} 0 \cdot f(x) dx + \int_0^2 \frac{1}{2} f(x) dx + \int_2^\infty 0 \cdot f(x) dx \\[1ex]&= \int_0^2 \frac{1}{2} f(x) dx. \end{align*}}

In your case, you have two different $$f$$.

Substitute each one into the above and compute the resulting integral.

What you want to do is the following:

(a) $$\displaystyle\int_0^2 \dfrac{1}{2}e^x dx$$, which is $$\dfrac{e^2-1}{2}$$, and

(b) $$\displaystyle\int_0^2 \dfrac{1}{2}\sin x dx$$, which is $$\dfrac{1-\cos2}{2}$$.