Skip to content

python implementation of Sobol' sequence generator

License

Notifications You must be signed in to change notification settings

wb2012sf/sobol_seq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

License

This package is heavily based on Sobol, a Python library for generating Sobols by John Burkardt and Corrado Chisari who made their code available under the MIT license. Any additions and/or changes to their code are also made available under the MIT license.

About

python implementation of Sobol' sequence generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%