# Expected value of the function of a uniformly distributed random variable

Let X by a uniformly distributed random variable on the interval [0,1]. Find $E[e^Y]$

I am trying to make use of the formula $$E[g(X)] = \int_{-\infty}^{\infty}g(x)xdx$$

so then $$E[e^X] = \int e^xxdx$$

What I am unsure of are the bounds of integration. Would they be from 0 to 1, which is the interval of Y, or would they be from $e^0$ to $e^1$?

Additionally, we are also given that Y is a uniformly distributed variable on the interval [0,1] as well. Find $E[e^{Y-X}]$. Since they are independent, would it be the correct approach to first find $E[e^Y]$, then $E[e^{-X}]$, and multiply the two together?

Furthermore, apparently there is a much easier way to solve this problem without needing to do any integration, but I am having difficulty conceptualizing this method. Thoughts?

Your formula above is not quite correct. Suppose that $Z$ is any continuous random variable with density $f_Z(z)$. Then for a "nice enough" function $g$, we have $$E[g(Z)] = \int_{-\infty}^{\infty} g(z) f_Z(z) dz.$$ In the uniform case, the density of $X$ is $$f_X(x) = \begin{cases} 1 & 0 \leq x \leq 1 \\ 0 & \text{ otherwise} \end{cases}$$ Letting $g(x) = e^x$, you get $$E[g(x)] = \int_{-\infty}^{\infty} g(x)f_X(x)dy = \int_{0}^1 e^x \cdot 1\, dx + \int_{-\infty}^{0} e^x \cdot 0\, dx + \int_1^{\infty} e^x \cdot 0\, dx\\ = \int_{0}^1 e^x \,dx.$$

For your second question, $E[e^Ye^{-X}] = E[e^Y]E[e^{-X}]$ if $X$ and $Y$ are independent. Otherwise you will need to know their joint density.

• X and Y are indeed independent. Given this, how do I find their joint density anyway? Nov 10, 2013 at 14:48
• @Luchia Since the two are independent, the joint density is just the product of the two individual densities. Nov 10, 2013 at 14:49
• If $X$ and $Y$ are independent, then the joint density $f_{X,Y}(x,y)$ is just $$f_{X,Y}(x,y) = f_X(x) f_Y(y).$$ This is why, when $X$ and $Y$ are independent, you can write $E[g(X)h(Y)] = E[g(X)]E[h(Y)]$, like you suggested.
– Tom
Nov 10, 2013 at 14:51
• Why do you integrate from -1 to 1? Should it not be from 0 to 1 because that is where Y takes on its values? Nov 10, 2013 at 14:54
• Sorry for the typo @Luchia! You are absolutely correct! Good catch.. it is integrated from 0 to 1. I've edited it for the fix.
– Tom
Nov 10, 2013 at 14:55

First of all, the correct formula for $E[g(x)]=\int g(x) f(x) dx$, where $f(x)$ denotes the pdf of the distribution (so you expression is currently incorrect). The pdf for a uniform distribution is $f(x)=\frac{1}{b-a}$ for $a \leq x \leq b$.

Therefore, the intergral would then become:

$\int_{0}^{1} e^y \frac{1}{b-a} dy=\frac{1}{1-0} \int_{0}^{1}e^ydy=e^y]^{1}_{0}=e-1$

As for your second question, yes, that is correct.

• Where are you getting the integration limits of -1 and 1 from? Nov 10, 2013 at 14:51
• @Luchia The pdf of the uniform distribution is only defined for $a \leq x \leq b$, in our case, this means it is only defined between $0 \leq x \leq 1$. To find the expected value, we have to integrate over all the values for which the function is defined. Hence this means integrating between $0$ and $1$. Nov 10, 2013 at 14:53
• However, the function is defined from 0 to 1 and not -1 to 1, so that is where I am confused. Nov 10, 2013 at 14:55