[Math] Probability that sum of two uniformly distributed random variables is less than some constant

calculusprobabilityuniform distribution

I am trying to find a way of determining the probability that the sum of two continuously uniformly distributed random variables is less than some constant $C$, formally:

Let $A \sim \mathcal{U}(0,a)$ and $B\sim\mathcal{U}(0, b)$ and $C \in \mathbb{N}$, how can we calculate: $$\mathbb{P}[A+B<C]$$

Now, my line of reasoning is as follows; we can find the cumulative probability that the first variable takes a value less than $C$ and multiply it by the cumulative probability that the second variable takes a value less than $C-x$, where $x$ is the value of the first variable.

This would give us an expression (if $C < a+b$):

$$\begin{align*}\mathbb{P}[A+B<C]&=\int_{0}^{C}\mathbb{P}[A=x]\mathbb{P}[0 \leq B < C-x]\:\mathrm{d}x \\
&= \int_{0}^{C}\frac{1}{a}\int_{0}^{C-x}\frac{1}{b}\:\mathrm{d}y\:\mathrm{d}x \\
&= \int_{0}^{C}\frac{C-x}{ab}\:\mathrm{d}x \\
&= \frac{C^{2}}{2ab}\end{align*}$$

So in general we should have:

$$\mathbb{P}[A+B<C]=\begin{cases}\frac{C^{2}}{2ab} & C < a+b \\ 1 & C \geq a+b \\ 0 & \text{otherwise}\end{cases}$$

However, in the case where $a = 1185$, $b=3968$, $C=3649$, I am told that $\mathbb{P}[A+B<C]=\frac{6113}{7936}$, however, applying the above formula gives us:

$$\mathbb{P}[A+B<C]=\frac{13315201}{9404160}$$

What is wrong with my approach?

Best Answer

You have to go through each case: $ \begin{cases} 1 & a+b<C \\ \frac{C^2}{2 a b} & (a\geq b\lor a\geq C)\land (a<b\lor b\geq C)\land C>0 \\ \frac{C-b}{a} & a+b=C \\ -\frac{a-2 C}{2 b} & a<b\land a<C\land b\geq C \\ -\frac{b-2 C}{2 a} & a>b\land b<C\land a\geq C \\ -\frac{a^2-2 a C+(b-C)^2}{2 a b} & a+b>C\land ((a<b\land b<C)\lor (a>b\land a<C)) \\ -\frac{2 b^2-4 b C+C^2}{2 a b} & a=b\land b<C\land a+b>C \end{cases} $

Related Question