I have a function of bivariate normal PDF and its marginals defined as
f[x_] := PDF[NormalDistribution[0, 1], {x}]
f2[x_, y_] :=
PDF[MultinormalDistribution[{0, 0}, {{1, ρ}, {ρ, 1}}], {x, y}] /. {ρ -> 1/2}
The function fw
is quite complex so I solve it numerically using FindRoot
for given X0
and Y0
.
fw[X0_?NumericQ, Y0_?NumericQ] :=
Y /.
FindRoot[
Integrate[f2[X0, u], {u, -∞, Y0}]f[X0] == Integrate[f2[X0, u], {u, -∞, Y}],
{Y, Y0}]
I would like to calculate the expected value of the function fw
over the Gaussian curve but for a reason this doesn't work.
NIntegrate[fw[XD, YD] f2[XD, YD], {XD, -∞, ∞}, {YD, -∞, ∞}]
I suppose NIntegrate
is either too slow or it cannot supply numerical values to fw
. Do you have any ideas how to fix this?
Integrate[f2[X0, u], {u,-Infinity, Y0}]
yields an analytic answer, replace it by that answer inFindRoot
to save a lot of time. $\endgroup$