# Expected value of normally distributed random variable with "reroll"

I am trying to model the following random variable $$Z$$:

Values get drawn from a normally-distributed random variable $$X$$ with mean 0 and variance $$\sigma^2$$. If the drawn value is outside the interval $$[a,b]$$, a value is drawn instead from a uniformly-distributed random variable $$Y$$ on the same interval.

I think the probability density function of $$Z$$ can be expressed as $$f(x) = \begin{cases} \phi_\sigma(x) + \left( 1-\Phi_{\sigma}(x) \right) \frac{1}{b-a} & \text{for x \in [a,b]} \\ 0 & \text{otherwise} \end{cases}$$ where $$\phi_\sigma$$ and $$\Phi_\sigma$$ are the probability and cumulative density functions of the normal distribution, resp.

I am trying to determine the expected value of this random variable. What I have so far is:

$$\mathbb{E}(Z)= \int{xf(x)dx}\\ =\int{x\phi_\sigma(x)}dx+\int{x\frac{1-\Phi_{\sigma}(x)}{b-a}}dx \\ =\mathbb{E}(X)+\int{x\frac{1-\Phi_{\sigma}(x)}{b-a}}dx \\ =\mathbb{E}(X)+\mathbb{E}(Y)-\int{x\frac{\Phi_\sigma(x)}{b-a}}dx \\$$

where $$X\sim \mathcal{N}(0,\sigma^2)$$ is the normally distributed random variable with $$\mu=0$$ and variance $$\sigma^2$$, and $$Y \sim \mathcal{U}(a,b)$$ is the uniformly distributed random variable on the interval $$[a,b]$$.

I need a closed form solution in terms of $$\sigma$$, $$a$$ and $$b$$ so I can compute it efficiently, but I have no idea how to integrate that last term.

• I don't think your PDF is correct: assume that $a$ is very big and $b = a + 1$, then both terms of your PDF are very small on $[a, b]$. Unless I made a mistake, correct PDF is $\phi(x) + \frac{1 + \Phi(a) - \Phi(b)}{b - a}$. But I doubt there is closed form in elementary functions even for expectation. Commented Feb 29 at 15:54
• I think you're right! Well that makes things massively easier, because then $\mathbb{E}(Z)$ just becomes $\mathbb{E}(X) + (1+\Phi(a)-\Phi(b)) \mathbb{E}(Y)$, which can easily be expressed in closed form. Thanky you @mihaild! Commented Mar 3 at 15:03

It is easier to avoid mistakes if you try to find the CDF first. Let $$X$$ be the standard normal, let $$Y$$ be the uniform variable, and then let $$Z=\begin{cases} X & X \in [a,b] \\ Y & \text{otherwise} \end{cases}$$. So You have
$$P(Z \leq z)=P(Z \leq z \mid X \in [a,b]) P(X \in [a,b]) + P(Z \leq z \mid X \not \in [a,b]) P(X \not \in [a,b]) \\ = P(X \leq z \mid X \in [a,b]) P(X \in [a,b]) + P(Y \leq z \mid X \not \in [a,b]) P(X \not \in [a,b]) \\ = P(X \in [a,b] \cap (-\infty,z]) + P(Y \leq z) P(X \not \in [a,b]).$$
You can express those in terms of $$\Phi$$. Then you can differentiate that to get the density.