Assume we have a continuous random variable $X$, with a probability density function

$$ f(x) = 1 - \frac{x}{2},\; 0 < x < 2 $$

Let's say I want to calculate $E(2X)$. I will use two different methods, and get different results, so I obviously understand something wrong.


Using the formula for the expectation of a function of a random variable, I get:

$$ E(2X) = \int_{-\infty}^{+\infty} 2xf(x)dx = \int_0^2 (2x-2x^2)dx = \frac{4}{3} $$

I understand this formula intuitively, as it's pretty much exactly the same as in the discrete case, if we replace the integral with a finite sum and the probability density function with the probability mass function. Only the values change, and not the distribution, so we only apply the function 2x to the values, and not the distribution $f(x)$.


Let's say I declare a new continuous random variable, $Y = 2X$. I can calculate the probability density function of $Y$:

$$ g(y) = |\frac{dx}{dy}|f(x) = \frac{1}{2}f(\frac{y}{2}) = \frac{1}{2}(1-\frac{y}{4})$$

for $0<y<4$.

Then I can calculate:

$$ E(2X) = E(Y) = \int_{-\infty}^{+\infty} y\;g(y)dx = \int_0^4 \frac{1}{2}(1-\frac{y}{4})dx = \frac{2}{3} $$

I don't understand what I did wrong here.

But I also don't understand the formula for $g(y)$ intuitively - shouldn't $g(y)$ and $f(x)$ be the same functions if they're injective, similar to the discrete case?

Anyway, if someone can point out what I did wrong, I would be very grateful.


You forgot to multiply by $y$ for the second computation.

$g(y)$ and $f(x)$ are different functions, but they are related by $g(y)=\frac{1}{2}f\big(\frac{y}{2}\big)$ and are both decreasing (also see here). For instance, $h_{1}(x)=x$ and $h_{2}(x)=2x$ are injective, but $h_{1}(1)=1$ and $h_{2}(1)=2$.

It is a good idea to check if $g(y)=\frac{1}{2}(1-\frac{y}{4})$ for $0<y<4$ is a valid pdf. Indeed we have $g(y)\geq 0$ for $0<y<4$ and $\int_{-\infty}^{\infty}g(y)dy=\frac{1}{2}\int_{0}^{4}(1-\frac{y}{4})dy=1,$ so $g(y)$ is a valid pdf.

Next we have $$ E(2X) = E(Y) = \int_{-\infty}^{+\infty} y\;g(y)dx = \int_0^4 \frac{\color{red}{y}}{2}(1-\frac{y}{4})dx = \frac{4}{3} $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.