ffrandom: Generate 'ff' vector with draws from distribution

Description Usage Arguments Details Value Examples

View source: R/ffrandom.R

Description

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

Usage

1
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.

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.

Value

An ff vector with draws from the distribution.

Examples

1
2
3
4
5
6
7
8
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[])

ffbase documentation built on Feb. 27, 2021, 5:06 p.m.