to_array | R Documentation |
Converting higher-dimensional matrices of quasi-random numbers to arrays of specific formats.
to_array(x, f, format = c("(n*f,d)", "(n,f,d)"))
x |
( |
f |
factor |
format |
|
to_array()
is helpful for converting quasi-random numbers
to time series paths.
(n * f, d)-matrix
or (n, f, d)-array
depending on the chosen format
.
Marius Hofert
korobov()
, ghalton()
, sobol()
.
## Basic call
N <- 4 # replications
n <- 3 # time steps
d <- 2 # dimension
set.seed(271) # note: respected for the choice of 'randomize'
x <- sobol(N, d = n * d, randomize = "digital.shift") # higher-dim. Sobol'
stopifnot(dim(to_array(x, f = n)) == c(N * n, d)) # conversion and check
stopifnot(dim(to_array(x, f = n, format = "(n,f,d)")) == c(N, n, d))
## See how the conversion is done
(x <- matrix(1:(N * n * d), nrow = N, byrow = TRUE))
to_array(x, f = n) # => (n * d)-column x was blocked in n groups of size d each
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.