1
$\begingroup$

Suppose I have a probability distribution for random variable $X_1$ given by:

$$ P(x) = \begin{cases} 1/a, & \text{if} \;\; 0 \leq x \leq a\\ 0, & \text{otherwise} \end{cases} $$

and $X_2$ with probability distribution:

$$ P(x) = \begin{cases} 1/b, & \text{if} \;\; 0 \leq x \leq b\\ 0, & \text{otherwise} \end{cases} $$

What is the probability distribution function of $X_1 + X_2$.

$\endgroup$
  • 1
    $\begingroup$ Are you assuming independence? $\endgroup$ – Keen-ameteur Aug 21 '18 at 14:58
  • $\begingroup$ @Keen-ameteur In what sense $\endgroup$ – Truth-seek Aug 21 '18 at 15:00
  • 3
    $\begingroup$ That $X_1$ and $X_2$ are independent? $\endgroup$ – Keen-ameteur Aug 21 '18 at 15:01
  • $\begingroup$ I think it can be written as $$\frac{d}{dx}\int_0^b\int_0^{\min(x-x_2,\,a)}\frac{1}{ab}\,dx_1\,dx_2$$. You just need to evaluate the integrals. $\endgroup$ – BlackMath Aug 21 '18 at 15:07
  • $\begingroup$ @Keen-ameteur If you mean whether the selected value of $X_1$ affects the probability of $X_2$ or vice versa, then no. But, Isn't that clear from the fact that $P(X_1)$ is not a function of $X_2$ and vice versa? $\endgroup$ – Truth-seek Aug 22 '18 at 13:00
1
$\begingroup$

These are both uniform random variables if they independent we can write it like this. First $X_{1} \sim U(0,a)$ $X_{2} \sim U(0,b)$ . Also note the proof assumes that $ a \leq b$ The pdf of a uniform random variable $X \sim U(a,b)$ is given by

$$ f_{X}(x) =\begin{align}\begin{cases} \frac{1}{b-a} & \textrm{ for } x \in [a,b] \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align} \tag{1}$$

then the pdf of $X_{1}$ is given by

$$f_{X_{1}}(x_{1}) =\begin{align}\begin{cases} \frac{1}{a} & \textrm{ for } x \in [0,a] \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align}\tag{2}$$

so the pdf of $X_{2}$ is $$f_{X_{2}}(x_{2}) =\begin{align}\begin{cases} \frac{1}{b} & \textrm{ for } x \in [0,b] \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align} \tag{3}$$

Let the density $S = X_{1} + X_{2}$ be given by

$$ f_{S}(s) = \int_{\mathbb{R}} f_{X_{1}}(s-x_{2})f_{X_{2}}(x_{2}) dx_{2} \tag{4}$$

$$f_{X_{1}}(s-x_{2}) =\begin{align}\begin{cases} \frac{1}{a} & 0 \leq s-x_{2} \leq a \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align} \tag{5}$$ $$f_{X_{2}}(x_{2}) =\begin{align}\begin{cases} \frac{1}{b} & 0 \leq x_{2} \leq b \\ \\ 0 & \textrm{ for everywhere else } \end{cases} \end{align} \tag{6}$$

when $ 0 \leq x_{2} \leq a$

$$ f_{S}(s) = \int_{0}^{s} \frac{1}{ab} dx_{2} = \frac{x_{2}}{ab}\Big|_{0}^{s} = \frac{s}{ab} \tag{7}$$ when $ a \leq x_{2} < b $ $$ f_{S}(s) =\int_{s-a}^{s} \frac{1}{ab} dx_{2} = \frac{1}{ab}\Big|_{s-a}^{s} = \frac{s}{ab} - \frac{s-a}{ab}= \frac{1}{ab}(s-(s-a)) = \frac{a}{ab} =\frac{1}{b} \tag{8} $$

when $ b \leq x_{2} \leq a+b $

$$ f_{S}(s) = \int_{s-a}^{b} \frac{1}{ab} dx_{2} =\frac{1}{ab}\Big|_{s-a}^{b} = \frac{b}{ab} - \frac{s-a}{ab} = \frac{1}{a} - \frac{s-a}{ab} = \frac{1}{a} - \frac{s}{ab}+\frac{1}{b} \tag{9}$$

$$f_{S}(s) =\begin{align}\begin{cases} \frac{1}{ab}s & 0 \leq s < a \\ \\ \frac{1}{b} & a \leq s < b \\ \frac{1}{a} -\frac{s}{ab}+\frac{1}{b} &b\leq s < a+b \\ 0 & \textrm{ otherwise} \end{cases} \end{align} \tag{10}$$

In order to visualize this here is some code

import numpy as np
import matplotlib.pyplot as plt


def sum_uni(a,b,n):

    z1 = np.linspace(0,a,n)
    z2 = np.ones(n)   
    z3 = np.linspace(b,a+b,n) 

    f1 = (1/(a*b))*z1
    f2 = (1/b)*z2
    f3 = (1/a)*z2-(1/(a*b))*z3 +(1/b)*z2
    g1 = np.linspace(0,a,n)
    g2 = np.linspace(a,b,n)
    g3 = np.linspace(b,a+b,n)
    my_plot = np.concatenate((g1,g2,g3),axis=0)
    my_distribution = np.concatenate((f1,f2,f3),axis=0)

    return my_plot, my_distribution

my_plot, my_dist = sum_uni(2,3,100)

plt.plot(my_plot,my_dist)

enter image description here

$\endgroup$
  • $\begingroup$ I would have thought that the top of the support at the end should be $a+b$ rather than $ab-1$ $\endgroup$ – Henry Aug 22 '18 at 7:32
  • $\begingroup$ Youre right will fix $\endgroup$ – воитель Aug 22 '18 at 14:11
1
$\begingroup$

Here is a figure based on a simulation of a million realizations of $X = U_1 + U_2,$ where $U_1 \sim \mathsf{Unif}(0, a),\, U_2 \sim \mathsf{Unif}(0, b),$ independently, with $a = 1,\, b= 3.$

set.seed(9118);  m = 10^6;  a=1;  b=3
u1 = runif(m, 0, a);  u2 = runif(m, 0, b)
x = u1 + u2
hist(x, br=50, prob=T, col="skyblue2")
 curve(x/(a*b), 0, a, col="red", lwd=2, add=T)
 lines(c(a, b), c(1/b, 1/b), col="red", lwd=2)
 curve(1/a + 1/b - x/(a*b), b, a+b, col="red", lwd=2, add=T)

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.