# Calculating Density Function in Probability?

Given that: $$Y \sim \text{Exp}(j)$$ and $$X \sim \text{Uni}(a,b)$$ independent from each other. How may I calculate the density of $$Z=Y-X$$ knowing that: $$f_{X+Y}(z)=\int_{-\infty}^\infty f_X(x)f_Y(z-x)\mathrm dx.$$

with your help I have calculated the density function for $$-x$$ which is

$$f_{-X}(-x) = \begin{cases} \dfrac{1}{b-a} &-x \in [a,b] \\ 0 & \text{otherwise}. \end{cases}$$

And I got too: $$\int_{-\infty}^\infty f_Y(y)f_{-X}(-x)dy$$

But how to continue from here? Plus how may I seperate the fields in which this is zero?

I know that: $$f_{Y}(y) = \begin{cases} \lambda e^{-\lambda y} &y >=0 \\ 0 & \text{otherwise}. \end{cases}$$

Update: I got

$$f_Z(z)$$= 0 if $$y<0$$ or $$x<-b$$ or $$x>-a$$

else $$1/{b-a}$$

My my book has a totally different Answer:

if $$z<-b$$ then $$0$$

if $$z>-a$$ then $$\dfrac {e^{- \lambda(a+z)}-e^{- \lambda(b+z)}}{b-a}$$

else $$\dfrac {1- e^{- \lambda(b+z)}}{b-a}$$

• change the variables and then integrate Jan 9, 2021 at 18:52
• Can someone kindly help with this one? is everything clear with my question? I have been trying for hours and no result Jan 9, 2021 at 20:48

HINT: you have that \begin{align*} \Pr [X-Y\leqslant c]&=\int_{\{(x,y)\in\mathbb{R}^2:x-y\leqslant c\}}f_X(x)f_Y(y)\mathop{}\!d (x,y)\\ &=\int_{\mathbb{R}}f_Y(y)\left(\int_{(-\infty ,c+y]}f_X(x)\mathop{}\!dx\right)\mathop{}\!d y\\ &=\int_{\mathbb{R}}f_Y(y)F_X(c+y)\mathop{}\!d y \end{align*}

• Can you kindly continue in the same method I started? Jan 9, 2021 at 19:54
• @White Im not sure what to do with $f_{-X}(-x)$ or what you are doing, instead try to follow the general procedure, that is $$\Pr [G(X_1,\ldots ,X_n)\leqslant c]=\Pr [(X_1,\ldots ,X_n)\in G^{-1}((-\infty ,c])]=\int_{G^{-1}((-\infty ,c])}\prod_{k=1}^n f_{X_n}(x_n)\mathop{}\!d (x_1,\ldots ,x_n)$$ where $X_1,\ldots ,X_n$ are independent and $G$ is any Lebesgue measurable function Jan 9, 2021 at 22:08
• I want it to be used with knowing that: (the sentence given by the question) Jan 10, 2021 at 8:43