# Evaluate a nested Gaussian integral

I would like to evaluate the following integral. I suspect it just doesn't have an analytic form but thought I'd check to see if there's anything I'm missing,

$$\int_{-\infty}^{\infty} \mathcal{N}(z;\mu,\sigma) \int_{z-a}^{z+a} \mathcal{N}(x;\mu,\sigma) \mathrm{d}x \mathrm{d}z.$$

The reason for doing so is to determine $$Pr(|x-z| < a)$$ where (both independently drawn) $$x\sim \mathcal{N}(\mu,\sigma)$$ and $$z\sim \mathcal{N}(\mu,\sigma)$$.

I can determine the inner integral easy enough,

Integrate[PDF[NormalDistribution[mu, sigma], x], {x, z - a, z + a}]


which yields,

1/2 (Erf[(a + z - mu)/(Sqrt sigma)] + Erf[(a - z + mu)/(Sqrt sigma)])

Attempting to do the full integral using this intermediate expression results in returning unevaluated, however,

Integrate[1/2 (Erf[(a + z - mu)/(Sqrt sigma)] + Erf[(a - z + mu)/(Sqrt sigma)])
PDF[NormalDistribution[mu, sigma], z], {z, -\[Infinity], \[Infinity]}]


Anyone got any idea on tricks to perform this integral?

Failing that, does anyone have any ideas for how to approximate it?

Yes, I'm being stupid (no shock there!). There is a work around since things are Gaussian. If $$z\sim \mathcal{N}(\mu, \sigma)$$ and $$x\sim \mathcal{N}(\mu, \sigma)$$, then $$x-z \sim \mathcal{N}(0, \sqrt{2} \sigma)$$. Then the result follows easily,
$$Pr(|x-z|.
• Using Mathematica: dist = TransformedDistribution[x - z, { x \[Distributed] NormalDistribution[\[Mu], \[Sigma]], z \[Distributed] NormalDistribution[\[Mu], \[Sigma]]}] // Simplify[#, DistributionParameterAssumptions[ NormalDistribution[\[Mu], \[Sigma]]]] &; Probability[Abs[y] < a, y \[Distributed] dist] Jul 2, 2019 at 18:53