% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rng.R
\name{rng_stream}
\alias{rng_stream}
\title{Random number stream based on caching}
\usage{
rng_stream(m, rng, ...)
}
\arguments{
\item{m}{initial cache size}

\item{rng}{a random number generator}

\item{...}{additional arguments passed to the random number generator}
}
\value{
A function that extracts random numbers from the cache and
fills the cache whenever it runs empty.
}
\description{
A random number stream uses a vectorized random number generator to generate
a cache of random numbers that can then be used sequentially. Whenever the
cache runs empty new numbers are generated automatically.
}
\examples{
runif_stream <- rng_stream(10, runif, min = -1, max = 1)
runif_stream()
}
