# How to find the CDF of a random variable uniformly distributed around another random variable?

I'm working on some game theory models of incomplete information (which I've posted about a few times here). I think this question is pretty straightforward though, so the actual context is unimportant.

Suppose there is a random variable uniformly distributed between $b_l$ and $b_h$, i.e. $B \sim U(b_l, b_h)$. Someone draws $b$ from $B$, and then defines another random variable $X \sim U(b - \epsilon, b + \epsilon)$. You know $b_l, b_h, \epsilon$, and the distributions of $B$ and $X$, but you do not know $b$, the actual number drawn from the $B$ distribution.

What is the CDF of $X$? My intuition is that the mass goes from $b_l - \epsilon$ to $b_h + \epsilon$ and is triangular, with the peak at $P(X < \frac{b_l + b_h}{2}) = .5$, but I'm really not sure. Thanks in advance for any help!

Edit: $b_l, b_h$, and $\epsilon$ are all predefined and fixed.

• What's $\varepsilon$? Is it random? – Aksakal Feb 16 '16 at 22:06
• Sorry, updated the question to make this more clear: $b_l,b_h$, and $\epsilon$ are all predefined and fixed. – sundance Feb 16 '16 at 22:08
• In the answer at stats.stackexchange.com/a/43075 I develop a general formula for the sum of an arbitrary random variable and an independent uniform variate. In this case, letting $F$ be the CDF of $B$, the CDF of $X$ will be $F(x+\epsilon)-F(x-\epsilon)$. – whuber Feb 16 '16 at 23:06
• Can you explain the substantive differences from this question? It looks like you're asking the same thing to me (suggesting that perhaps they should be merged, or one closed as duplicate of the other) – Glen_b Feb 17 '16 at 2:05
• The questions are similar but not the same. This question is asking about how to find the CDF of a random variable that is itself distributed around a draw from a random variable. The question you linked to is essentially asking how to find the CDF of the difference of two uniform variables. While those may look similar once you know their answers, I don't think it's obvious a priori that they can be solved in similar ways. – sundance Feb 17 '16 at 8:03

First recall that $$f(X|X \in [b-\epsilon,b+\epsilon])= \frac{1}{b+\epsilon - (b-\epsilon) } =\frac{1}{2\epsilon}$$ and $$f(X) = f(X|X \in [b-\epsilon,b+\epsilon]) \times Pr(X \in [b-\epsilon,b+\epsilon])+ f(X|X \not\in [b-\epsilon,b+\epsilon]) \times Pr(X \not\in [b-\epsilon,b+\epsilon])$$ but since $f(X|X \not\in [b-\epsilon,b+\epsilon]) =0$ the above simplifies to

$$f(X) = f(X|X \in [b-\epsilon,b+\epsilon]) \times Pr(X \in [b-\epsilon,b+\epsilon])$$

Note $X \in [b-\epsilon,b+\epsilon] \equiv b \in [X-\epsilon,X+\epsilon]$ and that $$Pr(b \in [X-\epsilon,X+\epsilon]) = \int_{\max(b_l,X-\epsilon)}^{\min(b_h,X+\epsilon)}\frac{1}{b_h-b_l}db=\frac{\min(b_h,X+\epsilon)-\max(b_l,X-\epsilon)}{b_h-b_l}$$ Thus; $$f(X)=\frac{\min(b_h,X+\epsilon)-\max(b_l,X-\epsilon)}{2\epsilon(b_h-b_l)}$$

The above can be broken up into a piece-wise function differently depending on the values of $\epsilon,b_l,$ and $b_h$.

## Simulation in R

To validate this answer I also ran a simulation where $\epsilon=2,b_l=0,$ and $b_h=1$. This results in the following pdf $$f(X) = \begin{cases} \frac{X+\epsilon-b_l}{2\epsilon(b_h-b_l)} = \frac{X+2}{4}\;\;\mathrm{if}\;\;X \in [-2,-1)\\ \frac{b_h-b_l}{2\epsilon(b_h-b_l)} = \frac{1}{4}\;\;\mathrm{if}\;\;X \in [-1,2]\\ \frac{b_h+\epsilon-X}{2\epsilon(b_h-b_l)} = \frac{3-X}{4}\;\;\mathrm{if}\;\;X \in (2,3]\\ 0\;\;\;\;\mathrm{otherwise} \end{cases}$$ The trapezoidal shape of $f(X)$ is validated with simulation and a kernel density estimator which I plot below The code in R for the above plot is;

e=2
bl=0;
bh=1;
b=runif(1e5,bl,bh)
x=runif(1e5,min=b-e,max=b+e)
plot(density(x,from=-2,to=3),main="Density Estimate (KDE)",lwd=2)
abline(h=.25,col=2,lty=2,lwd=2)
abline(v=-1,col=4,lty=4,lwd=2)
abline(v=2,col=4,lty=4,lwd=2)


Your variable $X$ is simply a sum of two randoms $$x=b+e$$, where the randoms are from uniform distributions $b\sim U(b_l,b_h)$ and $e\sim U(-\varepsilon,\varepsilon)$

If $b_h-b_l=2\varepsilon$, then $X$ is from a triangular distribution. Otherwise, it'll be a trapezoidal distribution. It must very easy to come up with CDF.

UPDATE

Her's one way of calculating the CDF. Start with a PDF $f(x)$, which is easily defined as follows:

• $\frac{x-b_l+\varepsilon}{(b_h-b_l)2\varepsilon}$, when $x\in [b_l-\varepsilon,b_l+\varepsilon]$
• $\frac{1}{b_h-b_l}$, when $x\in [b_l+\varepsilon,b_h-\varepsilon]$
• $\frac{-x+b_h+\varepsilon}{(b_h-b_l)2\varepsilon}$, when $x\in [b_h-\varepsilon,b_h+\varepsilon]$

Obviously, these are when $2\varepsilon\le b_h-b_l$.

Now, to get the CDF simply take the integral $\int_{b_l-\varepsilon}^{b_h+\varepsilon}f(x)dx$, which is easy but too long for me to type

• Thanks for the response. Looking at it as the addition of those two variables makes sense. I don't know much about convolutions, and all of the examples that I've read only show how to compute the convolution of two U(0,1) variables. How can I solve for the CDF where the bounds of the two variables are defined but arbitrary, as in this example? – sundance Feb 16 '16 at 22:46
• @sundance, I added PDF, you should be able to pick from there – Aksakal Feb 17 '16 at 1:13