# Truncated normal distribution over a union of intervals

Suppose I want to find a truncated normal distribution, but instead of its being defined on an interval $(a,b)$, where $-\infty<a<b<\infty$, its definition is on an interval $(a,b)\cup(c,d)$, where $-\infty<a<b<c<d<\infty$.

First of all, would this still satisfy the definition of a truncated normal distribution? The Wikipedia article on this just defines it using $(a,b)$, where $-\infty<a<b<\infty$ and $a<X<b$ (and X is normal with mean $\mu$ and variance $\sigma^{2}$). If it isn't a truncated normal distribution, then what is it?

If it is a truncated normal distribution, how would I compute it? I was thinking that I could approach it using the Law of Total Probability, but then I would just get the truncated distribution as 0.5 times the truncated normal distribution for each interval in the union, and this doesn't really make sense to me, because it means that instead of there being one value that X could take with maximum probability, there are two peaks in the distribution with equal probability (unless I am doing it wrong).

What you are describing is not truncated normal distribution per se, but its probability density function and cumulative distribution functions can be easily calculated the same way as in general we deal with truncated distributions, so you need to divide them by the leftover area under the curve i.e. by

$$\int_{ a < x \le b ~\cup ~ c < x \le d} f(x) dx \\ = [F(b)-F(a)] + [F(d)-F(c)]$$

where $f(x)$ is non-truncated density and $F(x)$ is non-truncated cdf. This can be generalized to any number of such intervals.

Density of such distribution is

$$g(x) = \begin{cases} \frac{f(x)}{F(b)-F(a) + F(d)-F(c)} & \text{for } a < x \le b ~\cup ~ c < x \le d \\ 0 & \text{otherwise} \end{cases}$$

To convince yourself, you can easily verify this result via simple simulation (see below).

set.seed(123)

m <- 0
s <- 1
a <- -2
b <- -1
c <- 1
d <- 2

x <- rnorm(1e5, m, s)
y <- x[(x > a & x <= b) | (x > c & x <= d)]

g <- function(x, mean = 0, sd = 1, a, b, c, d) {
ifelse((x > a & x <= b) | (x > c & x <= d),
dnorm(x, mean = mean, sd = sd) /
((pnorm(b, mean = mean, sd = sd) - pnorm(a, mean = mean, sd = sd)) +
(pnorm(d, mean = mean, sd = sd) - pnorm(c, mean = mean, sd = sd))),
0)
}

xx <- seq(-4, 4, by = 0.01)
hist(y, 100, xlim = c(-4, 4), freq = FALSE)
lines(xx, g(xx, m, s, a, b, c, d), col = "red")