I need to optimize an expected value of a maximum value for $q$. The problem has three variables, $q$ is a constant and $D_1$ and $D_2$ are stochastic variables with pdf $f(x)$ and cdf $F(x)$. The stochastic variables are i.i.d.
On Stackoverflow there are more problems like this but there $f(x)$ is known and mostly uniform, in my case this is not true.
To maximize I want to take the FOC, to do so I first rewrite the expected value as an integral. However, I saw that Im not able to take the derivative of the resulting integral.
$$ E[\max(q-D_1-D_2, 0)] = \int_0^\infty\int_0^\infty \max(q-x-y, 0)f(x)f(y)\,dx\,dy \\ = \int_0^q\int_0^{q-y} (q-x-y)f(x)f(y)\,dx\,dy\\ = \int_0^q\int_0^{q-y} qf(x)f(y)\,dx\,dy - \int_0^q\int_0^{q-y} xf(x)f(y)\,dx\,dy - \int_0^q\int_0^{q-y} yf(x)f(y)\,dx\,dy $$
How can I now get $\dfrac{\partial E[\max(q-D_1-D_2, 0)]}{\partial q}$?
Note, the derivative will never be zero since a higher $ q $ will lead to a higher expected value. However, in my real problem the function exist of several parts and only the part which is shown here gives difficulties for me.
Let $Z=q-Y-X$. Then, we are concerned with $E[max(Z,0)]$.
$P(max(Z,0) > c) $ is obviously $1$ if $c <0$. If $c \geq 0$, $P(max(Z,0) >c) = P(Z>c) = 1-F_Z(c)$. Thus, the cdf of $max(Z,0)$ is $F(c) = \left\{ \begin{array}{lr} 0, c <0 \\ F_z(c), c \geq 0 \end{array} \right.$.
Now, use the area rule for expectation (i.e. $E[X] = \int_0^\infty (1-F_X(x)) dx$ for non-negative r.v.'s $X$) to find $E[\max(Z,0)] = \int_0^\infty (1-F(c)) dc = \int_0^\infty (1-F_Z(c)) dc $.
You can easily calculate the CDF or PDF of $Z$ on your own. Note that the distribution of $\max(Z,0)$ is a point mass with probability $F_Z(0)$ at $0$ and density matching $Z$ for values greater than zero, and zero otherwise. So, if you have the density of $Z$, $E[\max(Z,0)]=\int_0^\infty z f(z) dz$ (since the mass at $0$ doesn't contribute anything to the expectation).