# sobol¶

Sobol sequence generator

This is a reimplementation of a C++ algorithm by Stephen Joe and Frances Y. Kuo. Directions are based on new-joe-kuo-6.21201 from the URL above.

pyscenarios.sobol.sobol(size: Union[int, Tuple[int, int]], d0: int = 0, chunks: Union[None, int, Tuple[int, int], Tuple[Tuple[int, ...], Tuple[int, ...]]] = None) → Union[numpy.ndarray, dask.array.core.Array]

Sobol points generator based on Gray code order

Parameters
• size – number of samples (cannot be greater than $$2^{32}$$) to extract from a single dimension, or tuple (samples, dimensions). To guarantee uniform distribution, the number of samples should always be $$2^{n} - 1$$.

• d0 (int) – first dimension. This can be used as a functional equivalent of a a random seed. dimensions + d0 can’t be greater than max_dimensions() - 1.

• chunks

If None, return a numpy array.

If set, return a dask array with the given chunk size. It can be anything accepted by dask (a positive integer, a tuple of two ints, or a tuple of two tuples of ints) for the output shape (see result below). e.g. either (16384, 50) or ((16384, 16383),  (50, 50, 50)) could be used together with size=(32767, 150).

Note

The algorithm is not efficient if there are multiple chunks on axis 0. However, if you do need them, it is typically better to require them here than re-chunking afterwards, particularly if (most of) the subsequent algorithm is embarassingly parallel.

Returns

If size is an int, a 1-dimensional array of samples. If size is a tuple, a 2-dimensional array POINTS, where POINTS[i, j] is the ith sample of the jth dimension. Each dimension is a uniform (0, 1) distribution.

Return type

If chunks is not None, dask.array.Array; else numpy.ndarray

pyscenarios.sobol.max_dimensions() → int

Return number of dimensions available. When invoking sobol(), size + d0 must be smaller than this.