# Sum of a Normal and a Truncated Normal distribution

I have normal distribution $N(\mu_1, \sigma_1)$ which shows the amount of demand in warehouse 1. The current amount of stock in the warehouse 1 is C. If the random demand is greater than C, it cannot satisfy the demand and the remainder of the demand will be send to warehouse 2.

The other warehouse also has another normal amount of demand, say $N(\mu_2, \sigma_2)$. I want to know that what is the probability distribution of the demand on the warehouse 2? Or in another word, Is there any closed form for sum of a normal distribution and a truncated normal distribution ?

The following figure shows two normal distribution and constant C=10 and demand on the warehouse 1 is $N(10, 1)$ and on warehouse 2 is $N(14, 1)$.

Thanks a lot for your complete explanation. I tried to perform a same procedure as you in Mathematica. However I do not have the mathStatica toolbox, I did the step as their definition in the Mathematica. In the step that you obtain the Marginal distribution, I used an integral on $\{v,-\infty, \infty\}$. The result is different. I sent the result in the following answer to the question. Can you please guide me what is the problem in my steps?

The following figure shows the step that I mentioned.

This is a very nice question (if I understand it correctly). It is also rather more complicated than it might at first appear. If I may paraphrase the question ...

The Question

A company operates in two areas:

• Area 1: Washington: In Area 1, the demand for widgets is: $$X_1 \sim N(\mu_1, \sigma_1^2)$$ with pdf $$f_1(x_1)$$

• Area 2: New York: In Area 2, the demand for widgets is: $$X_2 \sim N(\mu_2, \sigma_2^2)$$ with pdf $$f_2(x_2)$$

where $$X_1$$ and $$X_2$$ are independent random variables.

Each area has its own warehouse. The Washington warehouse has a stock (supply) of $$c$$ units. If $$X_1>c$$, the excess demand (unfulfilled orders) for widgets in Area 1 is referred to the New York warehouse for fulfilment.

Let $$Z$$ denote the total demand for widgets at the New York warehouse. Find the pdf of $$Z$$.

i.e. Find the pdf of:

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

Solution

To solve, we will need:

1. $$h_{\text{Lo}}(z) = \text{ pdf of } X_2 \big| \, (X_1 \leq c) \quad = \quad f_2(z) \quad$$ (by independence)

2. $$h_{\text{Hi}}(z) = \text{ pdf of } (X_2 + X_1-c) \, \big| \, (X_1 > c) \quad$$ (i.e. Normal + truncated-below Normal)

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

$$h(z) \, = \, P(X_1 \leq c) * h_{\text{Lo}}(z) \quad + \quad P(X_1>c) * h_{\text{Hi}}(z)$$

To assist the more tedious parts of the derivation, I will use a computer algebra system (the mathStatica package for Mathematica) to help simplify the steps required.

Solution: Part 1: $$h_{\text{Lo}}(z)$$

The pdf $$h_{\text{Lo}}(z)$$ is simply the pdf of $$Z = X_2$$:

Solution: Part 2: $$h_{\text{Hi}}(z)$$

The pdf of the sum of a Normal and a truncated-below Normal:

$$h_{\text{Hi}}(z) = \text{ pdf of } (X_2 + X_1-c) \, \big| \, (X_1 > c) \quad$$

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

... or explicitly:

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

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

We seek the marginal pdf of $$Z = X_2 + X_1 - c$$, i.e. $$h_{\text{Hi}}(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 $$X_1 \sim N(\mu_1, \sigma_1^2)$$ with pdf $$f_1(x_1)$$:

... then $$P(X_1 \leq c)$$ is:

Recall that the pdf of $$Z$$ is:

$$h(z) \, = \, P(X_1 \leq c) * h_{\text{Lo}}(z) \quad + \quad P(X_1>c) * h_{\text{Hi}}(z)$$

... which is explicitly:

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

Illustrative Plot

Here is a plot of the derived pdf when:

$$\text{params}=\left\{\mu _1\to 25,\mu _2\to 13,\sigma _1\to 3,\sigma _2\to 1,c\to 22\right\}$$

Monte Carlo check

It is always a good idea to check symbolic work using alternative methods, especially in a complicated derivation where it is easy to make a mistake. Here is a quick Monte Carlo check for the same parameter values as above:

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 different shaped outcomes.

Notes

1. The Transform, Marginal and Prob functions used above are from the mathStatica package for Mathematica. As disclosure, I should add that I am one of the authors.

2. The Erf function denotes the error function.

• Hi, Thanks a lot for your complete explanation. I tried to perform a same procedure as you in Mathematica. However I do not have the mathStatica toolbox, I did the step as their definition in the Mathematica. In the step that you obtain the Marginal distribution, I used an integral on {v,-\infty, \infty}. The result is different. I sent the result in the following answer to the question. Can you please guide me what is the problem in my steps? – Afshin Mar 16 '15 at 4:42