Here is a three part question involving continuous random variables and expected value that I have attempted:
Part A: Given the following function, calculate the value of $C > 0$.
$$ f(x) = \begin{cases} C\sin^{2}(x) & 0\leq x \leq \pi \\ 0 & (-\infty\leq x \leq 0] \cup [\pi\leq x \leq +\infty) \end{cases}$$
Computation:
$$\int_{0}^{\pi}C\sin^{2}(x)dx=C\int_{0}^{\pi}\sin^{2}(x)dx= C\frac{\pi}{2} $$
$$C\frac{\pi}{2}=1 \implies C=\frac{2}{\pi}$$
Part B: Using the function and the C-value you calculated above, find $E(X)$.
Computation:
$$E(X)=\int_{-\infty}^{+\infty}xf(x)dx$$
$$E(X)=\int_{0}^{\pi}x\frac{2}{\pi}\sin^{2}(x)dx=\frac{2}{\pi}\int_{0}^{\pi}x\sin^{2}(x)dx = \frac{\pi}{2}$$
Part C: Calculate $E(\cos(X))$.
Computation:
$$E(g(x))=\int_{-\infty}^{+\infty}g(x)f(x)dx$$
$$E(\cos(X))=\int_{0}^{\pi}\cos(x)\frac{2}{\pi}\sin^{2}(x)dx=\frac{2}{\pi}\int_{0}^{\pi}\cos(x)\sin^{2}(x)dx = 0$$
*For each computation we should be integrating from $-∞$ to $+∞$. To save some time and space, I only integrated from $0$ to $π$ because the integrals will be equal to zero outside of that interval.