# Sum of truncated normal with two normal distributions

Suppose I have one normal distribution $W \sim N(\mu_{w},\sigma_{w}^2)$ with a known cuttoff point (percentile) on this distribution called $c$. The first part of $W \in [-\infty,c[$ needs to be convoluted with another normal distribution $X\sim N(\mu_{x},\sigma_{x}^2)$ and the second part of $W \in [c,\infty]$ needs to be convoluted with a Normal distribution $Y\sim N(\mu_{y},\sigma_{y}^2)$. What are the properties of the resulting distribution $Z$?

Is this somehow similar to the problem of the sum of a normal distribution and a truncated distribution described in http://www.jstor.org/stable/1266101?seq=2

Or is this equal to the sum of truncated normal distributions?

More specifically in my application $Z$ represents an arrival time distribution and $W$ represents a departure time distribution and $c$ the end of a timeslot. The arrival time for departures smaller than $c$ is the sum of $W$ and $X$ and the arrival time for departures bigger than $c$ is the sum of $W$ and $Y$.

I think this is a very nice problem. If I may change notation slightly ...

The Problem

Let $\quad W \sim N(\mu_0, \sigma_0^2), \quad X_1 \sim N(\mu_1, \sigma_1^2), \quad X_2 \sim N(\mu_2, \sigma_2^2)$

denote independent random variables, and let $c$ denote a constant.

Find the pdf of $Z$, where:

$$Z = \begin{cases}W + X_1 & \text{if } W \leq c \\ W + X_2 & \text{if } W > c \end{cases}$$

Solution

To solve this, we need to solve 2 problems.

1. Find $h_1(z)$: the pdf of $(W + X_1) \, \big| \, (W \leq c) \quad$ (i.e. truncated-above Normal + Normal)

2. Find $h_2(z)$: the pdf of $(W + X_2) \, \big| \, (W > c) \quad$ (i.e. truncated-below Normal + Normal)

Then the pdf of $Z$, say $h(z)$, is the component mix:

$$h(z) \, = \, P(W \leq c) * h_1(z) \quad + \quad P(W>c) * h_2(z)$$

Solution: Part 1

$\rightarrow$ The pdf of the sum of a truncated-above Normal and a Normal

If $W$ is truncated ABOVE at $c$, ... then the joint pdf of $(W \big|(W \leq c),X_1)$, say $f_1(w,x_1;c)$, is, by independence, simply the product of the respective individual pdf's ... that is, $f_1(w,x_1;c) = \frac{f_w(w)}{P(W<c)} * f_{x_1}(x_1)$:

Next, transform $(W,X_1) \rightarrow (Z=W+X_1, V=X_1)$. Here is the joint pdf of $(Z, V)$, say $g_1(z,v)$:

where:

• I am using the Transform function in the mathStatica package for Mathematica to do the nitty-gritties.

• Note that the transformation equation $(Z=W+X_1, V=X_1)$ induces dependency between $Z$ and $V$. In particular, since $Z=V+W$ and $W < c$, it follows that $Z < V + c$. This important constraint is entered using the Boole[ blah ] statement above.

• Erf[.] denotes the error function

We seek the marginal pdf of $Z = W + X_1$, say $h_1(z)$, which is:

... defined on the real line. This concludes Part 1.

Solution: Part 2

$\rightarrow$ The pdf of the sum of a truncated-below Normal and a Normal

If $W$ is truncated BELOW at $c$, ... then the joint pdf of $(W \big|(W > c),X_2)$, say $f_2(w,x_2;c)$, is, by independence, simply the product of the respective individual pdf's ... that is, $f_2(w,x_2;c) = \frac{f_w(w)}{P(W>c)} * f_{x_2}(x_2)$:

Next, transform $(W,X_2) \rightarrow (Z=W+X_2, V=X_2)$. Here is the joint pdf of $(Z, V)$, say $g_2(z,v)$:

• Note that the transformation equation $(Z=W+X_2, V=X_2)$ induces dependency between $Z$ and $V$. In particular, since $Z=V+W$ and $W > c$, it follows that $Z > V + c$. This important constraint is entered using the Boole[ blah ] statement above.

We seek the marginal pdf of $Z = W + X_2$, say $h_2(z)$, which is:

...defined on the real line. This concludes Part 2.

The Component Mix

All the necessary pieces to the puzzle are now in place. To make this explicit, if $W \sim N(\mu_0, \sigma_0^2)$ with pdf $f(w)$:

... then $P(W<c)$ is:

Recall that the pdf of $Z$ is:

$$h(z) \, = \, P(W \leq c) * h_1(z) \quad + \quad P(W>c) * h_2(z)$$

... which is explicitly:

where $Z$ is defined on the real line. All done.

Monte Carlo check

It is always a good idea to check symbolic work using alternative methods. Here is a quick Monte Carlo check when:

$\text{params}=\left\{\mu _0\to 16,\mu _1\to 3,\mu _2\to 2,\sigma _0\to 6,\sigma _1\to 0.1,\sigma _2\to 2,c\to 12\right\}$

The following plot compares:

• a Monte Carlo simulation of the pdf of $Z$ (squiggly BLUE curve) to the
• theoretical solution derived above (dashed RED curve)

Looks fine :) Different parameter choices can, of course, yield very different shaped outcomes.

Mean of $Z$

Paulius Šarka asks: "Does the mean of Z have an analytical form"

Yes - it is easiest to derive this from:

$$Z = \begin{cases}W + X_1 & \text{if } W \leq c \\ W + X_2 & \text{if } W >c\end{cases}$$

... it follows that:

$$E[Z] = P(W \leq c) \big(E[W \big | W \leq c] + \mu_1 \big) \quad + \quad P(W>c)\big(E[W \big | W > c] + \mu_2 \big)$$

which yields the closed-form solution:

$$E[Z] \quad = \quad \mu_0 \, + \, P(W \leq c) \mu_1 \, + \, P(W > c) \mu_2$$

• Nice! Does the mean of $Z$ have an analytical form (i.e. can Mathematica integrate that expression)? Oct 31, 2014 at 16:36
• Hi @PauliusŠarka Yes - the mean has a 'nice' closed-form -- see addendum above -- best derived from the defn of $Z$. Oct 31, 2014 at 17:59
• @wolfies Concerning the analytical form for the mean of $Z$, why is $E[W|W \leq c]$ equal to $E[W]=\mu_{0}$? Nov 19, 2014 at 14:05
• $E[W \big | W \leq c]$ is not equal to $E[W]$. The correct derivation is: $$blah = P(W \leq c) \big(E[W \big | W \leq c] \big) \quad + \quad P(W>c)\big(E[W \big | W > c] \big) = E[W] = \mu_0$$ IF this is not intuitive, more formally let $W$ have pdf $\phi(w)$. Then $$\phi(w \big| W \leq c) =\frac{\phi(w)}{P(W \leq c)} \text{and} E[W \big | W \leq c] = \int_{-\infty}^c w \frac{\phi(w)}{P(W \leq c)}dw$$ Similarly, $E[W \big | W >c] = \int_{c}^\infty w \frac{\phi(w)}{P(W > c)}dw$. So, $$blah = \int_{-\infty}^c w \phi(w) dw + \int_{c}^\infty w \phi(w)dw = E[W]$$ Nov 19, 2014 at 17:49