# Probability that sum of two uniformly distributed random variables is less than some constant

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?

• There are many conditions. For instance, if $a + b < C$, then $P = 1$. If $a < b \land a < C \land b > C$ then $P = (2C -a)/2b$. And so forth. Please state your conditions on $a$, $b$ and $C$. – David G. Stork Jan 27 '15 at 1:48
• @DavidG.Stork The only conditions I have are: $a,b,C\in\mathbb{N}$. Why would the relative ordering of $a$ and $b$ matter, as $a+b = b+a$? – Thomas Russell Jan 27 '15 at 1:50

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}$
• I see where the problem was, I was always assuming that $a \geq b \geq C$; thank you for pointing this out! – Thomas Russell Jan 27 '15 at 2:03