Learn R Programming

ffbase (version 0.13.3)

ffrandom: Generate ff vector with draws from distribution

Description

A convenience function to generate ff vectors with draws from random distributions using functions such as runif, rnorm and rlnorm.

Usage

ffrandom(n, rfun = runif, ..., vmode = NULL)

Arguments

n

number of observations

rfun

a function generating the draws from the random distribution. This function should expect the number of draws as its first argument. Valid examples are the routines runif, rnorm, and rlnorm.

...

additional arguments are passed on to rfun.

vmode

the vmode of the resulting vector. See ff. If none given the vmode is determined from a single draw from rfun.

Value

An ff vector with draws from the distribution.

Details

Before generating the vector a single draw is taken from the distribution. This might be important if one tries to reproduce draws directly from rfun.

Examples

Run this code
# NOT RUN {
n <- ffrandom(1E3, rnorm, mean = 10, sd = 5)

set.seed(123)
runif(1)
a <- runif(10)
set.seed(123)
b <- ffrandom(10, runif)
identical(a, b[])

# }

Run the code above in your browser using DataLab