# What's the expression for convolution of a uniform[a,b] density and a normal(0,d^2) density?

Suppose I have $$X\sim Uniform[a,b]$$ and $$Y\sim normal(0,d^2)$$, what's the expression for the density of $$Z=X+Y$$?

Let $$F_{Z}(z)$$ be the cdf of $$Z$$ evaluated at $$z$$, and let $$\Phi(\cdot)$$ and $$\phi$$ be standard normal cdf and pdf respectively. I got

$$F_{Z}(z)=\frac{1}{b-a}\int_{a}^{b}\Phi(\frac{z-x}{d})dx$$,

differentiate wrt to $$z$$ on both sides gives

$$f_{Z}(z)=\frac{1}{b-a}\int_{a}^{b}\phi(\frac{z-x}{d})\frac{1}{d}dx=\frac{1}{b-a}(\Phi(\frac{z-a}{d})-\Phi(\frac{z-b}{d}))$$ .

Does this look correct?Thanks!

– Dave
Aug 16, 2020 at 21:59
• @Dave Thanks, it's done! Aug 16, 2020 at 22:50
• I see two mistakes. 1) You don’t seem to be using the uniform $X$. 2) You solve this kind of problem using convolution. 3) Please add the self-study tag.
– Dave
Aug 16, 2020 at 23:03
• The left side of your last displayed equation is a function of $z$ while the right side does not depend on $z$ at all. Aug 17, 2020 at 1:14
• Some posts on site address the convolution of uniform and normal. Aug 17, 2020 at 1:42

Comment:

As a reality check here is a simulation for the convolution of $$U \sim \mathsf{Unif}(a=2, b=7)$$ and $$Z \sim \mathsf{Norm}(\mu = 0, \sigma = 3).$$

Thus $$E(U+Z) = 4.5 + 0 = 4.5$$ and $$V(U+Z) = 25/12 +9 = 4.0833.$$

set.seed(2020)
a = 2;  b = 7;  sg = 3
u = runif(10^6, a, b)
z = rnorm(10^6, 0, sg)
x = u + z
mean(x); mean(u);  mean(z);  mean(u) + mean(z)
[1] 4.497167        # aprx E(X) = 4.5
[1] 4.500343        # aprx E(U) = 4.5
[1] -0.003175144    # aprx E(Z) = 0
[1] 4.497167
var(x); var(u); 25/12; var(z); var(u) + var(u)
[1] 11.08561        # aprx Var(X)
[1] 2.081356        # aprx Var(U) = 25/12
[1] 2.083333        # 25/12
[1] 9.011073
[1] 4.162712

hist(x, prob=T, br=50, col="skyblue2",
main="Simulated Density of X")
curve(1/(b-a)*( pnorm((x-a)/sg) - pnorm((x-b)/sg) ),