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.
I want to find the cdf and variance of $Z$, where:
$$ Z = \begin{cases}W + X_1 & \text{if } W \leq c \\ W + X_2 & \text{if } W > c \end{cases}$$
I know from a previous question (see statsSE) that the pdf of $Z$ is:
$\frac{\frac{e^{-\frac{\left(\mu _0+\mu _1-z\right){}^2}{2 \left(\sigma _0^2+\sigma _1^2\right)}} \left(\text{erf}\left(\frac{\sigma _1^2 \left(g-\mu _0\right)+\sigma _0^2 \left(g+\mu _1-z\right)}{\sqrt{2} \sigma _0 \sigma _1 \sqrt{\sigma _0^2+\sigma _1^2}}\right)+1\right)}{\sqrt{\sigma _0^2+\sigma _1^2}}-\frac{e^{-\frac{\left(\mu _0+\mu _2-z\right){}^2}{2 \left(\sigma _0^2+\sigma _2^2\right)}} \left(\text{erf}\left(\frac{\sigma _2^2 \left(g-\mu _0\right)+\sigma _0^2 \left(g+\mu _2-z\right)}{\sqrt{2} \sigma _0 \sigma _2 \sqrt{\sigma _0^2+\sigma _2^2}}\right)-1\right)}{\sqrt{\sigma _0^2+\sigma _2^2}}}{2 \sqrt{2 \pi }}$
My code is as follows:
hsol = (((1/
Sqrt[Subscript[σ, 0]^2 +
Subscript[σ,
1]^2]) (Exp[(-(-z + Subscript[μ, 0] +
Subscript[μ, 1])^2)/(2*(Subscript[σ, 0]^2 +
Subscript[σ, 1]^2))]*(1 +
Erf[((g - z + Subscript[μ, 1])*
Subscript[σ, 0]^2 + (g -
Subscript[μ, 0]) Subscript[σ,
1]^2)/(Sqrt[2]*Subscript[σ, 0]*
Subscript[σ, 1]*
Sqrt[Subscript[σ, 0]^2 +
Subscript[σ, 1]^2])]))) - ((1/
Sqrt[Subscript[σ, 0]^2 +
Subscript[σ,
2]^2]) (Exp[(-(-z + Subscript[μ, 0] +
Subscript[μ, 2])^2)/(2*(Subscript[σ, 0]^2 +
Subscript[σ, 2]^2))]*(-1 +
Erf[((g - z + Subscript[μ, 2])*
Subscript[σ, 0]^2 + (g -
Subscript[μ, 0]) Subscript[σ,
2]^2)/(Sqrt[2]*Subscript[σ, 0]*
Subscript[σ, 2]*
Sqrt[Subscript[σ, 0]^2 +
Subscript[σ, 2]^2])]))))/(2 Sqrt[2 Pi]);
domain[hsol] = {z, -Infinity, Infinity};
Prob[hsol]
Var[z, hsol]
But after some time mathematica (using the mathStatica package) returns an expression containing an integral or stops calculating. I assume it is too difficult to calculate these expressions. Is there anyway make to circumvent this behaviour?