r_cdf {rando} | R Documentation |
Generate Random Numbers Based on an arbitrary CDF
Description
Generates Random Numbers based on a distribution defined by any arbitrary cumulative distribution function
Usage
r_cdf(
Fun,
min = -Inf,
max = Inf,
...,
data = NULL,
n = default_n(..., data),
.seed = NULL
)
Arguments
Fun |
function to use as the cdf. See details |
min , max |
range values for the domain of the |
... |
arguments that can be passed to |
data |
data set containing arguments to be passed to |
n |
number of observations to generate. The |
.seed |
One of the following:
To extract the random seed from a previously generated set of
values, use |
Details
The Fun
argument accepts purrr
style inputs.
Must be vectorised, defined on the whole Real line and return a
single numeric value between 0 and 1 for any input. The random
variable will be passed to Fun
as the first argument.
This means that R's argument matching can be used with named
arguments in ...
if a different positional argument is wanted.
Value
A numeric vector of length n
Examples
set_n(5)
my_fun <- function(x, beta = 1) {
1 - exp(-beta * x)
}
r_cdf(my_fun)
r_cdf(~ 1 - exp(-.x), min = 0)
r_cdf(~ 1 - exp(-.x * beta), beta = 1:10, min = 0)