Testing Uniform Random Samplers: Methods, Datasets and Protocols

Olivier Zeyen, Maxime Cordy, Martin Gubri, Gilles Perrouin, Mathieu AcherarXiv 2025

Introduction

In modern software engineering, variability-intensive systems—such as the Linux kernel or complex web stacks—often encompass trillions of possible configurations. Exploring these massive search spaces is computationally prohibitive, leading researchers and engineers to rely on sampling. To ensure that statistical inferences drawn from these samples are valid, the sampling process must be uniform: every valid configuration should have an equal probability of being selected.

While many "Uniform Random Samplers" (URS) have been developed, verifying their claims of uniformity is a significant challenge. Unlike Pseudo-Random Number Generators (PRNGs), which operate on unconstrained spaces, URS tools must navigate the "constrained hyperspace" defined by Boolean formulae. This paper introduces a rigorous statistical framework designed to evaluate URS tools, revealing that theoretical guarantees often fail to translate into practical implementation.

The Statistical Framework

The authors propose a suite of five statistical tests, adapted from the PRNG community to account for the constraints of Boolean logic:

  1. Pearson’s $\chi^2$ Goodness of Fit (GOF): The most rigorous test, comparing observed frequencies against expected uniform distributions. However, it is limited to small solution spaces where all possible solutions can be enumerated.
  2. Monobit Test: A high-level check on whether the ratio of "true" to "false" variable assignments across all samples aligns with the overall distribution of the search space.
  3. Variable Frequency (VF) Test: A granular extension of the Monobit test that evaluates the frequency of every individual variable across the sample set.
  4. Selected Features per Configuration (SFpC): This test examines the distribution of the number of active features (variables set to true) per sample.
  5. Birthday Problem Test: Based on the "birthday paradox," this test monitors the frequency of duplicate samples. An excess or deficit of duplicates indicates a deviation from uniformity.

To manage the risk of Type-I errors (false positives) when running multiple tests, the framework utilizes the Harmonic Mean p-value (HMP). This method combines multiple p-values into a single score, providing a statistically robust verdict on a sampler's performance.

Experimental Evaluation

The framework was applied to seven state-of-the-art samplers using a diverse range of benchmarks, including the $\Omega$ Dataset (195 real-world formulas from configurable systems like the Linux kernel and JHipster) and various synthetic 3-CNF formulas used to isolate the impact of formula structure on sampler behavior.

Key Findings

The study revealed a significant "Implementation Gap." Several samplers with theoretical proofs of uniformity failed the statistical tests. For instance, SPUR, despite its theoretical foundations, failed multiple tests, suggesting that implementation bugs or practical heuristics can undermine mathematical guarantees.

UniGen3 emerged as the most reliable tool, being the only sampler to pass all tests across the real-world $\Omega$ dataset. In contrast, popular samplers like QuickSampler, CMSGen, and STS failed the Variable Frequency (VF) test decisively ($p$-value $\approx 0.000$).

The research also highlighted a trade-off between uniformity and exploration. The Birthday test showed that some non-uniform samplers (like STS) actually explore the search space more aggressively by producing fewer duplicates than a uniform distribution would. While beneficial for certain testing scenarios, this behavior makes them unsuitable for statistical inference.

Practical Implications and "Pre-testing"

Testing for uniformity is computationally expensive. To optimize this process, the authors recommend a "pre-testing" strategy. They observed that samplers failing on simple synthetic formulas almost invariably fail on complex real-world ones. By following a specific test order—starting with the Variable Frequency test, followed by SFpC, and finally the Birthday test—developers can quickly identify and eliminate flawed samplers before committing to days of compute time on expensive tests.

Conclusion

The proposed framework provides a standardized, independent protocol for assessing the quality of uniform random samplers. The results underscore that uniformity is not a static property; it is highly dependent on the input formula and the integrity of the sampler's implementation. By providing a "common playground" for the community, this work paves the way for more robust and reliable tools in the field of variability-intensive system analysis.

Summary updated

BibTeX
@misc{zeyen2025testing,
  author = {Olivier Zeyen and Maxime Cordy and Martin Gubri and Gilles Perrouin and Mathieu Acher},
  title = {{Testing Uniform Random Samplers: Methods, Datasets and Protocols}},
  year = {2025},
  eprint = {2503.14079},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.14079},
}
Figure