Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Structured randomness

Use this page when a finite-dimensional integral may benefit from structured space filling and you need to distinguish a deterministic approximation from a randomized uncertainty statement.

The big picture

Ordinary Monte Carlo uses independent points. Quasi-Monte Carlo (QMC) instead chooses points that cover [0,1)d[0,1)^d systematically. Randomized QMC (RQMC) randomizes that structured design without discarding it.

These are different inferential objects. A deterministic prefix gives a reproducible approximation but no sampling uncertainty. Replicated scrambles give randomized evidence. Repeatedly inspecting that evidence requires a sequentially valid policy.

The estimator

Let f:[0,1)dRf:[0,1)^d\rightarrow\mathbb{R} and

I=[0,1)df(u)du.I=\int_{[0,1)^d} f(\mathbf{u})\,d\mathbf{u}.

For a power-of-two prefix N=2N=2^\ell, one Sobol estimate is

I^N=1Nn=0N1f(un).\widehat{I}_{N} =\frac{1}{N}\sum_{n=0}^{N-1}f(\mathbf{u}_{n}).

The first Sobol point is retained; Jaxstro does not silently skip the origin. A finite hyperrectangle is handled by the shared affine map, signed orientation, measure density, and Jacobian owners in jaxstro.quad.

Three randomizations, three honest names

DigitalShift applies one coordinatewise bitwise shift. It is inexpensive and reproducible, but it is not Owen scrambling.

LinearMatrixScramble applies a random unit lower-triangular matrix over GF(2)\operatorname{GF}(2) and then an independently keyed digital shift. This is the default for randomized integration.

OwenScramble applies a nested bit permutation. For coordinate jj, bit bb, and already-scrambled prefix pp, its permutation depends on the complete triple (j,b,p)(j,b,p). That prefix dependence is the defining distinction from an LMS construction.

Fixed-look uncertainty

For RR independent scrambles, let I^N,r\widehat{I}_{N,r} be the estimate from replicate rr. Jaxstro computes

I=1Rr=1RI^N,r,s2=1R1r=1R(I^N,rI)2.\overline{I} =\frac{1}{R}\sum_{r=1}^{R}\widehat{I}_{N,r}, \qquad s^2 =\frac{1}{R-1}\sum_{r=1}^{R} \left(\widehat{I}_{N,r}-\overline{I}\right)^2.

One predeclared inspection uses the half-width

hfixed=t1α/2,R1sR.h_{\mathrm{fixed}} =t_{1-\alpha/2,R-1}\frac{s}{\sqrt{R}}.

ScrambledSobol requires R8R\geq 8 and returns ErrorKind.CONFIDENCE_INTERVAL_HALF_WIDTH. The Student-tt quantile is stopped with respect to automatic differentiation and is evaluated with cancellation-resistant center and survival-probability formulas.

import jax
import jax.numpy as jnp

from jaxstro import quad

result = quad.integrate(
    lambda x: jnp.exp(-jnp.sum(x, axis=-1)),
    quad.Hyperrectangle(jnp.zeros(8), jnp.ones(8)),
    method=quad.ScrambledSobol(level=8, replicates=16),
    key=jax.random.key(19),
    epsabs=1.0e-3,
    epsrel=0.0,
    max_evaluations=16 * 2**8,
    gradient="stop",
)

The key is explicit, and replicate rr uses jax.random.fold_in(key, r). Increasing replicate capacity therefore does not rewrite existing replicate identities.

Sequential uncertainty

A fixed-look interval must not be reinterpreted after repeated convergence checks. AdaptiveScrambledSobol instead requires a complete static schedule

S=((1,R1),,(K,RK))\mathcal{S} =\bigl((\ell_1,R_1),\ldots,(\ell_K,R_K)\bigr)

with monotone strict progress and final growth in both \ell and RR. Existing replicates reuse their Sobol prefix, and new replicates receive stable folded keys.

At inspection kk, the overall error probability α\alpha is allocated as

αk=α6π2(k+1)2,k=0αk=α.\alpha_k =\alpha\frac{6}{\pi^2(k+1)^2}, \qquad \sum_{k=0}^{\infty}\alpha_k=\alpha.

Given certified replicate-estimate bounds AI^N,rBA\leq\widehat{I}_{N,r}\leq B, the empirical-Bernstein half-width is

hk=2sk2log(2/αk)Rk+7(BA)log(2/αk)3(Rk1).h_k =\sqrt{\frac{2s_k^2\log(2/\alpha_k)}{R_k}} +\frac{7(B-A)\log(2/\alpha_k)}{3(R_k-1)}.

The union bound preserves the overall confidence claim even though the reused prefixes make inspections dependent.

method = quad.AdaptiveScrambledSobol(
    schedule=((6, 8), (7, 16), (8, 32)),
    estimate_bounds=(0.0, 1.0),
)

Direct estimate_bounds apply to replicate estimates and may certify a signed finite measure. integrand_bounds are derived automatically only for LebesgueMeasure, including reversed orientation. Weighted-measure derivation is rejected in Phase B3 because a pointwise integrand bound does not determine a weighted integral bound without certified measure information.

Astrophysical uses

Structured randomness is useful when a calculation contains a modest number of continuously varying nuisance coordinates:

The effective dimension matters more than the nominal column count. A 16-dimensional integrand dominated by two coordinates can be a better QMC target than a discontinuous two-dimensional mask.

What JAX differentiates

Methods and schedules are static PyTree metadata. Domains and keys may be dynamic under jax.jit; randomized methods support jax.vmap over keys and domains. Float32 coordinates retain at most 24 digital bits, and float64 coordinates retain at most 53. Float64 and integer operations above 32 bits fail eagerly unless jax_enable_x64=True.

All B3 methods require gradient="stop". Replay derivatives, multidimensional quantity certification, and final backend/memory optimization remain Phase B4 work.

Where the claim stops

The frozen campaign contains exactly four predeclared records and 3,145,7283{,}145{,}728 primary point-integrand evaluations. The two fixed-look cases covered 124/128124/128 and 120/128120/128 truths, both inside the exact 99% binomial acceptance band [115,127][115,127] for nominal 95% coverage. Sequential coverage is required not to fall below the same lower validity bound; excess coverage is reported as conservatism rather than misclassified as invalidity.

Connected foundations and methods

Review Probability and distributions for probability measures and Sensitivity, conditioning, and identifiability for conditioning. Connect explicit keys in Random computation, fixed quadrature in Fixed and weighted quadrature, sparse grids in Sparse-grid quadrature, and the complete public surface in Jaxstro quadrature.