Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sobol-test-func

Some test functions for Sobol sequences


Description

Some test functions for Sobol sequences

Usage

sobol.directions(polycoef, deg, prevmj, nbpoint, echo=FALSE)
sobol.basic(n, polycoef, deg, prevmj, echo=FALSE, output=c("real", "integer"))
sobol.R(n, d, echo=FALSE)

int2bit(x)
bit2int(x)
bit2unitreal(x)

Arguments

n

number of observations.

d

dimension of observations.

polycoef

binary coefficients of the primitive polynomial.

deg

degree of the primitive polynomial.

prevmj

matrix where each column is the binary representation of integers m_j

nbpoint

number of additionnal integers m_j.

echo

a logical to show some traces.

output

a character string either "real" or "integer" to specify whether the radical inverse function is computed output="real" or not output="integer".

x

an integer to convert in base 2 or its binary representation

Details

sobol.directions computes the direction numbers used when computing Sobol sequences.

sobol.basic compute the Sobol sequence in one dimension according to a primitive polynomial and specified integers m_j.

int2bit computes the binary representation of the integer part of a real, bit2int computes an integer from its binary representation. bit2unitreal computes the radical inverse function in base 2.

Value

a vector of length n for sobol.basic or a matrix for sobol.directions.

Author(s)

Christophe Dutang

References

Glasserman P., (2003); Monte Carlo Methods in Financial Engineering, Springer.

See Also

quasiRNG for quasi random number generation.

Examples

#page 306 of Glassermann
p13 <- int2bit(13)
prevterm <- sapply(c(1,3,3), int2bit)
colnames(prevterm) <- apply(prevterm, 2, bit2int)
sobol.directions(p13, 3, prevterm, 2, echo=FALSE)


sobol.basic(15, p13, 3, c(1,3,3), echo=FALSE)
sobol.basic(15, p13, 3, c(1,3,3), echo=FALSE, output="i")


#page 307 of Glassermann
trueval <- c(16, 24,  8, 12, 28, 20,  4, 30, 14,  
6, 22, 18,  2, 10, 26,  5, 21, 29, 13,  9, 25, 17,  
1, 27, 11,  3, 19, 23,  7, 15, 31)/32
cbind(sobol.basic(31, p13, 3, prevterm, echo=FALSE, output="r") , trueval)

randtoolbox

Toolbox for Pseudo and Quasi Random Number Generation and Random Generator Tests

v1.30.1
BSD_3_clause + file LICENSE
Authors
R port by Yohan Chalabi, Christophe Dutang, Petr Savicky and Diethelm Wuertz with some underlying C codes of (i) the SFMT algorithm from M. Matsumoto and M. Saito, (ii) the Knuth-TAOCP RNG from D. Knuth.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.