# Homework Help: PDF of an exponential distribution

1. Nov 28, 2012

### SallyY

1. The problem statement, all variables and given/known data
Hi! I'm trying to find the PDF of W = abs(X-λ), where X is an exponential R.V. with rate parameter λ>0.

2. Relevant equations
The PDF for an exponential distribution is ∫λe^(-λx)dx.
Taking the derivative of a CDF will yield the PDF for that function (I'm aware there are other methods, but I've not yet learned them so I'd like to stick to this one).

3. The attempt at a solution
First, it should be noted that the function V=abs(X-λ) is 2 to 1 from the range 0 to 2λ, so i think we split the CDF into two parts, one for 0<W<2λ, the second for W<2λ? I'm not entirely sure on this though!
Second, simplify Pr{abs(x-λ)≤w} into Pr{-w+λ≤x≤w+λ}. This should give us the bounds to integrate on for 0≤w≤2λ, I believe?
So we get ∫λe^(-λx)dx from {-w+λ} to {w+λ}, or
-e^(-λx) from {-w+λ} to {w+λ}.
This is where I run into trouble:
First, substituting in those numbers gives me a not-very-pretty equation for the CDF of w=abs(x-λ) {0<w<2λ}. Am I doing something wrong there?
Second, I'm not sure what to do with the rest of the CDF - do I just integrate the exponential distribution from 2λ to infinity?
Thanks so much for your help!
Sally

2. Nov 28, 2012

### Mute

So, I agree that $\mbox{Pr}(W \leq w) = \mbox{Pr}(|X-\lambda| \leq w) \Rightarrow \mbox{Pr}(\lambda-w \leq X \leq w+\lambda)$.

I want to make some comments on calculating the pdf from the CDF before I go further. First, it seems like you intend on evaluating the integral and then taking the derivative. You don't need to do this! You can differentiate the integral directly. Are you aware of the rule

$$\frac{d}{dx} \left[ \int_{a(x)}^{b(x)} dt~f(t)\right] = f(b(x)) \frac{db}{dx} - f(a(x))\frac{da}{dx}?$$

Using this rule will save you from having to evaluate the integral and then differentiate! (This rule - or rather a slight generalization of it which allows f(t) to also depend on x - is called the Leibniz rule. It also follows quite simply from the fundamental theorem of calculus: if the antiderivative of f(t) is F(t), then the integral is F(b(x))-F(a(x)). Taking the derivative of this and applying the chain rule gives the result I gave you).

The second thing I want to point out is that you have to be careful when taking the derivative because x cannot be negative. To take care of this issue, it would be easiest if you define your pdf for X not simply as $\lambda e^{-\lambda x}$ on $x \in [0,\infty)$ but as $\lambda e^{-\lambda x}\Theta(x)$ on $x \in (-\infty,\infty)$, where $\Theta(x)$ is the Heaviside step function (=0 for x negative, 1 for x positive). Although these two forms are effectively the same, the second will be more convenient for calculating the pdf of w because it will automatically enforce the condition that x cannot be negative, so you won't have to worry about splitting the integral up into different cases.

Think you can take it from here?

3. Nov 28, 2012

### SallyY

Thanks for your help! Unfortunately, I'm still pretty confused. The leibniz rule makes sense (probably learned it at some point:) ) but i'm a bit confused about the rest still!
First, I don't see how the heaviside step function helps in anything but a fairly trivial sense; is including it any different from adding a "0 if 0>w" to the PDF?
Second, for 0<w<2λ, do I use the leibniz rule with the exponential distribution PDF?
(I came up with λe(-λ^2-λw) - λe(-λ^2+λw))
Third, what do I do about the case where 2λ<w? I don't even know where to start there :(
Thanks so much for your help! I really appreciate it

4. Nov 28, 2012

### Mute

First, I should point out that the range for w is not 0 to $2\lambda$. If $W = |X-\lambda|$, what is the maximum possible value of that if $X \in [0,\infty)$? I think you were maybe trying to find where the kink in the pdf will be and made a typo; the kink is not at $2\lambda$.

The reason I put the Heaviside step function in explicitly is that the integral would otherwise look like

$$\int_{\lambda-w}^{\lambda+w}dx~\lambda e^{-\lambda x},$$
and because x must be greater than zero you'll have to split that up into a few different cases depending on the value of w.

However, if we put the step function in the definition of the integral, then when we apply the Leibniz rule we are basically setting $x = \lambda+w$ in the first term and $x = \lambda - w$ in second term, so the Heaviside step function will help us keep track of the allowed regions of w. This way keeps track of the separate cases for the different regions of w for you, although you can do it by splitting it up into cases if that's easier for you. I find the step functions generally help me.

However, if you do it with the step functions, I did forget that because your allowed range for w is w > 0, you will need to restrict w to that range by adding an additional overall $\Theta(w)$ that doesn't come from the $\Theta(x)$ in the integral as I wrote it. I'm afraid this isn't clearing things up for you at the moment, so perhaps try it again your way (show us your steps, please), and once you've found the solution perhaps I can show you how I did it.

Last edited: Nov 28, 2012
5. Nov 29, 2012

### SallyY

Hey, think I finished up here!
I know its not the fastest way, but I stuck with what i knew how to do and actually made the CDF before finding the PDF.
I found there to be three cases: w<0, 0<w<λ and λ<w. The first is trivially 0, the second one i integrated over (-w-λ to w-λ) and the third i integrated over (0 to w-λ), since X will always take on a positive value and λ<w. After that it was just fairly straight-forward integration/derivation, the CDF approached one as w->infinity and when I fixed a value for λ the ∫[my pdf] from 0 to infinity equaled one as well :) Thanks for your help!

6. Nov 29, 2012

### Ray Vickson

That is correct. Generally I would recommend your method whenever you have non-smooth functions such as | | involved, but that's just me: I like to go back to basics.

RGV

7. Nov 29, 2012

### Mute

Do you want to share your answer with us so we can double check it against what we got?

In this case, working with the Heaviside functions turns out to be somewhat cumbersome and it's easier to split the integral up into cases. Sorry for suggesting the Heaviside method.

However, I do advise you to learn to use the Liebniz rule rather than actually performing the integrals in the future. Suppose that in this problem X had been drawn from a half-normal distribution instead of exponential,

$$\rho_X(x) = \frac{\lambda}{\sqrt{\pi}}\exp(-\lambda^2 x^2/2)~\mbox{for}~x\in[0,\infty).$$

This doesn't have an elementary anti-derivative, so you can't actually perform the integrals, and you would have to use the Liebniz rule to differentiate the integrals to get the pdf for w. (If you were to try to use WolframAlpha or mathematica to evaluate the integrals, it may give you a result in terms of "error functions", but the error functions are defined as certain integrals over Gaussians, so to understand the derivative of the error function you need to understand differentiating with respect to integral limits).

8. Nov 29, 2012

### Ray Vickson

Re "..I do advise you to learn to use the Liebniz rule ..": I agree completely. What I was referring to was the virtue of first expressing P{W <= w} in terms of an integral (or several integrals in some cases, for different w-ranges) and then somehow dealing with those to get the density, and Leibnitz will certainly be an important tool in this regard. What I really meant was that I prefer to avoid canned formulas for f_W(w) in terms of Jacobians, etc., when we have absolute value functions involved.

9. Nov 29, 2012

### Aria1

I'm actually not clear on where your bounds are coming from here...I see that when w=λ, 0<x<2λ, so I agree with setting your three cases to w<0, 0<w<λ, and λ<w. However, I'm at a bit of a loss as to where your other bounds for the second and third cases came from. Can someone explain that to me please?

10. Nov 29, 2012

### Aria1

Just to clarify where my confusion is: I integrated from (-w+λ) to (w+λ) for 0<w<λ, and from 0 to (w+λ) for λ<w. The only difference in answer is that for interval 0<w<λ, my cdf was [e^(-λ^2)][e^(λw)-e^(-λw)] and for Sally's bounds, the e^(-λ^2) at the beginning was e^(λ^2).
Similarly, for λ<w, my cdf was 1-e^(-λw-λ^2), and Sally's was 1-e^(-λw+λ^2). As w=>∞, cdf also approaches 1, so I'm not sure what the difference is/why one is incorrect. Any insight?

11. Nov 29, 2012

### Mute

That looks right.

It looks like Sally (hopefully) made a typo in her post. The x integration should be from $\lambda-w$ to $\lambda+w$ for $0 < w < \lambda$ and 0 to $w+\lambda$ when $\lambda < w$, giving the cdfs you have written.