RokketBox
Engineering4 min read

Latin Hypercube Sampling: Why We Don't Use Brute Force

Optimising a subwoofer enclosure means searching a multi-dimensional space: box volume, tuning frequency, port width, port height, box length, box width, box height. Even with just these seven parameters, a brute-force grid search quickly becomes impractical.

The grid search problem

A Cartesian grid search divides each parameter into evenly spaced steps and evaluates every combination. The number of combinations grows exponentially with each parameter you add — this is the curse of dimensionality.

For a subwoofer enclosure with seven tuneable parameters, even a modest grid produces hundreds of thousands of combinations. With a full circuit-domain simulation at each point, that becomes impractically slow for interactive use — and wasteful, because most of the grid explores regions that are clearly suboptimal. Coarser grids are faster but miss good solutions that fall between the steps.

What Latin hypercube sampling is

Latin hypercube sampling (LHS) is a quasi-random sampling method that provides excellent coverage of a multi-dimensional space with far fewer samples than a grid search.

The method works as follows:

  1. Divide each parameter's range into N equal intervals
  2. Place exactly one sample in each interval for each parameter
  3. Randomly pair the intervals across parameters

The result is that every parameter's range is covered uniformly - there are no gaps or clusters along any single axis - while the multi-dimensional space is explored efficiently.

Think of it like a Sudoku puzzle: in a Latin square, each row and column contains exactly one of each value. LHS extends this concept to N dimensions.

For subwoofer optimization, LHS with a fraction of the samples outperforms a much denser Cartesian grid. Here is why:

Better space-filling. A grid concentrates samples on the grid lines, leaving large regions unexplored between them. LHS distributes samples throughout the space, so there are no systematic gaps.

No aliasing. Grid search can miss optima that fall between grid points. If the optimal tuning frequency is 31.5 Hz but the grid only evaluates 30 and 33, the optimum is invisible. LHS's quasi-random spacing means any particular value is equally likely to be sampled.

Fewer evaluations for the same coverage. LHS achieves comparable coverage to a grid that is an order of magnitude larger, because it does not waste samples on the combinatorial explosion of axis-aligned points.

Enables refinement. With the broad search completing quickly, there is budget for a focused second pass in the most promising regions of the design space — getting the precision of a fine grid with the exploration efficiency of random sampling.

The refinement pass

After the initial LHS sweep, RokketBox narrows the search space around the most promising candidates and runs a more focused evaluation. Because the broad sweep has already eliminated the vast majority of the design space, this refinement can be much more precise without being expensive.

Multi-objective scoring

LHS is particularly well-suited to multi-objective optimization because it naturally produces a diverse set of solutions across the parameter space. Instead of a single "best" answer, you get a population of good solutions that trade off different objectives — maximum output vs. flat response vs. deep extension vs. overall balance.

RokketBox's weight presets let you tell the optimizer what matters to you. Each preset scores the same simulation outputs (SPL, excursion, port velocity, group delay) with different priorities. The LHS population naturally includes solutions that excel at different tradeoffs, and the scoring selects the best one for your chosen goal.

Why not gradient-based optimization?

Classical optimization algorithms (gradient descent, Newton's method) are efficient for smooth, differentiable functions. Subwoofer optimization is neither:

Port routing discontinuities. A port configuration that fits at one set of dimensions might not fit at slightly different dimensions. The feasibility boundary is discontinuous - a step change, not a smooth slope.

Discrete choices. Port type (round, slot, kerfed), number of folds (0, 1, 2), and material thickness are discrete parameters. Gradient methods need continuous spaces.

Noisy objective landscape. The scoring function combines multiple physical metrics with different units and scales. The landscape has many local optima.

LHS handles all of these naturally because it does not assume anything about the objective landscape - it just samples broadly and ranks.

The bottom line

RokketBox's optimizer completes in seconds on modern hardware. The broad LHS sweep followed by focused refinement finds well-optimised enclosure designs faster and more reliably than brute-force search — without the user needing to understand any of the maths behind it.

lhsoptimizationlatin-hypercubegrid-searchengineeringrokketbox

Related posts