Fixed to 2D for visualization. LHS itself extends to arbitrary dimension d.
0: Gaussian peak (centered) / 1: sin(πx)sin(πy) ridge / 2: high frequency sin(20πx)sin(20πy)
Random numbers are generated deterministically with an LCG. The same seed and N always produces the same samples.
Background grid lines mark the LHS N×N cell partition. LHS places one point per row and column (stratified); plain MC has no stratification.
For each dimension $d$, Latin Hypercube Sampling builds an independent permutation $\pi_d$ of $\{0,1,\dots,N-1\}$ and sets the $d$-th coordinate of the $i$-th sample by (with $u_{i,d}\sim U(0,1)$):
$$x_{i,d} = \frac{\pi_d(i) + u_{i,d}}{N}$$The integral of $f$ is estimated by the sample mean:
$$\hat{I} = \frac{1}{N}\sum_{i=1}^{N} f(\mathbf{x}_i)$$For smooth integrands, the variance of the LHS estimate drops faster than $1/N$ of plain MC, so the practical error is smaller:
$$\mathrm{Var}(\hat{I}_\text{LHS}) \le \mathrm{Var}(\hat{I}_\text{MC})$$The test function $f_1(x,y)=\sin(\pi x)\sin(\pi y)$ has the exact integral $4/\pi^2 \approx 0.4053$. This tool uses that value as the reference to compare LHS and MC errors.