to_array: Compute Matrices to Arrays

View source: R/auxiliaries.R

to_arrayR Documentation

Compute Matrices to Arrays

Description

Converting higher-dimensional matrices of quasi-random numbers to arrays of specific formats.

Usage

to_array(x, f, format = c("(n*f,d)", "(n,f,d)"))

Arguments

x

(n,fd)-matrix of quasi-random numbers to be converted.

f

factor f\ge 1 dividing ncol{x}.

format

character string indicating the output format to which x should be converted.

Details

to_array() is helpful for converting quasi-random numbers to time series paths.

Value

(n * f, d)-matrix or (n, f, d)-array depending on the chosen format.

Author(s)

Marius Hofert

See Also

korobov(), ghalton(), sobol().

Examples

## 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

qrng documentation built on April 20, 2023, 5:14 p.m.

Related to to_array in qrng...