Skip to content

_sobol

Sobol quasi-random sequences via scipy.stats.qmc.

Provides the same quasirandom_sobol(N, D) and quasirandom_sobol_batch(start, end, D) interface that chmpy used historically (1-indexed seeds, end inclusive), backed by scipy.stats.qmc.Sobol. Output is bit-identical to the previous cython implementation, which used the same Joe & Kuo direction numbers.

quasirandom_sobol(N, D)

Return the Nth Sobol vector (1-indexed) in D dimensions.

Source code in chmpy/sampling/_sobol.py
def quasirandom_sobol(N: int, D: int) -> np.ndarray:
    """Return the ``N``th Sobol vector (1-indexed) in ``D`` dimensions."""
    if N < 1:
        raise ValueError("input seed for sobol_vector must be >= 1")
    pts = _draw(N, D)
    return pts[N - 1]

quasirandom_sobol_batch(start, end, D)

Return Sobol vectors for the inclusive seed range [start, end].

Source code in chmpy/sampling/_sobol.py
def quasirandom_sobol_batch(start: int, end: int, D: int) -> np.ndarray:
    """Return Sobol vectors for the inclusive seed range ``[start, end]``."""
    if start < 1:
        raise ValueError("input seed for sobol_vector must be >= 1")
    if end < start:
        raise ValueError("end must be >= start")
    pts = _draw(end, D)
    return pts[start - 1 : end]