Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Multidimensional and Quasi-Monte Carlo Integration

    A two-parameter loop integral can be smooth and still concentrate most of its variation along a thin strip. A tensor quadrature resolves every coordinate at the same order; adaptive cubature concentrates cells where a local indicator is large; Monte Carlo and randomized low-discrepancy rules distribute samples differently again. Which method earns its precision depends on the integrand and on how all its evaluations are counted.

    We compare these choices on a correlated Gaussian and a positive Euclidean bubble integral. Both have independently computed references. This is a controlled two-dimensional example, not a demonstration that one method wins in every dimension. Familiarity with adaptive quadrature and the elementary variance of a sample mean is sufficient.

    Four ways to spend an evaluation budget

    Let

    I=∫[0,1]dddx f(x).I=\int_{[0,1]^d}d^d x\,f(\boldsymbol x).

    A tensor Gauss rule of order nn in each coordinate uses ndn^d points. Polynomial exactness is powerful for a smooth low-dimensional integrand, but the cost grows exponentially with dd. Our two-dimensional comparison reports the order-nn result and uses the difference from order n/2n/2 as an indicator. Both rules count toward the budget; their difference is not a statistical error bar.

    The adaptive method uses products of three- and five-point Gauss rules on each rectangle. Its local value and indicator are

    QR=Q5,5[R],eR=∣Q5,5[R]−Q3,3[R]∣.Q_R=Q_{5,5}[R], \qquad e_R=|Q_{5,5}[R]-Q_{3,3}[R]|.

    One cell costs 25+9=3425+9=34 evaluations. Bisect the longest side of the cell with the largest eRe_R; ties choose the first coordinate. Replace it by two children and repeat until the next split would exceed the budget. The value is ∑RQR\sum_RQ_R and the indicator is ∑ReR\sum_Re_R. This intentionally simple algorithm is implemented in the companion; it is not an invocation of a newer SciPy cubature interface. The tested SciPy version is 1.13.1.

    For ordinary Monte Carlo, independent uniform points give

    I^N=1N∑j=1Nf(Xj),Var⁡(I^N)=Var⁡[f(X)]N,\widehat I_N=\frac1N\sum_{j=1}^Nf(X_j), \qquad \operatorname{Var}(\widehat I_N) =\frac{\operatorname{Var}[f(X)]}{N},

    provided the integrand has finite variance. There is no N−1/dN^{-1/d} exponent here, but dimension can still make the variance or the cost of one evaluation very large. Geometry matters through the distribution of f(X)f(X).

    A Sobol rule instead places points to cover the cube with low discrepancy. Its points are deliberately dependent. A single deterministic Sobol estimate has no independent-sample standard error obtained by inserting its point values into the Monte Carlo formula.

    Randomize the rule, then estimate variation between rules

    For replicate rr, independently scramble a complete Sobol point set of size n=2mn=2^m, obtaining

    Ir=1n∑j=1nf(Xrj).I_r=\frac1n\sum_{j=1}^n f(X_{rj}).

    The samples within rr are dependent. The independently randomized replicate estimates are the observations used for uncertainty:

    I‾=1R∑r=1RIr,SE⁡^(I‾)=1R(R−1)∑r=1R(Ir−I‾)2.\overline I=\frac1R\sum_{r=1}^R I_r, \qquad \widehat{\operatorname{SE}}(\overline I) =\sqrt{\frac{1}{R(R-1)} \sum_{r=1}^R(I_r-\overline I)^2}.

    Under the ideal uniform randomization, each replicate integrates without bias, while dependence within a replicate can reduce its variance. Finite digital precision and floating-point evaluation are additional numerical effects, not part of this replicate standard error. A Student interval using R−1R-1 degrees of freedom is a useful approximation when the replicate means are reasonably regular; a small number of replicates does not certify its coverage.

    The implementation uses SciPy's linear matrix scramble followed by a digital shift, with bits=52. Every replicate uses a power-of-two prefix; no points are skipped or thinned. These choices follow the tested Sobol documentation, “Notes” and “Warning.” The qmc_quad documentation, “Notes,” explains the same distinction between point sets and independent integral estimates. The companion uses an explicit replicate loop so every seed and replicate mean is retained.

    Here R=20R=20. Ordinary Monte Carlo is also organized into twenty independent groups, with the same formula for the uncertainty of their average. For each method, larger budgets reuse complete prefixes of each group's stream. The rows at different budgets are consequently correlated refinement observations, not independent repetitions of the whole experiment.

    A narrow correlated Gaussian on a square

    Take a bivariate normal density restricted to the unit square. Its parameters are

    μ=(0.4,0.6),σx=σy=σ=0.15,ρ=0.95.\boldsymbol\mu=(0.4,0.6), \qquad \sigma_x=\sigma_y=\sigma=0.15, \qquad \rho=0.95.

    Writing a=(x−μx)/σa=(x-\mu_x)/\sigma and b=(y−μy)/σb=(y-\mu_y)/\sigma, the density is

    fG(x,y)=exp⁡[−(a2−2ρab+b2)/(2(1−ρ2))]2πσ21−ρ2.f_G(x,y)= \frac{\exp[-(a^2-2\rho ab+b^2)/(2(1-\rho^2))]} {2\pi\sigma^2\sqrt{1-\rho^2}}.

    The integral over the square is a probability, not automatically 11. A reference reduces the problem to a different one-dimensional calculation. Conditional on X=xX=x,

    μY∣x=μy+ρ(x−μx),σY∣x=σ1−ρ2.\mu_{Y|x}=\mu_y+\rho(x-\mu_x), \qquad \sigma_{Y|x}=\sigma\sqrt{1-\rho^2}.

    If Φ\Phi is the standard normal cumulative distribution and φσ(x−μx)\varphi_\sigma(x-\mu_x) the marginal density, then

    IG=∫01dx φσ(x−μx)[Φ ⁣(1−μY∣xσY∣x)−Φ ⁣(−μY∣xσY∣x)].I_G=\int_0^1dx\,\varphi_\sigma(x-\mu_x) \left[ \Phi\!\left(\frac{1-\mu_{Y|x}}{\sigma_{Y|x}}\right) -\Phi\!\left(\frac{-\mu_{Y|x}}{\sigma_{Y|x}}\right) \right].

    Gauss orders 128 and 256 each differ by less than 6×10−156\times10^{-15} from the adaptive one-dimensional reference

    IG=0.9923392365431392.I_G=0.9923392365431392.

    That agreement limits how meaningfully we interpret a two-dimensional result already at the 10−1410^{-14} level. It is not an interval-arithmetic enclosure.

    A transformed Feynman-parameter integral

    For the same dimensionless bubble as the preceding article,

    J(q)=−F(−q)=∫01du log⁡[1+qh(u)],h(u)=u(1−u),q>0.J(q)=-F(-q)=\int_0^1du\,\log[1+q h(u)], \qquad h(u)=u(1-u),\qquad q>0.

    Introduce a second parameter through the exact identity

    log⁡(1+x)=∫01dv x1+vx.\log(1+x)=\int_0^1dv\,\frac{x}{1+vx}.

    Thus the positive two-dimensional representation is

    J(q)=∫01du∫01dv qh(u)1+qvh(u).J(q)=\int_0^1du\int_0^1dv\, \frac{q h(u)}{1+qv h(u)}.

    This is an auxiliary-parameter representation of the subtracted one-loop bubble; it is not a two-loop graph. At q=100q=100, variation near v=0v=0 makes a useful numerical test. Because h≤1/4h\leq1/4, set

    A=q4,ℓ=log⁡(1+A),v(t)=expm1⁡(ℓt)A,dvdt=ℓeℓtA.A=\frac q4,\qquad \ell=\log(1+A),\qquad v(t)=\frac{\operatorname{expm1}(\ell t)}{A}, \qquad \frac{dv}{dt}=\frac{\ell e^{\ell t}}{A}.

    The endpoints remain v(0)=0v(0)=0 and v(1)=1v(1)=1. The transformed integrand is

    f~q(u,t)=qh(u)1+qv(t)h(u)ℓeℓtA.\widetilde f_q(u,t)= \frac{q h(u)}{1+qv(t)h(u)} \frac{\ell e^{\ell t}}{A}.

    Near the most rapidly varying region, the map gives more of the parameter interval to small vv. The Jacobian is essential: dropping it changes the integral rather than improving its evaluation.

    At the declared q=100q=100, direct one-dimensional logarithmic integration and the independently implemented analytic bubble give

    J(100)=2.716467290451959.J(100)=2.716467290451959.

    This reference is outside the compared evaluation budgets. The positive Euclidean denominator avoids the threshold and branch problems treated in contour deformation.

    Equal caps, explicit counts, and retained outcomes

    The three caps are 51205120, 2048020480, and 8192081920 scalar integrand evaluations. Tensor fine orders 6464, 128128, and 256256, together with their half-order comparisons, exactly use those caps. Monte Carlo and scrambled Sobol use twenty groups of respectively 256256, 10241024, and 40964096 points.

    The adaptive rule cannot consume arbitrary counts in its 68-evaluation split increments. Its actual counts are 50665066, 2043420434, and 8190681906. They share the same caps, but are slightly smaller; no dummy evaluations are added. References and separate correctness checks are not included in the competing production budgets.

    At the middle cap, the comparison is:

    IntegrandMethodAbsolute errorIndicator or replicate SE
    GaussianTensor1.0×10−141.0\times10^{-14}2.3×10−152.3\times10^{-15} indicator
    GaussianAdaptive6.9×10−106.9\times10^{-10}2.3×10−62.3\times10^{-6} indicator
    GaussianMC1.35×10−21.35\times10^{-2}1.70×10−21.70\times10^{-2} SE
    GaussianSobol1.33×10−31.33\times10^{-3}2.90×10−32.90\times10^{-3} SE
    Mapped bubbleTensor2.1×10−142.1\times10^{-14}9.3×10−149.3\times10^{-14} indicator
    Mapped bubbleAdaptive2.1×10−112.1\times10^{-11}2.0×10−72.0\times10^{-7} indicator
    Mapped bubbleMC1.43×10−31.43\times10^{-3}5.30×10−35.30\times10^{-3} SE
    Mapped bubbleSobol6.44×10−56.44\times10^{-5}9.60×10−59.60\times10^{-5} SE

    The tensor rule is excellent for these smooth two-dimensional examples. The deliberately low-order adaptive indicator is conservative here, although the preceding article shows that such indicators can also fail completely. Neither indicator should be read as a Gaussian standard deviation.

    The variable change helps the randomized bubble estimates as well. At the largest cap, the MC SE decreases from 1.25×10−21.25\times10^{-2} for the raw representation to 2.24×10−32.24\times10^{-3} for the mapped one; the Sobol SE decreases from 8.17×10−58.17\times10^{-5} to 1.37×10−51.37\times10^{-5}. Each uncertainty estimate uses separate seeds.

    Absolute integration error against total evaluation cost for tensor, adaptive, Monte Carlo, and scrambled Sobol methods on the Gaussian and mapped bubble.

    Actual absolute errors are measured against the independent references; these curves are not uncertainty intervals. Each randomized point includes all twenty replicas. Tensor errors near 10−1410^{-14} are at the scale of reference and binary64 agreement. Larger prefixes need not reduce the realized random error monotonically.

    For example, the largest Gaussian Sobol estimate lies about 2.042.04 estimated standard errors above the reference. This result is retained. Three correlated budget rows and twenty scrambles per row do not establish coverage, a universal convergence exponent, or performance in high-dimensional singular integrals. Importance sampling, analytic subtraction, and suitable variable changes can change the comparison substantially.

    Reproduction

    Run python3 examples/computational-qft/numerical-integration/multidimensional_rules.py to regenerate cubature-results.json. Seeds are SeedSequence([881025, method, case, replica]), with method 00 for MC and 11 for Sobol, and cases 0,1,20,1,2 for Gaussian, raw bubble, and mapped bubble. The output retains all replica means, exact evaluation counts, reference refinements, and rectangular normalization checks.

    For general integrals, choose a representation before choosing a sampling engine. Tensor rules exploit low dimension and smoothness. Adaptive cubature exploits localized variation when its indicators see it. Randomized methods become especially useful when a tensor grid is too expensive, but still require variance control and honest accounting of independent replicates.

    Exercises

    1. Verify the bubble map and its normalization

    Derive the two-parameter representation from J(q)J(q), show that the transformed endpoints are correct, and evaluate the tt integral at fixed uu. What happens as q→0q\to0?

    Solution

    For x≥0x\geq0,

    ∫01x dv1+vx=[log⁡(1+vx)]01=log⁡(1+x).\int_0^1\frac{x\,dv}{1+vx} =[\log(1+vx)]_0^1=\log(1+x).

    With x=qh(u)x=q h(u) this proves the representation. Since eℓ=1+Ae^\ell=1+A, the proposed map gives v(0)=0v(0)=0 and v(1)=A/A=1v(1)=A/A=1. Its derivative is positive, so it is one-to-one. Direct substitution gives

    ∫01dt f~q(u,t)=∫01dv qh(u)1+qvh(u)=log⁡[1+qh(u)].\int_0^1dt\,\widetilde f_q(u,t) =\int_0^1dv\,\frac{q h(u)}{1+qv h(u)} =\log[1+q h(u)].

    As q→0q\to0, ℓ/A→1\ell/A\to1 and v(t)→tv(t)\to t. The transformed and original integrands approach qh(u)q h(u), and J(q)/q→∫01h(u) du=1/6J(q)/q\to\int_0^1h(u)\,du=1/6. At exactly q=0q=0, use this limiting map rather than dividing two zeros in its formula.

    2. Count the independent observations

    Twenty independently scrambled rules each use 10241024 points. Derive the standard error of their average from their twenty integral estimates. Explain why taking the sample standard deviation of all 2048020480 point values and dividing by 20480\sqrt{20480} gives a different, generally unjustified answer.

    Solution

    If the replicate estimates have common variance vv and are independent, their average has variance v/20v/20. The unbiased estimator of vv is

    sI2=119∑r=120(Ir−I‾)2.s_I^2=\frac1{19}\sum_{r=1}^{20}(I_r-\overline I)^2.

    Consequently

    SE⁡^(I‾)=120⋅19∑r=120(Ir−I‾)2.\widehat{\operatorname{SE}}(\overline I) =\sqrt{\frac1{20\cdot19} \sum_{r=1}^{20}(I_r-\overline I)^2}.

    Within one scrambled rule,

    Var⁡(Ir)=110242∑j,k=11024Cov⁡ ⁣(f(Xrj),f(Xrk)).\operatorname{Var}(I_r) =\frac1{1024^2} \sum_{j,k=1}^{1024}\operatorname{Cov}\!\left(f(X_{rj}),f(X_{rk})\right).

    The terms with j≠kj\ne k generally do not vanish. A pointwise iid formula discards precisely the dependence that makes the rule useful. The twenty randomizations cost 20⋅1024=2048020\cdot1024=20480 evaluations in total. With only one deterministic rule, even the between-replicate variance is unavailable.

    Summary

    Compare methods at declared total costs and compare like quantities. Deterministic refinement indicators, realized errors against a reference, and randomized standard errors answer different questions. The transformed bubble shows why preserving a Jacobian and improving an integrand's geometry can matter as much as changing the integration algorithm.

    References

    • SciPy developers, SciPy 1.13.1 Manual, scipy.integrate.qmc_quad, parameters n_estimates and n_points and the replicate-error discussion in “Notes.”
    • SciPy developers, SciPy 1.13.1 Manual, scipy.stats.qmc.Sobol, scrambling, seed, random_base2, and the warnings about skipped or thinned sequences.

    Scrollable formula. Use Left and Right arrow keys to reveal hidden content.

    Scrollable table. Use Left and Right arrow keys to reveal hidden columns.

    Scrollable figure. Use Left and Right arrow keys to reveal hidden content.