bundles / scipy 1.17.1 / scipy / stats / _qmc / Sobol
ABCMeta
scipy.stats._qmc:Sobol
source: /scipy/stats/_qmc.py :1609
Signature
def Sobol ( d : int | numpy.integer , * , scramble : bool = True , bits : int | numpy.integer | None = None , rng : int | numpy.integer | numpy.random._generator.Generator | numpy.random.mtrand.RandomState | None = None , optimization : Literal['random-cd', 'lloyd'] | None = None , seed = None ) → None Members
Summary
Engine for generating (scrambled) Sobol' sequences.
Extended Summary
Sobol' sequences are low-discrepancy, quasi-random numbers. Points can be drawn using two methods:
random_base2: safely draw points. This method guarantees the balance properties of the sequence.random: draw an arbitrary number of points from the sequence. See warning below.
Parameters
d: intDimensionality of the sequence. Max dimensionality is 21201.
scramble: bool, optionalIf True, use LMS+shift scrambling. Otherwise, no scrambling is done. Default is True.
bits: int, optionalNumber of bits of the generator. Control the maximum number of points that can be generated, which is
2**bits. Maximal value is 64. It does not correspond to the return type, which is alwaysnp.float64to prevent points from repeating themselves. Default is None, which for backward compatibility, corresponds to 30.optimization: {None, "random-cd", "lloyd"}, optionalWhether to use an optimization scheme to improve the quality after sampling. Note that this is a post-processing step that does not guarantee that all properties of the sample will be conserved. Default is None.
random-cd: random permutations of coordinates to lower the centered discrepancy. The best sample based on the centered discrepancy is constantly updated. Centered discrepancy-based sampling shows better space-filling robustness toward 2D and 3D subprojections compared to using other discrepancy measures.lloyd: Perturb samples using a modified Lloyd-Max algorithm. The process converges to equally spaced samples.
rng: `numpy.random.Generator`, optionalPseudorandom number generator state. When
rngis None, a new numpy.random.Generator is created using entropy from the operating system. Types other than numpy.random.Generator are passed to numpy.random.default_rng to instantiate aGenerator.
Notes
Sobol' sequences [1] provide low discrepancy points in . Scrambling them [3] makes them suitable for singular integrands, provides a means of error estimation, and can improve their rate of convergence. The scrambling strategy which is implemented is a (left) linear matrix scramble (LMS) followed by a digital random shift (LMS+shift) [2].
There are many versions of Sobol' sequences depending on their 'direction numbers'. This code uses direction numbers from [4]. Hence, the maximum number of dimension is 21201. The direction numbers have been precomputed with search criterion 6 and can be retrieved at https://web.maths.unsw.edu.au/~fkuo/sobol/.
Examples
Generate samples from a low discrepancy sequence of Sobol'.from scipy.stats import qmc sampler = qmc.Sobol(d=2, scramble=False) sample = sampler.random_base2(m=3) sample✓
qmc.discrepancy(sample)
✓_ = sampler.reset() _ = sampler.fast_forward(4) sample_continued = sampler.random_base2(m=2) sample_continued✓
l_bounds = [0, 2] u_bounds = [10, 5] qmc.scale(sample_continued, l_bounds, u_bounds)✓
Aliases
-
scipy.stats._qmc.Sobol