All Projects → stevengj → Sobol.jl

stevengj / Sobol.jl

Licence: other
generation of Sobol low-discrepancy sequence (LDS) for the Julia language

Programming Languages

julia
2034 projects

Labels

Projects that are alternatives of or similar to Sobol.jl

Dominhhai.github.io
My Blog
Stars: ✭ 8 (-84.31%)
Mutual labels:  math
Sharpmath
A small .NET math library.
Stars: ✭ 36 (-29.41%)
Mutual labels:  math
Rich Text Editor
Math editor (http://digabi.github.io/rich-text-editor/)
Stars: ✭ 45 (-11.76%)
Mutual labels:  math
Notecalc3
NoteCalc is a handy calculator trying to bring the advantages of Soulver to the web.
Stars: ✭ 879 (+1623.53%)
Mutual labels:  math
Formulador
Render math formulas in 2D in your terminal!
Stars: ✭ 33 (-35.29%)
Mutual labels:  math
Math books
📚 Математичный список полезных книг
Stars: ✭ 38 (-25.49%)
Mutual labels:  math
Hx Mathparser
Evaluates math expressions. Written in Haxe.
Stars: ✭ 7 (-86.27%)
Mutual labels:  math
Swift Numerics
Numerical APIs for Swift
Stars: ✭ 1,052 (+1962.75%)
Mutual labels:  math
Mlcourse.ai
Open Machine Learning Course
Stars: ✭ 7,963 (+15513.73%)
Mutual labels:  math
Jglm
Java OpenGL Mathematics Library
Stars: ✭ 44 (-13.73%)
Mutual labels:  math
Algebra Latex
Parse and calculate latex formatted math
Stars: ✭ 20 (-60.78%)
Mutual labels:  math
Swiftmath
Cross-platform math library with SIMD support
Stars: ✭ 30 (-41.18%)
Mutual labels:  math
Genericsvd.jl
Singular Value Decomposition for generic number types
Stars: ✭ 40 (-21.57%)
Mutual labels:  math
Bacomathiques
Bacomathiques est un petit site web qui contient tout ce dont vous avez besoin pour réviser vos maths en toute tranquillité de la Première à la Terminale ! Que vous cherchiez à passer votre BAC ou que vous souhaitiez simplement réviser votre cours : tout est possible et tout est gratuit.
Stars: ✭ 12 (-76.47%)
Mutual labels:  math
Phobos
The standard library of the D programming language
Stars: ✭ 1,038 (+1935.29%)
Mutual labels:  math
Percent
📈 Percent control done right
Stars: ✭ 7 (-86.27%)
Mutual labels:  math
Blog
About math, programming and procedural generation
Stars: ✭ 37 (-27.45%)
Mutual labels:  math
Sympy
A computer algebra system written in pure Python
Stars: ✭ 8,688 (+16935.29%)
Mutual labels:  math
Sophus
C++ implementation of Lie Groups using Eigen.
Stars: ✭ 1,048 (+1954.9%)
Mutual labels:  math
Prosemirror Math
Schema and plugins for "first-class" math support in ProseMirror!
Stars: ✭ 43 (-15.69%)
Mutual labels:  math

The Sobol module for Julia

Build Status

This module provides a free Julia-language Sobol low-discrepancy-sequence (LDS) implementation. This generates "quasi-random" sequences of points in N dimensions which are equally distributed over an N-dimensional hypercube.

The advantage of an LDS over truly random (or pseudo-random) numbers is that an LDS (which is not random) tends to be more evenly distributed for finite numbers of points. This is used in quasi-Monte Carlo methods in order to accelerate convergence compared to traditional Monte Carlo methods employing random sequences.

It can be installed using the Julia package manager via Pkg.add("Sobol").

Algorithm

This is an independent implementation, originally by Steven G. Johnson, of the algorithm for generation of Sobol sequences in up to 21201 dimensions described in:

Originally implemented in C in 2007 as part of the NLopt library for nonlinear optimization, the code was subsequently converted by Ken-B into pure Julia with roughly the same performance.

It is important to emphasize that SGJ's implementation was based on the mathematical description of the algorithms only, and was done without reference to the Fortran code from the Trans. Math. Soft. (TOMS) papers. The reason is that TOMS code is not free/open-source software (it falls under restrictive ACM copyright terms). (SGJ did re-use a table of primitive polynomials and coefficients from the TOMS code, but since this is merely a tabulation of mathematical facts it is not copyrightable.) SGJ's implementation in NLopt, along with this Julia translation, is free/open-source software under the MIT ("expat") license.

Direction numbers used were derived from the file http://web.maths.unsw.edu.au/~fkuo/sobol/new-joe-kuo-6.21201

Technically, we implement a 32-bit Sobol sequence. After 232-1 points, the sequence terminates, and subsequently our implementation returns pseudo-random numbers generated by the Mersenne Twister algorithm. In practical applications, however, this point is rarely reached.

Usage

To initialize a Sobol sequence s in N dimensions (0 < N < 21201), use the SobolSeq constructor:

using Sobol
s = SobolSeq(N)

Then

x = next!(s)

returns the next point (a Vector{Float64}) in the sequence; each point lies in the hypercube [0,1]N. You can also compute the next point in-place with

next!(s, x)

where x should be a Vector of length N of some floating-point type (e.g. Float64, Float32, or BigFloat).

You can also use a SobolSeq as an iterator in Julia:

for x in SobolSeq(N)
   ...
end

Note, however, that the loop will never terminate unless you explicitly call break (or similar) in the loop body at some point of your choosing.

We also provide a different SobolSeq constructor to provide an N-dimensional Sobol sequence rescaled to an arbitrary hypercube:

s = SobolSeq(lb, ub)

where lb and ub are arrays (or other iterables) of length N, giving the lower and upper bounds of the hypercube, respectively. For example, SobolSeq([-1,0,0],[1,3,2]) generates points in the box [-1,1]×[0,3]×[0,2]. (Although the generated points are Float64 by default, in general the precision is determined by that of lb and ub.)

If you know in advance the number n of points that you plan to generate, some authors suggest that better uniformity can be attained by first skipping the initial portion of the LDS (and in particular, the first power of two smaller than n; see Joe and Kuo, 2003). This facility is provided by:

skip(s, n)

Skipping exactly n elements is also possible:

skip(s, n, exact=true)

Example

Here is a simple example, generating 1024 points in two dimensions and plotting them with the PyPlot package. Note the highly uniform, nonrandom distribution of points in the [0,1]×[0,1] unit square!

using Sobol
using PyPlot
s = SobolSeq(2)
p = hcat([next!(s) for i = 1:1024]...)'
subplot(111, aspect="equal")
plot(p[:,1], p[:,2], "r.")

plot of 1024 points of a 2d Sobol sequence

Author

This module was written by Steven G. Johnson.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].