# Optimizing Equation involving CDF and PDF

Assume you have two random variables, $$v_b \sim N(\mu_b,\sigma_b^2)$$ and $$v_s \sim N(\mu_s,\sigma_s^2)$$ and let $$\rho$$ be the correlation between them. Denote by $$F$$ and $$f$$ the CDF and PDF of the variables respectively, and assume I have the following optimization problem: $$\max_{\pi}F_{v_s}(\pi)(\mu_b-\pi)-\rho\sigma_b\sigma_sf_{v_s}(\pi)$$ where $$\pi$$ is the variable of interest. I am stuck on the approach - first, the second order conditions are of ambiguous sign. I'm also not convinced there exists a closed-form expression for $$\pi$$ after trying for several hours to solve it. How would I go about approximating solutions numerically? Can this even be done?

• I would ask this question as: Consider a random variable $Y \sim N(\nu,\tau^2)$ with CDF $F$ and PDF $f$. Let $\mu$ and $c$ be other real numbers, which can be thought of as the mean of another normal variable $X$, and its covariance with $Y$. How can one maximize $$\max_z[(\mu-z)F(z)-c f(z)]?$$There are indeed no closed-form solutions, but from this presentation it should be easier to apply standard numerical techniques.
– user225256
Commented Nov 19, 2020 at 2:07

If getting more familiar with the (numeric rather than exact) solutions is the objective, then looking at some dynamic graphics would be helpful. This can certainly be done in R and Mathematica (and probably several other languages). Consider the following Mathematica code for looking at where the maximum occurs and the shape of the function being maximized:

Manipulate[sol = Quiet[FindMaximum[g[zz, \[Mu]b, \[Sigma]b, \[Mu]s, \[Sigma]s, \[Rho]], {{zz, zz0}}]];
Show[Plot[g[z, \[Mu]b, \[Sigma]b, \[Mu]s, \[Sigma]s, \[Rho]], {z, -10, 10},
PlotRange -> All, PlotLabel -> "z = " <> ToString[zz /. sol[[2]]] <> ", Max = " <>   ToString[sol[[1]]]],
ListPlot[{{zz /. sol[[2]], 0}, {zz /. sol[[2]], sol[[1]]}}, Joined -> True, PlotStyle -> Red]],
{{\[Mu]b, 7}, -10, 10, Appearance -> "Labeled"},
{{\[Sigma]b, 6}, 0.001, 10, Appearance -> "Labeled"},
{{\[Mu]s, 0}, -10, 10, Appearance -> "Labeled"},
{{\[Sigma]s, 1}, 0.001, 10, Appearance -> "Labeled"},
{{\[Rho], 0}, -1, 1, Appearance -> "Labeled"},
{{zz0, 0, "Starting value"}, -10, 10, Appearance -> "Labeled"},
TrackedSymbols :> {\[Mu]b, \[Sigma]b, \[Mu]s, \[Sigma]s, \[Rho], zz0},
Initialization :> (g[z_?NumericQ, \[Mu]b_?NumericQ, \[Sigma]b_?NumericQ, \[Mu]s_?NumericQ, \[Sigma]s_?NumericQ, \[Rho]_?NumericQ] :=
CDF[NormalDistribution[\[Mu]s, \[Sigma]s], z] (\[Mu]b - z) - \[Rho] \[Sigma]b \[Sigma]s PDF[NormalDistribution[\[Mu]s, \[Sigma]s], z])]


• Thank you, this is amazing Commented Nov 20, 2020 at 0:05