Closed form expression for expectation of piecewise maximum Suppose $Z$ is a random variable, Gaussian, with mean $0$ and variance $\sigma$. We are given some constant scalars $a_1,...,a_d$ and $b_1,...,b_d$.
Is there a closed-form expression for this term (expectation over $Z$)?
$$
\mathbb E_Z\left[\max_{i=1,...,d} (a_i \,Z+b_i)\right]
$$
Any hint + a reference would be much appreciated!
 A: WLOG, relabel the index of the pair $(a_i, b_i)$ such that $a_1 < a_2 < \ldots < a_d$
The above inequality is strict; Suppose $a_i = a_j$ and $b_i \geq b_j$, then
$$ a_iZ + b_i \geq a_jZ + b_j$$
surely, so the pair $(a_j, b_j)$ is being dominated and we simply discard it.
The pair $(a_i, b_i)$ is the maximizer if and only if for any $j \neq i, j \in \{1, 2, \ldots, d\}$
$$ a_iZ + b_i \geq a_jZ + b_j \iff (a_i - a_j)Z \geq b_j - b_i$$
which is equivalent to
$$ \begin{cases}
\displaystyle Z \geq \frac {b_j - b_i} {a_i - a_j} & \text{for} & j \in \{ 1, 2, \ldots, i-1\}\\
\displaystyle Z \leq \frac {b_j - b_i} {a_i - a_j} & \text{for} & j \in \{i+1, i+2, \ldots, d\}
\end{cases}$$
So we may set
$$ \underline{z}_i \triangleq \begin{cases} 
\displaystyle \max_{j\in\{1,\ldots,i-1\}} \frac {b_j - b_i} {a_i - a_j} & \text{for} & i \in {2, 3, \ldots, d} \\
\displaystyle -\infty & \text{for} & i = 1\end{cases} $$
$$ \overline{z}_i \triangleq \begin{cases} 
\displaystyle \min_{j\in\{i+1,\ldots,d\}} \frac {b_j - b_i} {a_i - a_j} & \text{for} & i \in {1, 2, \ldots, d-1} \\
\displaystyle +\infty & \text{for} & i = d\end{cases} $$
Note that the above inequality can be expressed more compactly as
$$ Z \geq \underline{z}_i \text{ and } Z \leq \overline{z}_i $$
Note that the inequality may have no solution when $\underline{z}_i > \overline{z}_i$, and in such case the pair $(a_i, b_i)$ is impossible to be the maximizer. Let
$$ \mathcal{Z}_i \triangleq \begin{cases} [\underline{z}_i, \overline{z}_i] & \text{if } \overline{z}_i > \underline{z}_i \\
\varnothing & \text{otherwise} \end{cases}$$
such that $(a_i, b_i)$ is the maximizer if and only if $Z \in \mathcal{Z}_i$
Denote $(a^*, b^*)$ be the maximizer. Similarly we can conclude that the probability of the pair $(a_i, b_i)$ is the maximizer is
$$ p_i \triangleq \Pr\{(a_i, b_i) = (a^*, b^*)\} = \begin{cases} F_Z(\overline{z}_i) - F_Z(\underline{z}_i) & \text{if } \overline{z}_i > \underline{z}_i \\
0  & \text{otherwise} \end{cases}$$
where $F_Z$ is the CDF of $Z$.
Finally,
$$ \begin{align} E\left[\max_{i\in\{1,\ldots,d\}} (a_iZ + b_i)\right]
&= E[a^*Z + b^*] \\
&= E[a^*Z] + E[b^*] \\
&= \sum_{i=1}^d a_i\int_{\mathcal{Z}_i}zf_Z(z)dz+b_ip_i
\end{align}$$
The above calculation assumed that $Z$ is continuous and have a finite expectation. 
For a particular case where $Z \sim \mathcal{N}(0, \sigma^2)$, whereever $\mathcal{Z}_i$ is non-empty,
$$ F_Z(\overline{z}_i) - F_Z(\underline{z}_i) = \Phi\left(\frac{\overline{z}_i} {\sigma}\right) - \Phi\left(\frac{\underline{z}_i} {\sigma}\right) $$
where $\Phi$ is the standard normal CDF, and
$$ \int_{\mathcal{Z}_i}zf_Z(z)dz = \sigma[\phi(\underline{z}_i) - \phi(\overline{z}_i)] $$
where $\phi$ is the standard normal pdf. And that is the simplification you can do to the above expression.
P.S. We can further interpret the calculation here geometrically. If we put $Z$ in the horizontal axis, then $a_iZ + b_i$ represent a straight line in the plane, where $a_i$ is the slope. 
Here is an illustration with $d = 3$:

Here we see that all $\mathcal{Z}_i$ are non-empty interval, forming a partition of the real line. The region is determine by which line is the highest in that region. Note that we have rearrange the slope $a_i$, so the set must be from left to right. 

Sometimes the $b_i$ of the middle one is too small, in such case it will be dominated, and never be the maximizer. So the corresponding set is empty.
Hope this illustration help.
