TITLE: conditional distribution of random variable given its sum with another random variable
QUESTION [6 upvotes]: I am trying to figure out the following problem:

I have two random variables: $X$ with pdf $f_X(x)$ on $[0,A]$ and $Y$ with pdf $g_Y(y)$ on $[0,B]$. Let's denote $Z=X+Y$. What should be the distribution of $X$, given $Z$?

Many thanks!

REPLY [6 votes]: Assuming $X$ and $Y$ are independent and continuous, find the joint probability density function for $X$ and $Z$, i.e. $f_{X,Z}(x,z)$.
The probability density function of the conditional random variable then reads:
$$
    f_{X|Z}\left(x\mid z\right) = \frac{f_{X,Z}(x,z)}{f_Z(z)}
$$
where $f_Z(z)$ is the marginal pdf of $Z$, which is obtained as $f_Z(z) = \int_0^A f_{X,Z}(x,z) \mathrm{d}x$.
To find $f_{X,Z}(x,z)$ simply change measure in an expectation of a bounded function:
$$
  \mathbb{E}\left(h(X,Z)\right) = \int_0^A \int_0^B h(x,x+y) f_X(x) g_Y(y) \mathrm{d}x \mathrm{d}y = \int_0^A \int_0^{A+B} h(x,z) f_{X,Z}(x,z) \mathrm{d}x \mathrm{d}z
$$
to find
$$
    f_{X,Z}(x,z) = f_X(x) g_Y(z-x) [ 0<x<A, x<z<B+x ]
$$
and therefore:
$$
    f_Z(z) = \int_{\max(0,z-B)}^{\min(z,A)} f_X(x) g_Y(z-x) \mathrm{d}x
$$