# Plot the exact density of a transformation of a distribution

I would like to compute (and plot) the exact density of the following distribution:

$$X_i \sim exp(-Exponential(\lambda)) - 0.5$$

I already have the estimated density for this distribution, but I need to get its exact density to compute the MSE of my kernel estimator.

I have difficulties to transform the function to be able to plot its density.

For now, I have tried to compute it (with r). I used the inverse of the transformation to be able to compute the pdf using dexp().

X2 <- exp(-rexp(n,rate =1))-0.5 #get random sample
X2<-sort(X)
plot(X2,dexp(-log(X2+0.5)))


But this gives me results that are not coherent with my estimated density.

What am I doing wrong here?

• Welcome to CV nahaut. To see what goes wrong, write $\text{Pr}[X \leq x ]$ as a probability involving the exponentilal r.v. say $E$ then use the known distribution of $E$. – Yves Jan 5 at 15:54
• Thanks. I don't understand exactly what you meant. I tried to calculate the density using the transformation method but it's not giving me the correct results. – nahaut Jan 5 at 19:20
• I considered that $-ln(X_i + 0.5) \sim Exponential(\lambda)$. Then, I considered that it was a function of the random variable: $U= -ln(X_i + 0.5)$. After computation, the result I got was not giving the adequate density: $fu(U)= e^{-e^{-u}+0.5-u}$ – nahaut Jan 5 at 19:27
• Note that $X$ has its values in $I:=(-0.5, \, 0.5)$. For $x \in I$, we have $\text{Pr}\{X \leq x \} = \text{Pr}\{U \geq - \log(x + 0.5) \} = \exp[\lambda \log(x + 0.5)]$ since $\text{Pr}\{U \geq u \} = \exp[-\lambda u]$ for $u > 0$. So $\text{Pr}\{X \leq x \} = [ x + 0.5]^\lambda$ and the density comes by derivation. Please use the appropriate tag homework̀ or self-study. – Yves Jan 6 at 8:15
• Look for the keyword Jacobian to understand your mistake. – Xi'an Jan 6 at 21:25