Generates Random Numbers based on a distribution defined by any arbitrary cumulative distribution function

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 range values for the domain of the Fun arguments that can be passed to Fun data set containing arguments to be passed to Fun number of observations to generate. The default_n() function will provide a default value within context One of the following: NULL (default) will not change the current seed. This is the usual case for generating random numbers. A numeric value. This will be used to set the seed before generating the random numbers. This seed will be stored with the results. TRUE. A random seed value will be generated and set as the seed before the results are generated. Again, this will be stored with the results. To extract the random seed from a previously generated set of values, use pull_seed()

## Value

A numeric vector of length n

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

## Examples


set_n(5)

my_fun <- function(x, beta = 1) {
1 - exp(-beta * x)
}

r_cdf(my_fun)
#>  1.2980998 1.0152400 0.5048573 3.2060206 0.3547609

r_cdf(~ 1 - exp(-.x), min = 0)
#>  0.05150437 0.85846782 0.24577975 0.13450980 2.78308988
r_cdf(~ 1 - exp(-.x * beta), beta = 1:10, min = 0)
#>   1.61582828 0.70951581 0.25349259 0.19785762 0.02016425 0.08192658
#>   0.02701879 0.14669299 0.12494922 0.29242635