Git Product home page Git Product logo

sobol_seq's Introduction

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.

sobol_seq's People

Contributors

naught101 avatar sjvrijn avatar bstemper avatar cnrlwlss avatar frazar avatar wb2012sf avatar ingmarschuster avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.