Skip to content

feat(qmc): add Halton quasi-Monte Carlo sampler - #250

Open
Samuel-Vangu wants to merge 1 commit into
esa:developfrom
Samuel-Vangu:feat/add-halton-sampler
Open

feat(qmc): add Halton quasi-Monte Carlo sampler#250
Samuel-Vangu wants to merge 1 commit into
esa:developfrom
Samuel-Vangu:feat/add-halton-sampler

Conversation

@Samuel-Vangu

@Samuel-Vangu Samuel-Vangu commented Jul 30, 2026

Copy link
Copy Markdown

Description

Summary of changes

  • Adds Halton, a (optionally scrambled) Halton low-discrepancy sampler, shaped exactly like Sobol and RNG — plugs into MonteCarlo.integrate via the existing rng= slot, no changes to MonteCarlo itself.
  • torch backend: pure PyTorch implementation (digit extraction, hierarchical digit-shift scrambling, integer Horner reconstruction), generated directly on the target device — no CPU/NumPy round-trip needed, unlike SobolEngine.
  • numpy / jax / tensorflow backends: scipy.stats.qmc.Halton (already a hard dependency), converted to the requested backend.
  • Unlike Sobol, does not require the sample size to be a power of two.
  • Adds tests/halton_test.py, mirroring sobol_test.py's structure, plus Halton-specific regression tests (see Test plan).

Resolved Issues

How Has This Been Tested?

  • halton_test.py, all backends: analytic accuracy against the test-function collection, Halton < plain-MC error at equal N (fixed seed), seed reproducibility, torch gradient flow
  • test_digits_needed_is_per_dimension: deterministic, seed/device-independent unit test guarding against a real bug found during development (a shared digit count across dimensions silently broke equidistribution for every dimension except the one with the smallest base)
  • test_halton_column_independent_of_other_dimensions: exact-equality check that a dimension's column never depends on which other dimensions are requested alongside it
  • test_halton_matches_scipy_when_unscrambled: pure-PyTorch and SciPy backends agree to within float64 machine epsilon (~2e-16) when scrambling is off, validating the digit extraction/reconstruction independently of the scrambling logic
  • test_halton_no_power_of_two_warning: confirms no spurious warning for non-power-of-two N
  • ruff format --check . clean (57 files)

Related Pull Requests

@Samuel-Vangu

Copy link
Copy Markdown
Author

@gomezzz, this one's ready for CI too whenever you get a chance — thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant