The expected value of a function of multiple random variables can be approximated by a Taylor expansion. How this can be done in MMA is described in other posts (Link1, Link2).
Let's assume we have a function of 3 iid normal variables
$f=\sqrt{(x_1-x_2)^4+x_3^4}$ with $x_i\sim\mathcal{N}(\mu_i,\sigma^2)$ and are looking for the expectation $\mathbb{E}[f]$.
The MMA code for a Taylor expansion of order 2 applying the cited descriptions would look like this:
f = Sqrt[(x[1] - x[2])^4 + x[3]^4]; (*our function*)
f = f /. x[i_] -> (z[i] - \[Mu][i]) t + \[Mu][i]; (*introduce dummy variable t*)
taylor = (Series[f, {t, 0, 2}] // Normal) /. t -> 1 // Expand;
mean = taylor //. z[i_]^2 -> \[Sigma]^2 + \[Mu][i]^2;
mean = FullSimplify[mean //. z[i_] -> \[Mu][i]] (*output of 2nd order Taylor approximation*)
What is the reason to make the replacement in the form $z_i^2\to\sigma^2+\mu_i^2$ in the second last line, why is there an addition?
TransformedDistributionhelp here? – MarcoB Jan 11 '21 at 20:29(*function must be 1d*) deltaApprox[f_, dist_] := Module[{moment, getDelta}, moment[b_] := CentralMoment[dist, b]; getDelta[g_, mu_] := ((Table[D[g[x], {x, b}]/Factorial[b], {b, 0, 4}] /. x -> (x + mu))) . Table[moment[b], {b, 0, 4}]; getDelta[f, Mean@dist] ]– Xminer Nov 13 '23 at 09:30