feat(qmc): add Halton quasi-Monte Carlo sampler - #250
Conversation
|
@gomezzz, this one's ready for CI too whenever you get a chance — thanks! |
|
@gomezzz , While waiting on Lattice, I checked Halton against everything you flagged 19/19 tests pass. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The torch scrambling is truncated to _digits_needed(base, number_of_points), so its claimed unbiased randomisation is not actually uniform: for N=1 in the first dimension, m=1 and the sample can only be 0 or 0.5 across seeds. That biases the QMC estimator for general integrands; add a random tail/continuous shift (or otherwise make the randomisation unbiased) and include an N=1 distribution regression.
|
Confirmed and fixed. Added a continuous tail shift after digit Added the N=1 regression: 200 seeds now span way more than 2 distinct |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The scrambled Halton construction now adds continuous tail randomization, and the N=1 multi-seed regression demonstrates that the first coordinate is no longer confined to the two-point set caused by the truncated digit permutation. This resolves the bias issue I raised.
Description
Summary of changes
Halton, a (optionally scrambled) Halton low-discrepancy sampler, shaped exactly likeSobolandRNG— plugs intoMonteCarlo.integratevia the existingrng=slot, no changes toMonteCarloitself.torchbackend: pure PyTorch implementation (digit extraction, hierarchical digit-shift scrambling, integer Horner reconstruction), generated directly on the target device — no CPU/NumPy round-trip needed, unlikeSobolEngine.numpy/jax/tensorflowbackends:scipy.stats.qmc.Halton(already a hard dependency), converted to the requested backend.tests/halton_test.py, mirroringsobol_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 flowtest_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 ittest_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 logictest_halton_no_power_of_two_warning: confirms no spurious warning for non-power-of-two Nruff format --check .clean (57 files)Related Pull Requests