# Calculate a nested integral

I wish to plot the following probability on Mathematica: $$\pi=n\cdot\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}\left[\int_{-\infty}^{z_{1}}G\left(z-z_{2}\right)\cdot f\left(z_{2}\right)dz_{2}\right]^{n-1}g\left(z-z_{1}\right)f\left(z_{1}\right)dz_{1}dz$$ where $$n\geq2$$, $$F$$ and $$G$$ are the CDFs of independent random variables supported on $$\mathbb{R}$$ (with respective densities $$f$$ and $$g$$). You may notice that the integral is related to the convolution distribution but it's not exactly that. For example, I wish to compute the above integral where $$F$$ and $$G$$ are the NormalDistribution[0, σ1] and NormalDistribution[0, σ2] respectively. The issue is that due to the infinities the integrals do not converge in Mathematica, unless I express them in the form of some probabilities or expectations so that Mathematica calculate them symbolically. I would appreciate any help!

*** UPDATE *** Here is my code:

probabilityFunction[n_, F_, G_] :=
Module[{vLow = DistributionDomain[F][][],
vHigh = DistributionDomain[F][][],
zLow = DistributionDomain[G][][],
zHigh = DistributionDomain[G][][]},
NIntegrate[
n*(Integrate[CDF[G, z - z2]*PDF[F, z2], {z2, vLow + zLow, z1},
Assumptions -> z1 \[Element] Reals])^(n - 1)*PDF[G, z - z1]*
PDF[F, z1], {z1, vLow, vHigh}, {z, vLow + zLow, vHigh + zHigh}]
];


Tested with:

Module[{n = 4, F = UniformDistribution[{0, 2}], G = UniformDistribution[{1, 4}]},
probabilityFunction[n, F, G]
]


gives

0.0145365


But I can't test it with the Normal distribution as it is supported over $$(-\infty, +\infty)$$. Numerical simulation is indeed one way to go, but I believe it should be possible to evaluate this fairly standard integral somehow...

• Neither Mathematica nor Rubi can calculate a closed form for the innermost integral. In this form I don't think there's anything you can do - other than numerical evaluation. – flinty Aug 30 at 16:10
• Please post Mathematica code corresponding to the integral. – Anton Antonov Aug 31 at 14:06
• Thank you both! I added my Mathematica code in case it is of any help to make it work. – Avocaddo Aug 31 at 16:51