LowDiscrepancy: Low Discrepancy Sequences

Description Usage Arguments Details Value Note Author(s) References Examples

Description

A collection and description of functions to compute Halton's and Sobol's low discrepancy sequences, distributed in form of a uniform or normal distribution.

The functions are:

runif.halton Uniform Halton sequence,
rnorm.halton Normal Halton sequence,
runif.sobol Uniform scrambled Sobol sequence,
rnorm.sobol Normal scrambled Sobol sequence,
runif.pseudo Uniform pseudo random numbers,
norma.pseudo Normal pseudo random numbers.

Usage

1
2
3
4
5
6
7
8
runif.halton(n, dimension, init) 
rnorm.halton(n, dimension, init)

runif.sobol(n, dimension, init, scrambling, seed) 
rnorm.sobol(n, dimension, init, scrambling, seed)

runif.pseudo(n, dimension, init)
rnorm.pseudo(n, dimension, init)

Arguments

dimension

an integer value, the dimension of the sequence. The maximum value for the Sobol generator is 1111.

init

a logical, if TRUE the sequence is initialized and restarts, otherwise not. By default TRUE.

n

an integer value, the number of random deviates.

scrambling

an integer value, if 1, 2 or 3 the sequence is scrambled otherwise not. If 1, Owen type type of scrambling is applied, if 2, Faure-Tezuka type of scrambling, is applied, and if 3, both Owen+Faure-Tezuka type of scrambling is applied. By default 0.

seed

an integer value, the random seed for initialization of the scrambling process. By default 4711. On effective if scrambling>0.

Details

Halton's Low Discrepancy Sequences:

Calculates a matrix of uniform or normal deviated halton low discrepancy numbers.

Scrambled Sobol's Low Discrepancy Sequences:

Calculates a matrix of uniform and normal deviated Sobol low discrepancy numbers. Optional scrambling of the sequence can be selected.

Pseudo Random Number Sequence:

Calculates a matrix of uniform or normal distributed pseudo random numbers. This is a helpful function for comparing investigations obtained from a low discrepancy series with those from a pseudo random number.

Value

All generators return a numeric matrix of size n by dimension.

Note

The global variables runif.halton.seed and runif.sobol.seed save the status to restart the generators. Note, that only one instance of a generators can be run at the same time.

The ACM Algorithm 659 implemented to generate scrambled Sobol sequences is under the License of the ACM restricted for academic and noncommerical usage. Please consult the ACM License agreement included in the doc directory.

Author(s)

P. Bratley and B.L. Fox for the Fortran Sobol Algorithm 659,
S. Joe for the Fortran extension to 1111 dimensions,
Diethelm Wuertz for the Rmetrics R-port.

References

Bratley P., Fox B.L. (1988); Algorithm 659: Implementing Sobol's Quasirandom Sequence Generator, ACM Transactions on Mathematical Software 14, 88–100.

Joe S., Kuo F.Y. (1998); Remark on Algorithm 659: Implementing Sobol's Quaisrandom Seqence Generator.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## *.halton - 
   par(mfrow = c(2, 2), cex = 0.75)
   runif.halton(n = 10, dimension = 5)
   hist(runif.halton(n = 5000, dimension = 1), main = "Uniform Halton", 
     xlab = "x", col = "steelblue3", border = "white")
   rnorm.halton(n = 10, dimension = 5)
   hist(rnorm.halton(n = 5000, dimension = 1), main = "Normal Halton", 
     xlab = "x", col = "steelblue3", border = "white")
   
## *.sobol - 
   runif.sobol(n = 10, dimension = 5, scrambling = 3)
   hist(runif.sobol(5000, 1, scrambling = 2), main = "Uniform Sobol", 
     xlab = "x", col = "steelblue3", border = "white")
   rnorm.sobol(n = 10, dimension = 5, scrambling = 3)
   hist(rnorm.sobol(5000, 1, scrambling = 2), main = "Normal Sobol", 
     xlab = "x", col = "steelblue3", border = "white")
   
## *.pseudo - 
   runif.pseudo(n = 10, dimension = 5)
   rnorm.pseudo(n = 10, dimension = 5) 

Example output

Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
        [,1]       [,2] [,3]       [,4]       [,5]
 [1,] 0.5000 0.33333333 0.20 0.14285714 0.09090909
 [2,] 0.2500 0.66666667 0.40 0.28571429 0.18181818
 [3,] 0.7500 0.11111111 0.60 0.42857143 0.27272727
 [4,] 0.1250 0.44444444 0.80 0.57142857 0.36363636
 [5,] 0.6250 0.77777778 0.04 0.71428571 0.45454545
 [6,] 0.3750 0.22222222 0.24 0.85714286 0.54545455
 [7,] 0.8750 0.55555556 0.44 0.02040816 0.63636364
 [8,] 0.0625 0.88888889 0.64 0.16326531 0.72727273
 [9,] 0.5625 0.03703704 0.84 0.30612245 0.81818182
[10,] 0.3125 0.37037037 0.08 0.44897959 0.90909091
            [,1]       [,2]       [,3]       [,4]       [,5]
 [1,]  0.0000000 -0.4307273 -0.8416212 -1.0675705 -1.3351778
 [2,] -0.6744898  0.4307273 -0.2533471 -0.5659489 -0.9084579
 [3,]  0.6744898 -1.2206404  0.2533471 -0.1800124 -0.6045854
 [4,] -1.1503494 -0.1397103  0.8416212  0.1800124 -0.3487557
 [5,]  0.3186394  0.7647097 -1.7506861  0.5659489 -0.1141853
 [6,] -0.3186394 -0.7647097 -0.7063026  1.0675705  0.1141853
 [7,]  1.1503494  0.1397103 -0.1509692 -2.0453910  0.3487557
 [8,] -1.5341206  1.2206404  0.3584588 -0.9811260  0.6045854
 [9,]  0.1573107 -1.7861556  0.9944579 -0.5068717  0.9084579
[10,] -0.4887764 -0.3308726 -1.4050716 -0.1282398  1.3351778
             [,1]       [,2]      [,3]      [,4]       [,5]
 [1,] 0.950436354 0.68109632 0.7964227 0.7789565 0.23022611
 [2,] 0.505117714 0.10001624 0.5394356 0.1626085 0.29512087
 [3,] 0.174511582 0.78909695 0.1558686 0.5312862 0.65873003
 [4,] 0.677048266 0.93456304 0.3741792 0.9448425 0.60587275
 [5,] 0.002695477 0.23692979 0.9461251 0.3135361 0.46957344
 [6,] 0.447998971 0.54445767 0.7023838 0.7443066 0.03626848
 [7,] 0.872369766 0.34755683 0.1179214 0.1217073 0.91564041
 [8,] 0.418673068 0.05109646 0.2309225 0.9069471 0.13713892
 [9,] 0.776573598 0.86932755 0.5893980 0.2873443 0.75079370
[10,] 0.706255794 0.41129673 0.8402236 0.6534177 0.69252151
             [,1]       [,2]       [,3]        [,4]        [,5]
 [1,]  1.64909933  0.4707667  0.8289112  0.76867389 -0.73810241
 [2,]  0.01282859 -1.2814591  0.0990120 -0.98379378 -0.53848580
 [3,] -0.93648572  0.8032918 -1.0115836  0.07850354  0.40899966
 [4,]  0.45946060  1.5106647 -0.3208048  1.59677855  0.26857795
 [5,] -2.78269455 -0.7162134  1.6083904 -0.48585188 -0.07634218
 [6,] -0.13071858  0.1116705  0.5312691  0.65667975 -1.79573322
 [7,]  1.13766483 -0.3919250 -1.1854420 -1.16649456  1.37633104
 [8,] -0.20528928 -1.6343141 -0.7358122  1.32218750 -1.09326416
 [9,]  0.76067235  1.1232180  0.2259968 -0.56115990  0.67698953
[10,]  0.54247926 -0.2242106  0.9953773  0.39456417  0.50301041
            [,1]      [,2]       [,3]      [,4]        [,5]
 [1,] 0.29222771 0.7281048 0.63672189 0.5431828 0.070940836
 [2,] 0.11574528 0.7198382 0.02069591 0.6765897 0.993525149
 [3,] 0.18691077 0.7621712 0.23603775 0.7597572 0.960623501
 [4,] 0.42419334 0.1932581 0.25469482 0.2817705 0.007606127
 [5,] 0.76726467 0.4625299 0.86909448 0.7733348 0.814188231
 [6,] 0.83655130 0.2331329 0.54778436 0.5792517 0.746376947
 [7,] 0.08466633 0.7112312 0.89832108 0.1413082 0.669994322
 [8,] 0.77167332 0.4730453 0.69779039 0.1070985 0.076937753
 [9,] 0.27612643 0.3519474 0.20243526 0.9048102 0.165609849
[10,] 0.68283742 0.5280150 0.44043972 0.0787187 0.671508044
            [,1]        [,2]        [,3]        [,4]        [,5]
 [1,] -0.5300083 -0.27735444 -0.30590893 -0.94706996  0.09237461
 [2,] -2.1274535 -0.48382942  2.22404992 -0.02138352 -0.59919837
 [3,]  0.2087398 -0.57093579  0.68053470 -1.34325979  0.14725219
 [4,]  0.4175248 -0.73724105  0.01438017 -1.37346636 -2.80105714
 [5,]  0.5916889 -0.03620547  0.38916190  0.27749427 -0.07266138
 [6,] -1.7628146 -0.04496813  1.73189275 -0.86556729 -0.86344378
 [7,]  0.5665761  0.17168553 -0.57356550  1.13143996 -0.83553363
 [8,]  1.2484524 -0.22898792  0.15546493  0.42435769 -0.87211982
 [9,]  0.9238795 -0.21610104  0.75481179  0.09248077 -1.10699053
[10,]  0.3514042 -1.35083244 -0.67965957 -0.67518626 -1.69355367

fOptions documentation built on May 2, 2019, 2:27 p.m.