Problem:
Suppose that $x_1$, $x_2$ and $x_3$ are independent uniformly distributed on the interval $[1,3]$. What is the probability that
$x_1 + x_2 + x_3 < 8$.
Answer:
Let $p$ be the probability we seek. The density for these three random variables is:
$$ f(x) = \begin{cases}
\frac{1}{2} & \text{for } 1 \leq x \leq 3 \\
0, & \text{otherwise }
\end{cases} $$
\begin{align*}
p &= \int_{1}^{3} \int_{1}^{5-x_1} \int_{1}^{8-x_1-x_2} \left( \frac{1}{2}\right)^3 \, dx_3 \, dx_2 \, dx_1 \\
p &= \int_{1}^{3} \int_{1}^{5-x_1} \frac{x_3}{8} \, \Big|_{x_3 = 1}^{x_3 = 8-x_1-x_2} \, dx_2 \, dx_1 \\
p &= \int_{1}^{3} \int_{1}^{5-x_1} \frac{8 - x_1 - x_2}{8} - \frac{1}{8} \, dx_2 dx_1 \\
p &= \int_{1}^{3} \int_{1}^{5-x_1} \frac{7 - x_1 - x_2}{8} \, dx_2 \, dx_1 \\
p &= \int_{1}^{3} \frac{7x_2 - x_1 x_2 - \frac{x_2^2}{2}}{8} \Big|_{1}^{5-x_1} \, dx_1 \\
p &= \int_{1}^{3} \frac{7(5-x_1) - x_1(5-x_1) - \frac{(5-x_1)^2}{2} }{8} - \frac{1}{8} \, dx_1 \\
p &= \int_{1}^{3} \frac{14(5-x_1) - 2x_1(5-x_1) - (5-x_1)^2 - 2 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ 70 - 14x_1 - 2x_1(5-x_1) - ( 25 - 10x_1 + x_1^2 ) - 2 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ 70 - 14x_1 - 2x_1(5-x_1) - 25 + 10x_1 - x_1^2 - 2 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ - 14x_1 - 2x_1(5-x_1) + 10x_1 - x_1^2 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ -4x_1 - 2x_1(5-x_1) - x_1^2 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ -4x_1 - 10x_1 + 2x_1^2 - x_1^2 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ x_1^2 - 14x_1 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ x_1^2 - 14x_1 }{16} \, dx_1 + (3-1)\left( \frac{43}{16} \right) \\
p &= \int_{1}^{3} \frac{ x_1^2 - 14x_1 }{16} \, dx_1 + \frac{43}{8} \\
p &= \left( \frac{1}{16 }\right) \int_{1}^{3} ( x_1^2 - 14x_1 ) \, dx_1 + \frac{43}{8} \\
\end{align*}
Using an online integral calculator, I find:
$$ \int_{1}^{3} ( x_1^2 - 14x_1 ) \, dx_1 = - \frac{142}{3} $$
\begin{align*}
p &= \left( \frac{1}{16 }\right) \left( - \frac{142}{3} \right) \,+ \frac{43}{8} \\
p &= -\frac{71}{3(8)} + \frac{43}{8} = \frac{139 - 71}{24}
\end{align*}
Since $p$ is greater than $1$, my answer cannot be right. Were did I go wrong?
I would also like to know if I setup the integral correctly.
I ran the following R script:
count = 0
limit = 10*1000*1000
for ( i in 1:limit ) {
num = sum( runif( 3, 1, 3 ) )
if ( num <= 8 )
count = count + 1
}
The result was around 0.979. Therefore, I question the answer of $\frac{7}{8}$.