Function that create functions that can accept and/or produce
(multiple options) A function to turn into a function that accepts and/or produces random variables:
(character vector) The names of the arguments of
(positive integer). The number of draws used to construct new
random variables if no
This function wraps an existing function (
.f) such that it returns
whatever type of data
.f would normally return.
The returned function, when called, executes
.f possibly multiple times, once for each draw of
rvars passed to it, then returns a new
rvar representing the output of those function evaluations. If the arguments contain no
.f will be executed
ndraws times and an
rvar with that many draws returned.
Functions created by
rfun() are not necessarily fast (in fact in some cases they may be very slow), but
they have the advantage of allowing a nearly arbitrary R functions to be executed against
simply by wrapping them with
rfun(). This makes it especially useful as a prototyping
tool. If you create code with
rfun() and it is unacceptably slow for your application,
consider rewriting it using math operations directly on
rvars (which should be fast),
rvar_rng(), and/or using operations directly on the arrays that back the
A function with the same argument specification as
.f, but which can accept and return
1 2 3 4 5 6 7
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.