Box counting estimates the fractal dimension of a point set by covering it with a grid of squares of side s and counting how many squares N(s) contain at least one point. For a self-similar set this follows a power law:
N(s) ∝ s^(−D)
D = lim(s→0) log N(s) / log(1/s)
In practice you sweep several scales s₁ > s₂ > … , plot log N(s) against log(1/s), and the slope of the best-fit line through those points is the estimate of D. This simulator grids the domain at k = 1, 3, 9, 27, 81, 243 divisions per side (s = 2/k) and fits:
D̂ = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)²
where x = log k, y = log N(k)
Why powers of 3, not powers of 2: the 3D sibling of this simulator grids every pattern at k = 1,2,4,8,16,32 regardless of which pattern is selected. That is fine for the Sierpinski shape (built from a ratio-1/2 contraction, so it lines up with a base-2 grid) but it silently mismeasures the Cantor dust, which is built from a base-3 (ternary) construction: a standalone check of that exact code (grid vs. a 6-digit ternary Cantor coordinate, 40k points) measured D ≈ 2.36 against a claimed theoretical 1.89 — a real ~25% error from grid/generator misalignment, not sampling noise (confirmed by re-running with a much finer base-2 grid, which still converged to the wrong value, 1.74). Regridding at k = 3ᵐ instead of 2ᵐ brought the same generator to D ≈ 1.90. This simulator uses that corrected base-3 grid for every pattern so one consistent grid measures all four fairly.
- Pattern buttons — switch the underlying point set; each has a known theoretical dimension shown above the buttons for comparison against the measured D.
- Point count — more points resolve the fine scales more accurately (sparse clouds under-count small boxes).
- Grid scale level — chooses which of the 6 grids is drawn over the pattern; the regression itself always uses all 6 levels at once, plotted live below the pattern view.
- Drag / scroll on the pattern view — pans and zooms your camera on the plane; it never changes the data or the measurement, only how closely you're looking.