# Probability evaluation fails with equals condition

The following evaluation fails (the result is just the copy of the input) $$\text{Probability}[0<x\leq a | x-y=t,\{x\ {ExponentialDistribution}[\lambda ],y\ {ExponentialDistribution}[\lambda ]\}]$$

At the same time, the very exact expression evaluates correctly if I replace == with < $$\text{Probability}[0<x\leq a | x-y<t,\{x\ {ExponentialDistribution}[\lambda ],y\ {ExponentialDistribution}[\lambda ]\}]$$

Input:

Probability[0 < x <= a \[Conditioned] (x - y == t), {x \[Distributed]
ExponentialDistribution[\[Lambda]],
y \[Distributed] ExponentialDistribution[\[Lambda]]}]


Thank you!

The event $x - y = t$ has probability 0. Mathematica is not smart enough to figure out how to compute the conditional probability you are after.

Here is, however, a way in which you can get your desired CDF quite easily.

Transform you problem from $\mathbb{P}[0 < x \le a]$ to $\mathbb{E}[\mathbb{1}_{0 < x \le a}\delta(x - y - t)]$ where $\delta(x)$ is the Dirac delta.

If you can evaluate the expectation, you will get the unnormalized density and you will just need to compute the normalization constant. Let us look at how that works:

f = Expectation[
Boole[0 < x <= b] DiracDelta[x - y - t], {x \[Distributed]
ExponentialDistribution[\[Lambda]],
y \[Distributed] ExponentialDistribution[\[Lambda]]}];
Integrate[
D[f, b]/Integrate[D[f, b], {b, -Infinity, Infinity},
Assumptions -> \[Lambda] > 0] // FullSimplify, {b, 0, a},
Assumptions -> a > 0]


The last command gives the CDF you are after. Of course, $\lambda$ is assumed real and positive. You can plot the CDF to convince yourself that it is right, and you can differentiate it to obtain the density.

Edit

If this is a homework assignment, the solution I suggested may not be something you would want to report. Instead, a more traditional approach is preferable. You can, for example, do a change of variable $z = x - y$. Then you can write the joint density $p_{\mathsf x,\mathsf z}(x, z)$ $$p_{\mathsf x,\mathsf z}(x, z) = \begin{cases} \frac{e^{\frac{z-2 x}{\lambda }}}{\lambda ^2} & x\geq z \\ 0 & \text{o.w.} \\ \end{cases}$$

Now you can obtain the conditional density $p_{\mathsf x,\mathsf z}(x, z)$ as follows:

$$p_{\mathsf x|\mathsf z}(x| z) = \frac{p_{\mathsf x,\mathsf z}(x, z)}{\int_{-\infty}^\infty p_{\mathsf x,\mathsf z}(x, z)\mathrm d x} = \begin{cases}\frac{2 e^{-\frac{2 (x-z)}{\lambda }}}{\lambda } & x \ge z \ge 0\\ 0 & \mathrm{o.w.} \end{cases}$$

Now, your desired result is $\int_0^a p_{\mathsf x|\mathsf z}(x| z)\mathrm d x$.

All of the steps of the second derivation are easy by hand and trivial with Mathematica.

Note that the second solution is parametrized differently from the first one, where the value of $\lambda$ should be equal to the first example's $\lambda^{-1}$