# sobol_seq

Created: 2012-03-26 04:56
Updated: 2019-02-01 20:59

# Sobol sequence implementation in python

Sobol sequences are quasi-random low-discrepancy sequences that are useful for creating sample distributions.

## Installation

Install as usual with setuptools - source available from https://github.com/naught101/sobol_seq.

Or a decent package manager like conda:

``````conda install -c https://conda.binstar.org/naught101 sobol_seq
``````

## Usage

Use `i4_sobol` to generate a single Sobol vector:

``````import sobol_seq

vec, seed = sobol_seq.i4_sobol(4, 1)
vec
# array([ 0.5,  0.5,  0.5,  0.5])
seed
# 2

# generate the next vector in the sequence:
vec,seed=sobol_seq.i4_sobol(4, seed)
``````

Use `i4_sobol_generate` to generate a Sobol sequence. For example, if you want to have the first 5 three-dimensional Sobol numbers, run:

``````sobol_seq.i4_sobol_generate(3, 5)

# array([[ 0.5  ,  0.5  ,  0.5  ],
#        [ 0.75 ,  0.25 ,  0.75 ],
#        [ 0.25 ,  0.75 ,  0.25 ],
#        [ 0.375,  0.375,  0.625],
#        [ 0.875,  0.875,  0.125]])
``````

Use `i4_sobol_generate_std_normal` to generate (multivariate) standard normal quasi-random variables. For example, if you want to have the first 5 realisations of a three-dimensional standard normal quasi-random variable, run:

``````sobol_seq.i4_sobol_generate_std_normal(3, 5)

# array([[ 0.        ,  0.        ,  0.        ],
#       [ 0.67448975, -0.67448975,  0.67448975],
#       [-0.67448975,  0.67448975, -0.67448975],
#       [-0.31863936, -0.31863936,  0.31863936],
#       [ 1.15034938,  1.15034938, -1.15034938]])
``````

All functions have detailed documentation available via `help(func)`.